Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_document_topics returns and empty list #2306

Closed
senjed opened this issue Dec 23, 2018 · 4 comments
Closed

get_document_topics returns and empty list #2306

senjed opened this issue Dec 23, 2018 · 4 comments

Comments

@senjed
Copy link

senjed commented Dec 23, 2018

I trained the lda model and want to get topic distribution for a new document. However, for some documents the get_document_topics function returns and empty list and I get this warning:

/home/anaconda2/lib/python2.7/site-packages/gensim/models/ldamodel.py:676: RuntimeWarning: overflow encountered in divide
gammad = self.alpha + expElogthetad * np.dot(cts / phinorm, expElogbetad.T)

This is the way I call the function:

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

@horpto
Copy link
Contributor

horpto commented Dec 23, 2018

Hi @senjed

What does self.ldamodel.inference([new_doc_bow]) return ?
If this expression returns empty list, so what is the value of self.ldamodel.num_topics ?

@senjed
Copy link
Author

senjed commented Dec 23, 2018

Hi,
It returns (array([[nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan]], dtype=float32), None)
and num_topics is 20.

@horpto
Copy link
Contributor

horpto commented Dec 24, 2018

@senjed
Please, try to increase epsilon in gensim/models/ldamodel.py likeit is said in #2115 (comment)

@senjed
Copy link
Author

senjed commented Dec 24, 2018

it worked thanks! I am closing the issue.

@senjed senjed closed this as completed Dec 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants