How to construct the document-topic matrix using the word-topic and topic-word matrix calculated using Latent Dirichlet Allocation? I can not seem to find it anywhere, even not from the author of LDA, M.Blei.

Gensim and sklearn just work, but I want to know how to use the two matrices to construct the document topic-matrix (Spark MLLIB LDA only gives me the 2 matrices and not the document-topic matrix).

  • $\begingroup$ stackoverflow.com/questions/33072449/… $\endgroup$
    – Emre
    Jul 15, 2016 at 20:25
  • $\begingroup$ Thank you. Yes, I found that and implemented that. But I want to learn the theory and implement it for my Python friends. $\endgroup$
    – blpasd
    Jul 16, 2016 at 10:53

1 Answer 1


using the word-topic and topic-word matrix

This would be the same, wouldn't it? The model generates a words x topics and a topics x documents matrix, there is not much left to calculate, the model practically spits it out.

Using the Gibbs method gives you the counts Ntw[1..T][1..W] and Ndt[1..D][1..T], where for example Ndt[1][5] is the amount of words assigned to topic number 5 in document number 1.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.