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!
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With