public class LocalLDAModel extends LDAModel implements scala.Serializable
param: topics Inferred topics (vocabSize x k matrix).
| Modifier and Type | Method and Description |
|---|---|
scala.Tuple2<int[],double[]>[] |
describeTopics(int maxTermsPerTopic)
Return the topics described by weighted terms.
|
Vector |
docConcentration()
Concentration parameter (commonly named "alpha") for the prior placed on documents'
distributions over topics ("theta").
|
int |
k()
Number of topics
|
static LocalLDAModel |
load(SparkContext sc,
String path) |
double |
logLikelihood(JavaPairRDD<Long,Vector> documents)
Java-friendly version of
logLikelihood |
double |
logLikelihood(RDD<scala.Tuple2<Object,Vector>> documents)
Calculates a lower bound on the log likelihood of the entire corpus.
|
double |
logPerplexity(JavaPairRDD<Long,Vector> documents)
Java-friendly version of
logPerplexity |
double |
logPerplexity(RDD<scala.Tuple2<Object,Vector>> documents)
Calculate an upper bound on perplexity.
|
void |
save(SparkContext sc,
String path)
Save this model to the given path.
|
double |
topicConcentration()
Concentration parameter (commonly named "beta" or "eta") for the prior placed on topics'
distributions over terms.
|
Vector |
topicDistribution(Vector document)
Predicts the topic mixture distribution for a document (often called "theta" in the
literature).
|
JavaPairRDD<Long,Vector> |
topicDistributions(JavaPairRDD<Long,Vector> documents)
Java-friendly version of
topicDistributions |
RDD<scala.Tuple2<Object,Vector>> |
topicDistributions(RDD<scala.Tuple2<Object,Vector>> documents)
Predicts the topic mixture distribution for each document (often called "theta" in the
literature).
|
Matrix |
topics() |
Matrix |
topicsMatrix()
Inferred topics, where each topic is represented by a distribution over terms.
|
int |
vocabSize()
Vocabulary size (number of terms or terms in the vocabulary)
|
describeTopicspublic static LocalLDAModel load(SparkContext sc, String path)
public Matrix topics()
public Vector docConcentration()
LDAModelThis is the parameter to a Dirichlet distribution.
docConcentration in class LDAModelpublic double topicConcentration()
LDAModelThis is the parameter to a symmetric Dirichlet distribution.
topicConcentration in class LDAModelpublic int k()
LDAModelpublic int vocabSize()
LDAModelpublic Matrix topicsMatrix()
LDAModeltopicsMatrix in class LDAModelpublic scala.Tuple2<int[],double[]>[] describeTopics(int maxTermsPerTopic)
LDAModeldescribeTopics in class LDAModelmaxTermsPerTopic - Maximum number of terms to collect for each topic.public void save(SparkContext sc, String path)
SaveableThis saves: - human-readable (JSON) model metadata to path/metadata/ - Parquet formatted data to path/data/
The model may be loaded using Loader.load.
public double logLikelihood(RDD<scala.Tuple2<Object,Vector>> documents)
See Equation (16) in original Online LDA paper.
documents - test corpus to use for calculating log likelihoodpublic double logLikelihood(JavaPairRDD<Long,Vector> documents)
logLikelihooddocuments - (undocumented)public double logPerplexity(RDD<scala.Tuple2<Object,Vector>> documents)
documents - test corpus to use for calculating perplexitypublic double logPerplexity(JavaPairRDD<Long,Vector> documents)
logPerplexitydocuments - (undocumented)public RDD<scala.Tuple2<Object,Vector>> topicDistributions(RDD<scala.Tuple2<Object,Vector>> documents)
This uses a variational approximation following Hoffman et al. (2010), where the approximate distribution is called "gamma." Technically, this method returns this approximation "gamma" for each document.
documents - documents to predict topic mixture distributions forpublic Vector topicDistribution(Vector document)
Note this means to allow quick query for single document. For batch documents, please refer
to topicDistributions() to avoid overhead.
document - document to predict topic mixture distributions forpublic JavaPairRDD<Long,Vector> topicDistributions(JavaPairRDD<Long,Vector> documents)
topicDistributionsdocuments - (undocumented)