Class MultilayerPerceptronClassificationModel
Object
org.apache.spark.ml.PipelineStage
org.apache.spark.ml.Transformer
org.apache.spark.ml.Model<M>
org.apache.spark.ml.PredictionModel<FeaturesType,M>
org.apache.spark.ml.classification.ClassificationModel<FeaturesType,M>
org.apache.spark.ml.classification.ProbabilisticClassificationModel<Vector,MultilayerPerceptronClassificationModel>
org.apache.spark.ml.classification.MultilayerPerceptronClassificationModel
- All Implemented Interfaces:
Serializable,org.apache.spark.internal.Logging,ClassifierParams,MultilayerPerceptronParams,ProbabilisticClassifierParams,Params,HasBlockSize,HasFeaturesCol,HasLabelCol,HasMaxIter,HasPredictionCol,HasProbabilityCol,HasRawPredictionCol,HasSeed,HasSolver,HasStepSize,HasThresholds,HasTol,PredictorParams,HasTrainingSummary<MultilayerPerceptronClassificationTrainingSummary>,Identifiable,MLWritable
public class MultilayerPerceptronClassificationModel
extends ProbabilisticClassificationModel<Vector,MultilayerPerceptronClassificationModel>
implements MultilayerPerceptronParams, Serializable, MLWritable, HasTrainingSummary<MultilayerPerceptronClassificationTrainingSummary>
Classification model based on the Multilayer Perceptron.
Each layer has sigmoid activation function, output layer has softmax.
param: uid uid param: weights the weights of layers
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface org.apache.spark.internal.Logging
org.apache.spark.internal.Logging.LogStringContext, org.apache.spark.internal.Logging.SparkShellLoggingFilter -
Method Summary
Modifier and TypeMethodDescriptionfinal IntParamParam for block size for stacking input data in matrices.Creates a copy of this instance with the same UID and some extra params.Evaluates the model on a test dataset.The initial weights of the model.final IntArrayParamlayers()Layer sizes including input size and output size.final IntParammaxIter()Param for maximum number of iterations (>= 0).intNumber of classes (values which the label can take).intReturns the number of features the model was trained on.doublePredict label for the given features.predictRaw(Vector features) Raw prediction for each possible label.read()final LongParamseed()Param for random seed.solver()The solver algorithm for optimization.stepSize()Param for Step size to be used for each iteration of optimization (> 0).summary()Gets summary of model on training set.final DoubleParamtol()Param for the convergence tolerance for iterative algorithms (>= 0).toString()uid()An immutable unique ID for the object and its derivatives.weights()write()Returns anMLWriterinstance for this ML instance.Methods inherited from class org.apache.spark.ml.classification.ProbabilisticClassificationModel
normalizeToProbabilitiesInPlace, predictProbability, probabilityCol, setProbabilityCol, setThresholds, thresholds, transform, transformSchemaMethods inherited from class org.apache.spark.ml.classification.ClassificationModel
rawPredictionCol, setRawPredictionCol, transformImplMethods inherited from class org.apache.spark.ml.PredictionModel
featuresCol, labelCol, predictionCol, setFeaturesCol, setPredictionColMethods inherited from class org.apache.spark.ml.Transformer
transform, transform, transformMethods inherited from class org.apache.spark.ml.PipelineStage
paramsMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.spark.ml.param.shared.HasBlockSize
getBlockSizeMethods inherited from interface org.apache.spark.ml.param.shared.HasFeaturesCol
featuresCol, getFeaturesColMethods inherited from interface org.apache.spark.ml.param.shared.HasLabelCol
getLabelCol, labelColMethods inherited from interface org.apache.spark.ml.param.shared.HasMaxIter
getMaxIterMethods inherited from interface org.apache.spark.ml.param.shared.HasPredictionCol
getPredictionCol, predictionColMethods inherited from interface org.apache.spark.ml.param.shared.HasProbabilityCol
getProbabilityCol, probabilityColMethods inherited from interface org.apache.spark.ml.param.shared.HasRawPredictionCol
getRawPredictionCol, rawPredictionColMethods inherited from interface org.apache.spark.ml.param.shared.HasStepSize
getStepSizeMethods inherited from interface org.apache.spark.ml.param.shared.HasThresholds
getThresholds, thresholdsMethods inherited from interface org.apache.spark.ml.util.HasTrainingSummary
hasSummary, setSummaryMethods 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, 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.classification.MultilayerPerceptronParams
getInitialWeights, getLayersMethods 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, shouldOwnMethods inherited from interface org.apache.spark.ml.classification.ProbabilisticClassifierParams
validateAndTransformSchema
-
Method Details
-
read
-
load
-
layers
Description copied from interface:MultilayerPerceptronParamsLayer sizes including input size and output size.- Specified by:
layersin interfaceMultilayerPerceptronParams- Returns:
- (undocumented)
-
solver
Description copied from interface:MultilayerPerceptronParamsThe solver algorithm for optimization. Supported options: "gd" (minibatch gradient descent) or "l-bfgs". Default: "l-bfgs"- Specified by:
solverin interfaceHasSolver- Specified by:
solverin interfaceMultilayerPerceptronParams- Returns:
- (undocumented)
-
initialWeights
Description copied from interface:MultilayerPerceptronParamsThe initial weights of the model.- Specified by:
initialWeightsin interfaceMultilayerPerceptronParams- Returns:
- (undocumented)
-
blockSize
Description copied from interface:HasBlockSizeParam for block size for stacking input data in matrices. Data is stacked within partitions. If block size is more than remaining data in a partition then it is adjusted to the size of this data..- Specified by:
blockSizein interfaceHasBlockSize- Returns:
- (undocumented)
-
stepSize
Description copied from interface:HasStepSizeParam for Step size to be used for each iteration of optimization (> 0).- Specified by:
stepSizein interfaceHasStepSize- Returns:
- (undocumented)
-
tol
Description copied from interface:HasTolParam for the convergence tolerance for iterative algorithms (>= 0). -
maxIter
Description copied from interface:HasMaxIterParam for maximum number of iterations (>= 0).- Specified by:
maxIterin interfaceHasMaxIter- Returns:
- (undocumented)
-
seed
Description copied from interface:HasSeedParam for random seed. -
uid
Description copied from interface:IdentifiableAn immutable unique ID for the object and its derivatives.- Specified by:
uidin interfaceIdentifiable- Returns:
- (undocumented)
-
weights
-
numFeatures
public int numFeatures()Description copied from class:PredictionModelReturns the number of features the model was trained on. If unknown, returns -1- Overrides:
numFeaturesin classPredictionModel<Vector,MultilayerPerceptronClassificationModel>
-
summary
Gets summary of model on training set. An exception is thrown ifhasSummaryis false.- Specified by:
summaryin interfaceHasTrainingSummary<MultilayerPerceptronClassificationTrainingSummary>- Returns:
- (undocumented)
-
evaluate
Evaluates the model on a test dataset.- Parameters:
dataset- Test dataset to evaluate model on.- Returns:
- (undocumented)
-
predict
Predict label for the given features. This internal method is used to implementtransform()and outputPredictionModel.predictionCol().- Overrides:
predictin classClassificationModel<Vector,MultilayerPerceptronClassificationModel> - Parameters:
features- (undocumented)- Returns:
- (undocumented)
-
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().- Specified by:
copyin interfaceParams- Specified by:
copyin classModel<MultilayerPerceptronClassificationModel>- Parameters:
extra- (undocumented)- Returns:
- (undocumented)
-
write
Description copied from interface:MLWritableReturns anMLWriterinstance for this ML instance.- Specified by:
writein interfaceMLWritable- Returns:
- (undocumented)
-
predictRaw
Description copied from class:ClassificationModelRaw prediction for each possible label. The meaning of a "raw" prediction may vary between algorithms, but it intuitively gives a measure of confidence in each possible label (where larger = more confident). This internal method is used to implementtransform()and outputClassificationModel.rawPredictionCol().- Specified by:
predictRawin classClassificationModel<Vector,MultilayerPerceptronClassificationModel> - Parameters:
features- (undocumented)- Returns:
- vector where element i is the raw prediction for label i. This raw prediction may be any real number, where a larger value indicates greater confidence for that label.
-
numClasses
public int numClasses()Description copied from class:ClassificationModelNumber of classes (values which the label can take).- Specified by:
numClassesin classClassificationModel<Vector,MultilayerPerceptronClassificationModel>
-
toString
- Specified by:
toStringin interfaceIdentifiable- Overrides:
toStringin classObject
-