-1
$\begingroup$

I am learning about Probabilistic Topic Models by reading this article by D. Blei, watching this video, and doing this exercise A Gentle Introduction to Topic Modeling in R.

After the topics in my corpus are defined (by the algorithm), will the "LDA" package in R allow me to find the documents for a specific topic that was modeled? Put differently, how can I check which documents contributed to the formation of a certain topic in the final model?

Any advice on this topic or how to better formulate my question is appreciated.

$\endgroup$
0
$\begingroup$

In the R code under the link for A Gentle Introduction to Topic Modeling there is a snippet that does just what I'm looking for - i.e. it attributes each document in the corpus to one of 5 theme topics.

#write out results
#docs to topics
ldaOut.topics <- as.matrix(topics(ldaOut))
write.csv(ldaOut.topics,file=paste("LDAGibbs",k,"DocsToTopics.csv"))

This snippet quantifies the probability with which each document is associated with a certain theme:

#probabilities associated with each topic assignment
topicProbabilities <- as.data.frame(ldaOut@gamma)
write.csv(topicProbabilities,file=paste("LDAGibbs",k,"TopicProbabilities.csv"))
$\endgroup$
1
  • $\begingroup$ Note that topic model attributes a stochastic mixture of the topics to each document, not one topic. $\endgroup$ – Emre Jul 8 '16 at 23:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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