Reputation: 7967
I have the LDA model and the document-topic probabilities.
# build the model on the corpus
ldam = LdaModel(corpus=corpus, num_topics=20, id2word=dictionary)
# get the document-topic probabilities
theta, _ = ldam.inference(corpus)
I also need the distribution of words for all the topics i.e. a topic-word probability matrix. Is there a way to extract this information?
Thanks!
Upvotes: 4
Views: 2672
Reputation: 2399
The topics-term matrix (lambda) is accessible via :
topics_terms = ldam.state.get_lambda()
If you want a probability distribution just normalize it :
topics_terms_proba = np.apply_along_axis(lambda x: x/x.sum(),1,topics_terms)
Upvotes: 6