Class MultilayerPerceptronClassifier

All Implemented Interfaces:
Serializable, org.apache.spark.internal.Logging, org.apache.spark.ml.classification.ClassifierParams, org.apache.spark.ml.classification.MultilayerPerceptronParams, org.apache.spark.ml.classification.ProbabilisticClassifierParams, Params, HasBlockSize, HasFeaturesCol, HasLabelCol, HasMaxIter, HasPredictionCol, HasProbabilityCol, HasRawPredictionCol, HasSeed, HasSolver, HasStepSize, HasThresholds, HasTol, org.apache.spark.ml.PredictorParams, DefaultParamsWritable, Identifiable, MLWritable

public class MultilayerPerceptronClassifier extends ProbabilisticClassifier<Vector,MultilayerPerceptronClassifier,MultilayerPerceptronClassificationModel> implements org.apache.spark.ml.classification.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:
  • Constructor Details

    • MultilayerPerceptronClassifier

      public MultilayerPerceptronClassifier(String uid)
    • MultilayerPerceptronClassifier

      public MultilayerPerceptronClassifier()
  • Method Details

    • load

      public static MultilayerPerceptronClassifier load(String path)
    • read

      public static MLReader<T> read()
    • layers

      public final IntArrayParam layers()
      Specified by:
      layers in interface org.apache.spark.ml.classification.MultilayerPerceptronParams
    • solver

      public final Param<String> solver()
      Description copied from interface: HasSolver
      Param for the solver algorithm for optimization.
      Specified by:
      solver in interface HasSolver
      Specified by:
      solver in interface org.apache.spark.ml.classification.MultilayerPerceptronParams
      Returns:
      (undocumented)
    • initialWeights

      public final Param<Vector> initialWeights()
      Specified by:
      initialWeights in interface org.apache.spark.ml.classification.MultilayerPerceptronParams
    • blockSize

      public final IntParam 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 interface HasBlockSize
      Returns:
      (undocumented)
    • stepSize

      public DoubleParam stepSize()
      Description copied from interface: HasStepSize
      Param for Step size to be used for each iteration of optimization (&gt; 0).
      Specified by:
      stepSize in interface HasStepSize
      Returns:
      (undocumented)
    • tol

      public final DoubleParam tol()
      Description copied from interface: HasTol
      Param for the convergence tolerance for iterative algorithms (&gt;= 0).
      Specified by:
      tol in interface HasTol
      Returns:
      (undocumented)
    • maxIter

      public final IntParam maxIter()
      Description copied from interface: HasMaxIter
      Param for maximum number of iterations (&gt;= 0).
      Specified by:
      maxIter in interface HasMaxIter
      Returns:
      (undocumented)
    • seed

      public final LongParam seed()
      Description copied from interface: HasSeed
      Param for random seed.
      Specified by:
      seed in interface HasSeed
      Returns:
      (undocumented)
    • uid

      public String uid()
      Description copied from interface: Identifiable
      An immutable unique ID for the object and its derivatives.
      Specified by:
      uid in interface Identifiable
      Returns:
      (undocumented)
    • setLayers

      public MultilayerPerceptronClassifier setLayers(int[] value)
      Sets the value of param layers().

      Parameters:
      value - (undocumented)
      Returns:
      (undocumented)
    • setBlockSize

      public MultilayerPerceptronClassifier setBlockSize(int value)
      Sets the value of param blockSize(). Default is 128.

      Parameters:
      value - (undocumented)
      Returns:
      (undocumented)
    • setSolver

      public MultilayerPerceptronClassifier setSolver(String value)
      Sets the value of param solver(). Default is "l-bfgs".

      Parameters:
      value - (undocumented)
      Returns:
      (undocumented)
    • setMaxIter

      public MultilayerPerceptronClassifier setMaxIter(int value)
      Set the maximum number of iterations. Default is 100.

      Parameters:
      value - (undocumented)
      Returns:
      (undocumented)
    • setTol

      public MultilayerPerceptronClassifier setTol(double value)
      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

      public MultilayerPerceptronClassifier setSeed(long value)
      Set the seed for weights initialization if weights are not set

      Parameters:
      value - (undocumented)
      Returns:
      (undocumented)
    • setInitialWeights

      public MultilayerPerceptronClassifier setInitialWeights(Vector value)
      Sets the value of param initialWeights().

      Parameters:
      value - (undocumented)
      Returns:
      (undocumented)
    • setStepSize

      public MultilayerPerceptronClassifier setStepSize(double value)
      Sets the value of param stepSize() (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. See defaultCopy().
      Specified by:
      copy in interface Params
      Specified by:
      copy in class Predictor<Vector,MultilayerPerceptronClassifier,MultilayerPerceptronClassificationModel>
      Parameters:
      extra - (undocumented)
      Returns:
      (undocumented)