为LDA模型选择最佳一致性得分

问题描述

我正在使用python Gensim软件包构建LDA模型(https://www.machinelearningplus.com/nlp/topic-modeling-gensim-python/#:~:text=Topic%20Modeling%20with%20Gensim%20(Python)&text=Topic%20Modeling%20is%20a%20technique,in%20the%20Python's%20Gensim%20package

为了在LDA中选择最佳主题数,我计算了(1-20)个主题的相关度得分,然后对其进行了视觉化

    def compute_coherence_values(dictionary,corpus,texts,limit,start=1,step=1):
    coherence_values = []
    model_list = []
    for num_topics in range(start,step):
        lda_model_coh = gensim.models.ldamodel.Ldamodel(corpus=corpus,num_topics=num_topics,id2word=id2word,per_word_topics=True,update_every=1,chunksize=100,random_state=80,passes=10,alpha='auto')
        model_list.append(lda_model_coh)
        coherence_model_lda = CoherenceModel(model=lda_model_coh,texts=data_words_nostops,dictionary=id2word,coherence='c_v')
        coherence_values.append(coherence_model_lda.get_coherence())

    return model_list,coherence_values

model_list,coherence_values = compute_coherence_values(dictionary=id2word,corpus=corpus,limit=21,step=1)
print(coherence_values)

输出是:

[0.6110807023750182、0.623346262237542、0.611190819343431, 0.6150879617345366、0.6661056841233617、0.6460622418348893、0.6684570240561849、0.6603704258720786、0.6781376351229919、0.6686810583507139、0.6704931154541898、0.6209832171172912、0.6223242456220992、0.583528787158143、0.5672411886488239、0.5485767400671236>,0.5801387424604389、0.5801

coherence score / topic numbers

] [1]

如图所示,一致性得分值是最高得分,值为10。但是当我使用主题间距离图将其可视化时,我发现主题很拥挤,主题间的重叠很大。因此,我使用5个和7个主题来形象化它。

intertopic distance map

2 我不确定选择哪个主题更好。 我的问题是,如何选择最佳的一致性值。科学参考建议对我会很有帮助。
[1]:https://i.stack.imgur.com/ltqrC.png

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)