Moniba
Moniba

Reputation: 869

get_document_topics return an empty list.

I am using gensim for topic modeling. After training the lda model I call get_document_topics on a new document to get the topic distribution. However, for some documents, the return value is an empty list. Here is my code. Any idea what could have gone wrong?

 topic_vector = [ x[1] for x in self.ldamodel.get_document_topics(new_doc_bow , minimum_probability=
0.0, per_word_topics=False)]

Upvotes: 0

Views: 466

Answers (1)

Moniba
Moniba

Reputation: 869

Here is how I solved this issue:

First, make sure your gensim version is gensim-3.6.0 you can check this by running this command in your terminal:

pip freeze | grep gensim

If not, you can uninstall your gensim and install the newer version. Then in the file gensim/models/ldamodel.py you need to edit value of epsilon to a larger value.

DTYPE_TO_EPS = {
    np.float16: 1e-5,
    np.float32: 1e-35, # modify the value and set it to 1e-5 
    np.float64: 1e-100,
}

Upvotes: 1

Related Questions