2

I want to use the HDP model from gensim to get the number of topics for my corpus, I already used this corpus and dictionary to train a regular LDA model from gensim and it works fine. But now when I do

hdp = models.HdpModel(bow_corpus, dictionary)

I get

Traceback (most recent call last):
  File "models.py", line 185, in <module>
    hdp = models.HdpModel(bow_corpus, dictionary)
  File "/usr/lib/python3.8/site-packages/gensim/models/hdpmodel.py", line 391, in __init__
    self.update(corpus)
  File "/usr/lib/python3.8/site-packages/gensim/models/hdpmodel.py", line 467, in update
    start_time = time.clock()
AttributeError: module 'time' has no attribute 'clock'

Is this a bug?

$ python --version
Python 3.8.2 (default, Feb 26 2020, 22:21:03) 

Edit to add more system information

>>> print(gensim.__version__)
3.8.1

uname -a
Linux ** 5.5.9-arch1-2 #1 SMP PREEMPT Thu, 12 Mar 2020 23:01:33 +0000 x86_64 GNU/Linux
Atirag
  • 1,660
  • 7
  • 32
  • 60

1 Answers1

1

You are coming across an issue caused by deprecation of clock function of time module. It has been deprecated since Python v. 3.3 and removed in v. 3.8.

To resolve it you have 2 options:

  1. Try to upgrade gensim if you do not have the newest version.
  2. Try to downgrade Python.
sophros
  • 14,672
  • 11
  • 46
  • 75