【发布时间】:2019-04-03 08:13:51
【问题描述】:
/Users/Barry/anaconda/lib/python2.7/site-packages/gensim/models/ldaseqmodel.py:217:RuntimeWarning:在 double_scalars 中遇到除以零 收敛 = np.fabs((bound - old_bound) / old_bound)
#dynamic topic model
def run_dtm(num_topics=18):
docs, years, titles = preprocessing(datasetType=2)
#resort document by years
Z = zip(years, docs)
Z = sorted(Z, reverse=False)
years_new, docs_new = zip(*Z)
#generate time slice
time_slice = Counter(years_new).values()
for year in Counter(years_new):
print year,' --- ',Counter(years_new)[year]
print '********* data set loaded ********'
dictionary = corpora.Dictionary(docs_new)
corpus = [dictionary.doc2bow(text) for text in docs_new]
print '********* train lda seq model ********'
ldaseq = ldaseqmodel.LdaSeqModel(corpus=corpus, id2word=dictionary, time_slice=time_slice, num_topics=num_topics)
print '********* lda seq model done ********'
ldaseq.print_topics(time=1)
大家好,我正在使用 gensim 包中的动态主题模型进行主题分析,遵循本教程 https://github.com/RaRe-Technologies/gensim/blob/develop/docs/notebooks/ldaseqmodel.ipynb,但是我总是遇到同样的意外错误。谁能给我一些指导?即使我尝试了一些不同的数据集来生成语料库和字典,我也很困惑。 错误是这样的:
/Users/Barry/anaconda/lib/python2.7/site-packages/gensim/models/ldaseqmodel.py:217:RuntimeWarning:在 double_scalars 中遇到除以零 收敛 = np.fabs((bound - old_bound) / old_bound)
【问题讨论】:
标签: gensim