R package for interactive topic model visualization.
LDAvis is designed to help users interpret the topics in a topic model that has been fit to a corpus of text data. The package extracts information from a fitted LDA topic model to inform an interactive web-based visualization.
If you are familiar with devtools, it is easiest to install LDAvis this way:
devtools::install_github("cpsievert/LDAvis", build_vignettes = TRUE)
Alternatively, you can decompress the zip ball or tar ball and run R CMD INSTALL
on it.
Once installed, we recommend a visit to the main help page:
library(LDAvis)
help(createJSON, package = "LDAvis")
The documentation and example on the bottom of that page should provide a quick sense of how to create (and share) your own visualizations. If you want more details about the technical specifications of the visualization, see the vignette:
vignette("details", package = "LDAvis")
Note that LDAvis itself does not provide facilities for fitting the model (only visualizing a fitted model). If you want to perform LDA in R, there are several packages, including mallet, lda, and topicmodels.
If you want to perform LDA with the R package lda and visualize the result with LDAvis, our example of a 20-topic model fit to 2,000 movie reviews may be helpful.
LDAvis does not limit you to topic modeling facilities in R. If you use other tools (MALLET and gensim are popular), we recommend that you visit our Twenty Newsgroups example to help quickly understand what components LDAvis will need.
To share a visualization that you created using LDAvis, you can encode the state of the visualization into the URL by appending a string of the form:
"#topic=k&lambda=l&term=s"
to the end of the URL, where "k", "l", and "s" are strings indicating the desired values of the selected topic, the value of lambda, and the selected term, respectively. For more details, see the last section of our Movie Reviews example, or for a quick example, see the link here:
http://cpsievert.github.io/LDAvis/reviews/vis/#topic=3&lambda=0.6&term=cop
To read about the methodology behind LDAvis, see our paper, which we presented at the 2014 ACL Workshop on Interactive Language Learning, Visualization, and Interfaces in Baltimore on June 27, 2014.