运行LDA mod的gensim的AttributeError

2024-04-29 19:59:48 发布

您现在位置:Python中文网/ 问答频道 /正文

我试着在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)

得到以下错误:

^{pr2}$

我尝试过from numpy import random,但似乎不起作用,也不确定为什么会抛出这个错误。在

有什么建议吗?在

编辑:重新启动Python和Spyder解决了这个问题。在


Tags: textfrom模型importdatadictionaryhereis