如何使用LDA获取每个文档的主题概率以进行主题建模 [英] How to get the topic probability for each document for topic modeling using LDA

查看:163
本文介绍了如何使用LDA获取每个文档的主题概率以进行主题建模的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 scikit-learn LDA 生成LDA模型,然后获得主题词.我想知道如何获得每个文档的每个主题的概率?

I use scikit-learn LDA to generate LDA model and after that I can get the topic-terms. I am wondering how can I get the probability of each topic for each document?

推荐答案

在拟合模型后,使用 LatentDirichletAllocation 类的 transform 方法.它将返回文档主题分布.

Use the transform method of the LatentDirichletAllocation class after fitting the model. It will return the document topic distribution.

如果您使用

If you work with the example given in the documentation for scikit-learn's Latent Dirichlet Allocation, the document topic distribution can be accessed by appending the following line to the code:

doc_topic_dist = lda.transform(tf)

在这里, lda 是经过训练的LDA模型,而 tf 是文档单词矩阵.

Here, lda is the trained LDA model and tf is the document word matrix.

这篇关于如何使用LDA获取每个文档的主题概率以进行主题建模的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆