Class MultilayerPerceptronClassifier
Object
org.apache.spark.ml.PipelineStage
org.apache.spark.ml.Estimator<M>
org.apache.spark.ml.Predictor<FeaturesType,E,M>
org.apache.spark.ml.classification.Classifier<FeaturesType,E,M>
org.apache.spark.ml.classification.ProbabilisticClassifier<Vector,MultilayerPerceptronClassifier,MultilayerPerceptronClassificationModel>
org.apache.spark.ml.classification.MultilayerPerceptronClassifier
- 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
,DefaultParamsWritable
,Identifiable
,MLWritable
,scala.Serializable
public class MultilayerPerceptronClassifier
extends ProbabilisticClassifier<Vector,MultilayerPerceptronClassifier,MultilayerPerceptronClassificationModel>
implements MultilayerPerceptronParams, DefaultParamsWritable
Classifier trainer based on the Multilayer Perceptron.
Each layer has sigmoid activation function, output layer has softmax.
Number of inputs has to be equal to the size of feature vectors.
Number of outputs has to be equal to the total number of labels.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.spark.internal.Logging
org.apache.spark.internal.Logging.SparkShellLoggingFilter
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal IntParam
Param for block size for stacking input data in matrices.Creates a copy of this instance with the same UID and some extra params.The initial weights of the model.final IntArrayParam
layers()
Layer sizes including input size and output size.final IntParam
maxIter()
Param for maximum number of iterations (>= 0).static MLReader<T>
read()
final LongParam
seed()
Param for random seed.setBlockSize
(int value) Sets the value of paramblockSize()
.setInitialWeights
(Vector value) Sets the value of paraminitialWeights()
.setLayers
(int[] value) Sets the value of paramlayers()
.setMaxIter
(int value) Set the maximum number of iterations.setSeed
(long value) Set the seed for weights initialization if weights are not setSets the value of paramsolver()
.setStepSize
(double value) Sets the value of paramstepSize()
(applicable only for solver "gd").setTol
(double value) Set the convergence tolerance of iterations.solver()
The solver algorithm for optimization.stepSize()
Param for Step size to be used for each iteration of optimization (> 0).final DoubleParam
tol()
Param for the convergence tolerance for iterative algorithms (>= 0).uid()
An immutable unique ID for the object and its derivatives.Methods inherited from class org.apache.spark.ml.classification.ProbabilisticClassifier
probabilityCol, setProbabilityCol, setThresholds, thresholds
Methods inherited from class org.apache.spark.ml.classification.Classifier
rawPredictionCol, setRawPredictionCol
Methods inherited from class org.apache.spark.ml.Predictor
featuresCol, fit, labelCol, predictionCol, setFeaturesCol, setLabelCol, setPredictionCol, transformSchema
Methods inherited from class org.apache.spark.ml.PipelineStage
params
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.spark.ml.util.DefaultParamsWritable
write
Methods inherited from interface org.apache.spark.ml.param.shared.HasBlockSize
getBlockSize
Methods inherited from interface org.apache.spark.ml.param.shared.HasFeaturesCol
featuresCol, getFeaturesCol
Methods inherited from interface org.apache.spark.ml.param.shared.HasLabelCol
getLabelCol, labelCol
Methods inherited from interface org.apache.spark.ml.param.shared.HasMaxIter
getMaxIter
Methods inherited from interface org.apache.spark.ml.param.shared.HasPredictionCol
getPredictionCol, predictionCol
Methods inherited from interface org.apache.spark.ml.param.shared.HasProbabilityCol
getProbabilityCol, probabilityCol
Methods inherited from interface org.apache.spark.ml.param.shared.HasRawPredictionCol
getRawPredictionCol, rawPredictionCol
Methods inherited from interface org.apache.spark.ml.param.shared.HasStepSize
getStepSize
Methods inherited from interface org.apache.spark.ml.param.shared.HasThresholds
getThresholds, thresholds
Methods inherited from interface org.apache.spark.ml.util.Identifiable
toString
Methods inherited from interface org.apache.spark.internal.Logging
initializeForcefully, initializeLogIfNecessary, initializeLogIfNecessary, initializeLogIfNecessary$default$2, isTraceEnabled, log, logDebug, logDebug, logError, logError, logInfo, logInfo, logName, logTrace, logTrace, logWarning, logWarning, org$apache$spark$internal$Logging$$log_, org$apache$spark$internal$Logging$$log__$eq
Methods inherited from interface org.apache.spark.ml.util.MLWritable
save
Methods inherited from interface org.apache.spark.ml.classification.MultilayerPerceptronParams
getInitialWeights, getLayers
Methods inherited from interface org.apache.spark.ml.param.Params
clear, copyValues, defaultCopy, defaultParamMap, explainParam, explainParams, extractParamMap, extractParamMap, get, getDefault, getOrDefault, getParam, hasDefault, hasParam, isDefined, isSet, onParamChange, paramMap, params, set, set, set, setDefault, setDefault, shouldOwn
Methods inherited from interface org.apache.spark.ml.classification.ProbabilisticClassifierParams
validateAndTransformSchema
-
Constructor Details
-
MultilayerPerceptronClassifier
-
MultilayerPerceptronClassifier
public MultilayerPerceptronClassifier()
-
-
Method Details
-
load
-
read
-
layers
Description copied from interface:MultilayerPerceptronParams
Layer sizes including input size and output size.- Specified by:
layers
in interfaceMultilayerPerceptronParams
- Returns:
- (undocumented)
-
solver
Description copied from interface:MultilayerPerceptronParams
The solver algorithm for optimization. Supported options: "gd" (minibatch gradient descent) or "l-bfgs". Default: "l-bfgs"- Specified by:
solver
in interfaceHasSolver
- Specified by:
solver
in interfaceMultilayerPerceptronParams
- Returns:
- (undocumented)
-
initialWeights
Description copied from interface:MultilayerPerceptronParams
The initial weights of the model.- Specified by:
initialWeights
in interfaceMultilayerPerceptronParams
- Returns:
- (undocumented)
-
blockSize
Description copied from interface:HasBlockSize
Param 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:
blockSize
in interfaceHasBlockSize
- Returns:
- (undocumented)
-
stepSize
Description copied from interface:HasStepSize
Param for Step size to be used for each iteration of optimization (> 0).- Specified by:
stepSize
in interfaceHasStepSize
- Returns:
- (undocumented)
-
tol
Description copied from interface:HasTol
Param for the convergence tolerance for iterative algorithms (>= 0). -
maxIter
Description copied from interface:HasMaxIter
Param for maximum number of iterations (>= 0).- Specified by:
maxIter
in interfaceHasMaxIter
- Returns:
- (undocumented)
-
seed
Description copied from interface:HasSeed
Param for random seed. -
uid
Description copied from interface:Identifiable
An immutable unique ID for the object and its derivatives.- Specified by:
uid
in interfaceIdentifiable
- Returns:
- (undocumented)
-
setLayers
Sets the value of paramlayers()
.- Parameters:
value
- (undocumented)- Returns:
- (undocumented)
-
setBlockSize
Sets the value of paramblockSize()
. Default is 128.- Parameters:
value
- (undocumented)- Returns:
- (undocumented)
-
setSolver
Sets the value of paramsolver()
. Default is "l-bfgs".- Parameters:
value
- (undocumented)- Returns:
- (undocumented)
-
setMaxIter
Set the maximum number of iterations. Default is 100.- Parameters:
value
- (undocumented)- Returns:
- (undocumented)
-
setTol
Set the convergence tolerance of iterations. Smaller value will lead to higher accuracy with the cost of more iterations. Default is 1E-6.- Parameters:
value
- (undocumented)- Returns:
- (undocumented)
-
setSeed
Set the seed for weights initialization if weights are not set- Parameters:
value
- (undocumented)- Returns:
- (undocumented)
-
setInitialWeights
Sets the value of paraminitialWeights()
.- Parameters:
value
- (undocumented)- Returns:
- (undocumented)
-
setStepSize
Sets the value of paramstepSize()
(applicable only for solver "gd"). Default is 0.03.- Parameters:
value
- (undocumented)- Returns:
- (undocumented)
-
copy
Description copied from interface:Params
Creates 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:
copy
in interfaceParams
- Specified by:
copy
in classPredictor<Vector,
MultilayerPerceptronClassifier, MultilayerPerceptronClassificationModel> - Parameters:
extra
- (undocumented)- Returns:
- (undocumented)
-