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").
|
protected java.lang.String |
formatVersion()
Current version of model save/load format.
|
protected double |
gammaShape()
Shape parameter for random initialization of variational parameter gamma.
|
int |
k()
Number of topics
|
static LocalLDAModel |
load(SparkContext sc,
java.lang.String path) |
double |
logLikelihood(JavaPairRDD<java.lang.Long,Vector> documents)
Java-friendly version of
logLikelihood |
double |
logLikelihood(RDD<scala.Tuple2<java.lang.Object,Vector>> documents)
Calculates a lower bound on the log likelihood of the entire corpus.
|
double |
logPerplexity(JavaPairRDD<java.lang.Long,Vector> documents)
Java-friendly version of
logPerplexity |
double |
logPerplexity(RDD<scala.Tuple2<java.lang.Object,Vector>> documents)
Calculate an upper bound bound on perplexity.
|
void |
save(SparkContext sc,
java.lang.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.
|
JavaPairRDD<java.lang.Long,Vector> |
topicDistributions(JavaPairRDD<java.lang.Long,Vector> documents)
Java-friendly version of
topicDistributions |
RDD<scala.Tuple2<java.lang.Object,Vector>> |
topicDistributions(RDD<scala.Tuple2<java.lang.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)
|
describeTopics
public static LocalLDAModel load(SparkContext sc, java.lang.String path)
public Matrix topics()
public Vector docConcentration()
LDAModel
This is the parameter to a Dirichlet distribution.
docConcentration
in class LDAModel
public double topicConcentration()
LDAModel
This is the parameter to a symmetric Dirichlet distribution.
Note: The topics' distributions over terms are called "beta" in the original LDA paper by Blei et al., but are called "phi" in many later papers such as Asuncion et al., 2009.
topicConcentration
in class LDAModel
protected double gammaShape()
LDAModel
gammaShape
in class LDAModel
public int k()
LDAModel
public int vocabSize()
LDAModel
public Matrix topicsMatrix()
LDAModel
topicsMatrix
in class LDAModel
public scala.Tuple2<int[],double[]>[] describeTopics(int maxTermsPerTopic)
LDAModel
describeTopics
in class LDAModel
maxTermsPerTopic
- Maximum number of terms to collect for each topic.protected java.lang.String formatVersion()
Saveable
formatVersion
in interface Saveable
public void save(SparkContext sc, java.lang.String path)
Saveable
This 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<java.lang.Object,Vector>> documents)
See Equation (16) in original Online LDA paper.
documents
- test corpus to use for calculating log likelihoodpublic double logLikelihood(JavaPairRDD<java.lang.Long,Vector> documents)
logLikelihood
documents
- (undocumented)public double logPerplexity(RDD<scala.Tuple2<java.lang.Object,Vector>> documents)
documents
- test corpus to use for calculating perplexitypublic double logPerplexity(JavaPairRDD<java.lang.Long,Vector> documents)
logPerplexity
public RDD<scala.Tuple2<java.lang.Object,Vector>> topicDistributions(RDD<scala.Tuple2<java.lang.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 JavaPairRDD<java.lang.Long,Vector> topicDistributions(JavaPairRDD<java.lang.Long,Vector> documents)
topicDistributions
documents
- (undocumented)