问题
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?
回答1:
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)
Here, lda
is the trained LDA model and tf
is the document word matrix.
来源:https://stackoverflow.com/questions/49740675/how-to-get-the-topic-probability-for-each-document-for-topic-modeling-using-lda