--------------------------------------------------------------------------- ImportError Traceback most recent call last ipython-input-34-11d75af83256 in module 3 fr
The 'coherence_score' function is not available in the version of scikit-learn that you are using. You can try updating scikit-learn to the latest version by running the following command:
!pip install --upgrade scikit-learn
If the issue persists even after updating scikit-learn, you can use the 'c_v' coherence score function from the gensim package instead. Here is an example:
from gensim.models.coherencemodel import CoherenceModel
# create a gensim dictionary and corpus
# ...
# create a LDA model
# ...
# calculate coherence score
cm = CoherenceModel(model=model, corpus=corpus, dictionary=dictionary, coherence='c_v')
score = cm.get_coherence()
原文地址: http://www.cveoy.top/t/topic/bxQv 著作权归作者所有。请勿转载和采集!