--------------------------------------------------------------------------- ImportError Traceback most recent call last ipython-input-34-11d75af83256 in module 3 from sklearndecomposition import Laten
该错误是因为sklearn.metrics库中没有coherence_score函数。可以使用gensim库中的CoherenceModel函数来计算主题模型的一致性得分。
以下是使用gensim计算一致性得分的示例代码:
from gensim.models import CoherenceModel
coherence_model_lda = CoherenceModel(model=lda_model, texts=data_lemmatized, dictionary=id2word, coherence='c_v') coherence_lda = coherence_model_lda.get_coherence() print('Coherence Score: ', coherence_lda)
原文地址: http://www.cveoy.top/t/topic/bxQJ 著作权归作者所有。请勿转载和采集!