1

我正在尝试在 gensim 中复制 Mallet 包装器的教程。http://radimrehurek.com/2014/03/tutorial-on-mallet-in-python/

当我拟合模型时

model = models.LdaMallet(mallet_path, corpus, num_topics=10, id2word=corpus.dictionary)

我收到一条错误消息:

C:\Anaconda\lib\site-packages\gensim\models\ldamallet.py:234: RuntimeWarning: invalid value encountered in divide topic = topic / topic.sum() # normalize to probability dist

当我使用模型推断示例的主题分布时,分布是均匀的:

doc = "Don't sell coffee, wheat nor sugar; trade gold, oil and gas instead."
bow = corpus.dictionary.doc2bow(utils.simple_preprocess(doc))
print model[bow]

我的输出:

[(0, 0.10000000000000002), (1, 0.10000000000000002), (2, 0.10000000000000002), (3, 0.10000000000000002), (4, 0.10000000000000002), (5, 0.10000000000000002), (6, 0.10000000000000002), (7, 0.10000000000000002), (8, 0.10000000000000002), (9, 0.10000000000000002)]

这是包装器或木槌功能中的问题吗?我已经设法在这里复制槌教程:http: //programminghistorian.org/lessons/topic-modeling-and-mallet

4

0 回答 0