forked from cpsievert/LDAvis
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
a few color and text-size changes to the javascript
- Loading branch information
Showing
4 changed files
with
146 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
% Generated by roxygen2 (4.0.1): do not edit by hand | ||
\name{newJSON} | ||
\alias{newJSON} | ||
\title{Create the JSON object to read into the javascript visualization} | ||
\usage{ | ||
newJSON(phi = matrix(), theta = matrix(), alpha = numeric(), | ||
beta = numeric(), doc.length = integer(), vocab = character(), | ||
term.frequency = integer(), R = 30, print.progress = FALSE) | ||
} | ||
\arguments{ | ||
\item{phi}{matrix, with each row containing the | ||
distribution over terms for a topic, with as many rows as | ||
there are topics in the model, and as many columns as | ||
there are terms in the vocabulary.} | ||
|
||
\item{theta}{matrix, with each row containing the | ||
probability distribution over topics for a document, with | ||
as many rows as there are documents in the corpus, and as | ||
many columns as there are topics in the model.} | ||
|
||
\item{alpha}{numeric vector with as many elements as | ||
there are topics in the model, containing the parameters | ||
of the Dirichlet prior distribution over topics for each | ||
document.} | ||
|
||
\item{beta}{numeric vector with as many elements as there | ||
are terms in the vocabulary, containing the parameters of | ||
the Dirichlet prior distribution over terms for each | ||
topic.} | ||
|
||
\item{doc.length}{integer vector containing the number of | ||
tokens in each document in the corpus.} | ||
|
||
\item{vocab}{character vector of the terms in the | ||
vocabulary (in the same order as the columns of | ||
\code{phi} and the elements of \code{beta})} | ||
|
||
\item{term.frequency}{integer vector containing the | ||
frequency of each term in the vocabulary} | ||
|
||
\item{R}{integer, the number of terms to display in the | ||
barcharts of the interactive viz. Default is 30. | ||
Recommended to be roughly between 10 and 50.} | ||
|
||
\item{print.progress}{logical; should the function print | ||
progress to the screen during computation?} | ||
} | ||
\value{ | ||
a JSON object in R that can be written to a file to feed | ||
the interactive visualization | ||
} | ||
\description{ | ||
This function creates the JSON object that feeds the | ||
javascript visualization that is currently stored in | ||
'path-to-LDAvis/LDAvis/inst/htmljs/' | ||
} | ||
\details{ | ||
The function first computes the topic frequencies (across | ||
the whole corpus), and then it reorders the topics in | ||
decreasing order of frequency. The main computation is to | ||
loop through the topics and through 101 values of lambda | ||
(0, 0.01, 0.02, .., 1) to compute the R most relevant terms | ||
for each topic and value of lambda. If \code{print.progress | ||
= TRUE} progress in this loop (which can take a minute or | ||
two) will print to the screen. For more details, see | ||
Sievert and Shirley, 2014, ACL Workshop. | ||
} | ||
\examples{ | ||
# This example uses Newsgroup documents from | ||
# http://qwone.com/~jason/20Newsgroups/ | ||
|
||
#data("Newsgroupdata", package = "LDAvis") | ||
|
||
# K = 50 topics | ||
# W = 22524 terms in the vocabulary | ||
|
||
#json <- newJSON(...) | ||
|
||
# Open vis in a browser! | ||
#serVis(json) | ||
|
||
# By default serVis uses a temporary directory | ||
# Instead, we could write files to current working directory | ||
#serVis(json, out.dir = '.', open.browser = FALSE) | ||
|
||
# If you have a GitHub account and want to quickly share with others! | ||
serVis(json, as.gist = TRUE) | ||
} | ||
\seealso{ | ||
\link{serVis} | ||
} | ||
|