【发布时间】:2021-04-14 16:35:15
【问题描述】:
我将找到 LDA 的最佳主题数量。为此,我使用 GENSIM 如下:
def compute_coherence_values(dictionary, corpus, texts, limit, start=2, step=3):
coherence_values = []
model_list = []
for num_topics in range(start, limit, step):
model = gensim.models.wrappers.LdaMallet(mallet_path, corpus=corpus, num_topics=num_topics, id2word=id2word)
model_list.append(model)
coherencemodel = CoherenceModel(model=model, texts=texts, dictionary=dictionary, coherence='c_v')
coherence_values.append(coherencemodel.get_coherence())
return model_list, coherence_values
但我有一个属性错误:我使用了 spyder。
AttributeError: module 'gensim.models' has no attribute 'wrappers'
【问题讨论】:
标签: python gensim lda topic-modeling