Class LDA
- All Implemented Interfaces:
Serializable,org.apache.spark.internal.Logging,org.apache.spark.ml.clustering.LDAParams,Params,HasCheckpointInterval,HasFeaturesCol,HasMaxIter,HasSeed,DefaultParamsWritable,Identifiable,MLWritable
Terminology: - "term" = "word": an element of the vocabulary - "token": instance of a term appearing in a document - "topic": multinomial distribution over terms representing some concept - "document": one piece of text, corresponding to one row in the input data
Original LDA paper (journal version): Blei, Ng, and Jordan. "Latent Dirichlet Allocation." JMLR, 2003.
Input data (featuresCol):
LDA is given a collection of documents as input data, via the featuresCol parameter.
Each document is specified as a Vector of length vocabSize, where each entry is the
count for the corresponding term (word) in the document. Feature transformers such as
Tokenizer and CountVectorizer
can be useful for converting text to word count vectors.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.spark.internal.Logging
org.apache.spark.internal.Logging.LogStringContext, org.apache.spark.internal.Logging.SparkShellLoggingFilter -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal IntParamParam for set checkpoint interval (>= 1) or disable checkpoint (-1).Creates a copy of this instance with the same UID and some extra params.final DoubleArrayParamParam for features column name.Fits a model to the input data.final IntParamk()final BooleanParamfinal DoubleParamfinal DoubleParamstatic LDAfinal IntParammaxIter()Param for maximum number of iterations (>= 0).final BooleanParamread()final LongParamseed()Param for random seed.setCheckpointInterval(int value) setDocConcentration(double value) setDocConcentration(double[] value) setFeaturesCol(String value) The features for LDA should be aVectorrepresenting the word counts in a document.setK(int value) setKeepLastCheckpoint(boolean value) setLearningDecay(double value) setLearningOffset(double value) setMaxIter(int value) setOptimizeDocConcentration(boolean value) setOptimizer(String value) setSeed(long value) setSubsamplingRate(double value) setTopicConcentration(double value) setTopicDistributionCol(String value) final DoubleParamfinal String[]final DoubleParamtransformSchema(StructType schema) Check transform validity and derive the output schema from the input schema.uid()An immutable unique ID for the object and its derivatives.Methods inherited from class org.apache.spark.ml.PipelineStage
paramsMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.spark.ml.util.DefaultParamsWritable
writeMethods inherited from interface org.apache.spark.ml.param.shared.HasCheckpointInterval
getCheckpointIntervalMethods inherited from interface org.apache.spark.ml.param.shared.HasFeaturesCol
getFeaturesColMethods inherited from interface org.apache.spark.ml.param.shared.HasMaxIter
getMaxIterMethods inherited from interface org.apache.spark.ml.util.Identifiable
toStringMethods inherited from interface org.apache.spark.ml.clustering.LDAParams
getDocConcentration, getK, getKeepLastCheckpoint, getLearningDecay, getLearningOffset, getOldDocConcentration, getOldOptimizer, getOldTopicConcentration, getOptimizeDocConcentration, getOptimizer, getSubsamplingRate, getTopicConcentration, getTopicDistributionCol, org$apache$spark$ml$clustering$LDAParams$_setter_$docConcentration_$eq, org$apache$spark$ml$clustering$LDAParams$_setter_$k_$eq, org$apache$spark$ml$clustering$LDAParams$_setter_$keepLastCheckpoint_$eq, org$apache$spark$ml$clustering$LDAParams$_setter_$learningDecay_$eq, org$apache$spark$ml$clustering$LDAParams$_setter_$learningOffset_$eq, org$apache$spark$ml$clustering$LDAParams$_setter_$optimizeDocConcentration_$eq, org$apache$spark$ml$clustering$LDAParams$_setter_$optimizer_$eq, org$apache$spark$ml$clustering$LDAParams$_setter_$subsamplingRate_$eq, org$apache$spark$ml$clustering$LDAParams$_setter_$supportedOptimizers_$eq, org$apache$spark$ml$clustering$LDAParams$_setter_$topicConcentration_$eq, org$apache$spark$ml$clustering$LDAParams$_setter_$topicDistributionCol_$eq, validateAndTransformSchemaMethods inherited from interface org.apache.spark.internal.Logging
initializeForcefully, initializeLogIfNecessary, initializeLogIfNecessary, initializeLogIfNecessary$default$2, isTraceEnabled, log, logBasedOnLevel, logDebug, logDebug, logDebug, logDebug, logError, logError, logError, logError, logInfo, logInfo, logInfo, logInfo, logName, LogStringContext, logTrace, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, logWarning, MDC, org$apache$spark$internal$Logging$$log_, org$apache$spark$internal$Logging$$log__$eq, withLogContextMethods inherited from interface org.apache.spark.ml.util.MLWritable
saveMethods inherited from interface org.apache.spark.ml.param.Params
clear, copyValues, defaultCopy, defaultParamMap, estimateMatadataSize, explainParam, explainParams, extractParamMap, extractParamMap, get, getDefault, getOrDefault, getParam, hasDefault, hasParam, isDefined, isSet, onParamChange, paramMap, params, set, set, set, setDefault, setDefault, shouldOwn
-
Constructor Details
-
LDA
-
LDA
public LDA()
-
-
Method Details
-
read
-
load
-
k
- Specified by:
kin interfaceorg.apache.spark.ml.clustering.LDAParams
-
docConcentration
- Specified by:
docConcentrationin interfaceorg.apache.spark.ml.clustering.LDAParams
-
topicConcentration
- Specified by:
topicConcentrationin interfaceorg.apache.spark.ml.clustering.LDAParams
-
supportedOptimizers
- Specified by:
supportedOptimizersin interfaceorg.apache.spark.ml.clustering.LDAParams
-
optimizer
- Specified by:
optimizerin interfaceorg.apache.spark.ml.clustering.LDAParams
-
topicDistributionCol
- Specified by:
topicDistributionColin interfaceorg.apache.spark.ml.clustering.LDAParams
-
learningOffset
- Specified by:
learningOffsetin interfaceorg.apache.spark.ml.clustering.LDAParams
-
learningDecay
- Specified by:
learningDecayin interfaceorg.apache.spark.ml.clustering.LDAParams
-
subsamplingRate
- Specified by:
subsamplingRatein interfaceorg.apache.spark.ml.clustering.LDAParams
-
optimizeDocConcentration
- Specified by:
optimizeDocConcentrationin interfaceorg.apache.spark.ml.clustering.LDAParams
-
keepLastCheckpoint
- Specified by:
keepLastCheckpointin interfaceorg.apache.spark.ml.clustering.LDAParams
-
checkpointInterval
Description copied from interface:HasCheckpointIntervalParam for set checkpoint interval (>= 1) or disable checkpoint (-1). E.g. 10 means that the cache will get checkpointed every 10 iterations. Note: this setting will be ignored if the checkpoint directory is not set in the SparkContext.- Specified by:
checkpointIntervalin interfaceHasCheckpointInterval- Returns:
- (undocumented)
-
seed
Description copied from interface:HasSeedParam for random seed. -
maxIter
Description copied from interface:HasMaxIterParam for maximum number of iterations (>= 0).- Specified by:
maxIterin interfaceHasMaxIter- Returns:
- (undocumented)
-
featuresCol
Description copied from interface:HasFeaturesColParam for features column name.- Specified by:
featuresColin interfaceHasFeaturesCol- Returns:
- (undocumented)
-
uid
Description copied from interface:IdentifiableAn immutable unique ID for the object and its derivatives.- Specified by:
uidin interfaceIdentifiable- Returns:
- (undocumented)
-
setFeaturesCol
The features for LDA should be aVectorrepresenting the word counts in a document. The vector should be of length vocabSize, with counts for each term (word).- Parameters:
value- (undocumented)- Returns:
- (undocumented)
-
setMaxIter
-
setSeed
-
setCheckpointInterval
-
setK
-
setDocConcentration
-
setDocConcentration
-
setTopicConcentration
-
setOptimizer
-
setTopicDistributionCol
-
setLearningOffset
-
setLearningDecay
-
setSubsamplingRate
-
setOptimizeDocConcentration
-
setKeepLastCheckpoint
-
copy
Description copied from interface:ParamsCreates a copy of this instance with the same UID and some extra params. Subclasses should implement this method and set the return type properly. SeedefaultCopy(). -
fit
Description copied from class:EstimatorFits a model to the input data. -
transformSchema
Description copied from class:PipelineStageCheck transform validity and derive the output schema from the input schema.We check validity for interactions between parameters during
transformSchemaand raise an exception if any parameter value is invalid. Parameter value checks which do not depend on other parameters are handled byParam.validate().Typical implementation should first conduct verification on schema change and parameter validity, including complex parameter interaction checks.
- Specified by:
transformSchemain classPipelineStage- Parameters:
schema- (undocumented)- Returns:
- (undocumented)
-