来自运行LDA模型的gensim的AttributeError

时间:2018-11-21 06:46:19

标签: python gensim lda

我正在尝试在Gensim上运行一个简单的LDA模型:

from gensim import corpora
#text_data here is a list of tokens
dictionary = corpora.Dictionary(text_data)
corpus = [dictionary.doc2bow(text) for text in text_data]

lda = gensim.models.ldamodel.LdaModel(corpus=corpus, num_topics=5, id2word=dictionary, passes=15)

并出现以下错误:

File ".../anaconda3/lib/python3.6/site-packages/gensim/models/ldamodel.py", line 465, in __init__
    self.random_state = utils.get_random_state(random_state)

  File ".../anaconda3/lib/python3.6/site-packages/gensim/utils.py", line 84, in get_random_state
    return np.random.mtrand._rand

AttributeError: module 'numpy.random' has no attribute 'mtrand'

我尝试了from numpy import random,但似乎没有用,也不确定为什么会引发此错误。

有什么建议吗?

编辑:重新启动Anaconda和Spyder解决了该问题。

0 个答案:

没有答案