mallet.topic.labels | R Documentation |
This function returns a vector of strings, one for each topic, with the most probable words in that topic separated by spaces.
mallet.topic.labels(topic.model, topic.words = NULL, num.top.words = 3, ...)
topic.model |
A |
topic.words |
The matrix of topic-word weights returned by |
num.top.words |
The number of words to include for each topic. Defaults to 3. |
... |
Further arguments supplied to |
a character vector with one element per topic
mallet.topic.words
produces topic-word weights.
mallet.top.words
produces a data frame for a single topic.
## Not run: # Read in sotu example data data(sotu) sotu.instances <- mallet.import(id.array = row.names(sotu), text.array = sotu[["text"]], stoplist = mallet_stoplist_file_path("en"), token.regexp = "\\p{L}[\\p{L}\\p{P}]+\\p{L}") # Create topic model topic.model <- MalletLDA(num.topics=10, alpha.sum = 1, beta = 0.1) topic.model$loadDocuments(sotu.instances) # Train topic model topic.model$train(200) # Create hiearchical clusters of topics doc_topics <- mallet.doc.topics(topic.model, smoothed=TRUE, normalized=TRUE) topic_words <- mallet.topic.words(topic.model, smoothed=TRUE, normalized=TRUE) topic_labels <- mallet.topic.labels(topic.model) plot(mallet.topic.hclust(doc_topics, topic_words, balance = 0.3), labels=topic_labels) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.