0
votes

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

1 Answers

3
votes

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.