主题模块 - 计算Sklearn LDA模型的相干得分?
我尝试了几种方法来计算 sklearn LDA 模型的一致性分数,但没有成功。计算 sklearn LDA 模型的一致性分数的方法是什么?
当我使用标准 gensim 代码计算一致性分数时,我收到以下错误: ValueError:当前不支持此主题模型。支持的主题模型应该实现 get_topics 方法。```
这是我的代码的一部分:
count_vectorizer = CountVectorizer(stop_words='english')
# Fit and transform the processed titles
count_data = count_vectorizer.fit_transform(training_data_preprocessed['Input'])
tf = count_data
number_topics = 5
number_words = 5
# Create and fit the LDA model
lda = LDA(n_components=number_topics)
lda.fit(tf)
# Print the topics found by the LDA model
print("Topics found via LDA:")
print_topics(lda, count_vectorizer, number_words)
I tried several things to calculate the coherence score for a sklearn LDA model, but it does not work out. What is a way to calculate the Coherence score for a sklearn LDA model?
When I use the standard gensim code to calculate the coherence score, I receive the following error: ValueError: This topic model is not currently supported. Supported topic models should implement the get_topics
method.```
Here is part of my code:
count_vectorizer = CountVectorizer(stop_words='english')
# Fit and transform the processed titles
count_data = count_vectorizer.fit_transform(training_data_preprocessed['Input'])
tf = count_data
number_topics = 5
number_words = 5
# Create and fit the LDA model
lda = LDA(n_components=number_topics)
lda.fit(tf)
# Print the topics found by the LDA model
print("Topics found via LDA:")
print_topics(lda, count_vectorizer, number_words)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您可以使用下面的代码来实现 LDA 中的一致性模型:
I think you can use this code below for coherence model in LDA: