0

Anyone please help me for extracting topic models results (topic terms) along with its weights.

this is my code

mallet.instances <- mallet.import(as.character(documents$id), as.character(documents$text), "custom_stopwords.csv", FALSE, token.regexp="\\p{L}[\\p{L}\\p{P}]+\\p{L}")

n.topics <- 30

topic.model <- MalletLDA(n.topics)

topic.model$loadDocuments(mallet.instances)

vocabulary <- topic.model$getVocabulary()

word.freqs <- mallet.word.freqs(topic.model)

topic.model$setAlphaOptimization(20, 50)

topic.model$train(200)

topic.model$maximize(10)

doc.topics <- mallet.doc.topics(topic.model, smoothed=T, normalized=T)

topic.words <- mallet.topic.words(topic.model, smoothed=T, normalized=T)

topic.docs <- t(doc.topics)

topic.docs <- topic.docs / rowSums(topic.docs)

write.csv(topic.docs, "topics-docs.csv" )


topics.labels <- rep("", n.topics)

for (topic in 1:n.topics) topics.labels[topic] <-paste(mallet.top.words(topic.model, topic.words[topic,],                                                                      num.top.words=10)$words, collapse=",")              

topics.labels

write.csv(topics.labels, "topics-labels.csv")
Wimpel
  • 26,031
  • 1
  • 20
  • 37
  • Welcome to SO!. Please take some time to create a proper reproducible example: https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Wimpel Oct 04 '18 at 09:15
  • Please any one help me! – shanmuga priya Oct 04 '18 at 12:34
  • 1
    It can not be emphasized enough that a message is putting yourself at the mercy of strangers. If someone has the wit and knowledge to answer your question, they probably have other things they would like to do. Making your message clear, concise and user-friendly gives you the best hope of at least one of those strangers diverting their attention away from their life towards your problem. – Wimpel Oct 04 '18 at 14:02

0 Answers0