1

I'm trying to replicate the tutorial for the Mallet wrapper in gensim. http://radimrehurek.com/2014/03/tutorial-on-mallet-in-python/

When I fit the model with

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

I get an error message:

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

When I use the model to infer the topic distribution of the example the distribution is uniform:

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]

My output:

[(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)]

Is this a problem in the functioning of the wrapper or in mallet? I've managed to replicate the mallet tutorial here: http://programminghistorian.org/lessons/topic-modeling-and-mallet

Artturi Björk
  • 3,643
  • 6
  • 27
  • 35

0 Answers0