我有 LDA 模型和文档主题概率。
# build the model on the corpus
ldam = LdaModel(corpus=corpus, num_topics=20, id2word=dictionary)
# get the document-topic probabilities
theta, _ = ldam.inference(corpus)
我还需要所有主题的单词分布,即主题-单词概率矩阵。有没有办法提取这些信息?
谢谢!
最佳答案
主题术语矩阵 (lambda) 可通过以下方式访问:
topics_terms = ldam.state.get_lambda()
如果你想要一个概率分布,只需对其进行归一化:
topics_terms_proba = np.apply_along_axis(lambda x: x/x.sum(),1,topics_terms)
关于python - 在gensim LdaModel中提取主题词概率矩阵,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42289858/