
非监督学习
:
主题建模与聚类
|
257
from gensim.models import LdaModel
lda_gensim_para = LdaModel(corpus=bow_gensim_para, id2word=dict_gensim_para,
chunksize=2000, alpha='auto', eta='auto', iterations=400, num_topics=10,
passes=20, eval_every=None, random_state=42)
我们感兴趣的是主题的单词分布:
display_topics_gensim(lda_gensim_para)
输出结果:
texts=gensim_paragraphs,
dictionary=dict_gensim_para,
coherence='c_v')
nmf_gensim_para_coherence_score = nmf_gensim_para_coherence.get_coherence()
print(nmf_gensim_para_coherence_score)
Out:
0.6500661701098243
The score varies with the number of topics. If you want to find the optimal number of
topics, a frequent approach is to run NMF for several ...