Skip to content
Advertisement

Gensim LDA Coherence Score Nan

I created a Gensim LDA Model as shown in this tutorial: https://www.machinelearningplus.com/nlp/topic-modeling-gensim-python/

JavaScript

And it generates 10 topics with a log_perplexity of:

lda_model.log_perplexity(data_df[‘bow_corpus’]) = -5.325966117835991

But when I run the coherence model on it to calculate coherence score, like so:

JavaScript

My LDA-Score is nan. What am I doing wrong here?

Advertisement

Answer

Solved! Coherence Model requires the original text, instead of the training corpus fed to LDA_Model – so when i ran this:

JavaScript

I got a coherence score of: 0.462

Hope this helps someone else making the same mistake. Thanks!

Advertisement