Get an array of topic words and an array of topic document from lda gensim

Situation:

I have a matrix matrix term-document example: [[0,1,0,0 ....], .... [...... 0,0,0,0]].

I have included the above matrix in the ldamodel gensim method. And it works great with the paired method lda = LdaModel(corpus, num_topics=10) . corpus is my term documentary matrix mentioned above. I need two intermediate matrices (an array of words and an array of documents ) for research purposes.

1) for each probabilistic matrix of the document (p_d_t)

2) the probability matrix of a word word (p_w_t)

Question:

How to get this array from gensim function LdaModel() .? Please help me with getting these matrices.

+5
source share
1 answer

1. The probability matrix of the document tag:

Apply the conversion to your enclosure.

 docTopicProbMat = lda[corpus] 
  1. The probability matrix of words by topic:

K = lda.num_topics topicWordProbMat = lda.print_topics(K)

+9
source

Source: https://habr.com/ru/post/1202404/


All Articles