Class OneVsRest

All Implemented Interfaces:
Serializable, org.apache.spark.internal.Logging, ClassifierParams, ClassifierTypeTrait, OneVsRestParams, Params, HasFeaturesCol, HasLabelCol, HasParallelism, HasPredictionCol, HasRawPredictionCol, HasWeightCol, PredictorParams, Identifiable, MLWritable

public final class OneVsRest extends Estimator<OneVsRestModel> implements OneVsRestParams, HasParallelism, MLWritable
Reduction of Multiclass Classification to Binary Classification. Performs reduction using one against all strategy. For a multiclass classification with k classes, train k models (one per class). Each example is scored against all k models and the model with highest score is picked to label the example.
See Also:
  • Constructor Details

    • OneVsRest

      public OneVsRest(String uid)
    • OneVsRest

      public OneVsRest()
  • Method Details

    • read

      public static MLReader<OneVsRest> read()
    • load

      public static OneVsRest load(String path)
    • parallelism

      public IntParam parallelism()
      Description copied from interface: HasParallelism
      The number of threads to use when running parallel algorithms. Default is 1 for serial execution

      Specified by:
      parallelism in interface HasParallelism
      Returns:
      (undocumented)
    • classifier

      Description copied from interface: OneVsRestParams
      param for the base binary classifier that we reduce multiclass classification into. The base classifier input and output columns are ignored in favor of the ones specified in OneVsRest.
      Specified by:
      classifier in interface OneVsRestParams
      Returns:
      (undocumented)
    • weightCol

      public final Param<String> weightCol()
      Description copied from interface: HasWeightCol
      Param for weight column name. If this is not set or empty, we treat all instance weights as 1.0.
      Specified by:
      weightCol in interface HasWeightCol
      Returns:
      (undocumented)
    • rawPredictionCol

      public final Param<String> rawPredictionCol()
      Description copied from interface: HasRawPredictionCol
      Param for raw prediction (a.k.a. confidence) column name.
      Specified by:
      rawPredictionCol in interface HasRawPredictionCol
      Returns:
      (undocumented)
    • predictionCol

      public final Param<String> predictionCol()
      Description copied from interface: HasPredictionCol
      Param for prediction column name.
      Specified by:
      predictionCol in interface HasPredictionCol
      Returns:
      (undocumented)
    • featuresCol

      public final Param<String> featuresCol()
      Description copied from interface: HasFeaturesCol
      Param for features column name.
      Specified by:
      featuresCol in interface HasFeaturesCol
      Returns:
      (undocumented)
    • labelCol

      public final Param<String> labelCol()
      Description copied from interface: HasLabelCol
      Param for label column name.
      Specified by:
      labelCol in interface HasLabelCol
      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)
    • setClassifier

      public OneVsRest setClassifier(Classifier<?,?,?> value)
    • setLabelCol

      public OneVsRest setLabelCol(String value)
    • setFeaturesCol

      public OneVsRest setFeaturesCol(String value)
    • setPredictionCol

      public OneVsRest setPredictionCol(String value)
    • setRawPredictionCol

      public OneVsRest setRawPredictionCol(String value)
    • setParallelism

      public OneVsRest setParallelism(int value)
      The implementation of parallel one vs. rest runs the classification for each class in a separate threads.

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

      public OneVsRest setWeightCol(String value)
      Sets the value of param weightCol().

      This is ignored if weight is not supported by classifier(). If this is not set or empty, we treat all instance weights as 1.0. Default is not set, so all instances have weight one.

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

      public StructType transformSchema(StructType schema)
      Description copied from class: PipelineStage
      Check transform validity and derive the output schema from the input schema.

      We check validity for interactions between parameters during transformSchema and raise an exception if any parameter value is invalid. Parameter value checks which do not depend on other parameters are handled by Param.validate().

      Typical implementation should first conduct verification on schema change and parameter validity, including complex parameter interaction checks.

      Specified by:
      transformSchema in class PipelineStage
      Parameters:
      schema - (undocumented)
      Returns:
      (undocumented)
    • fit

      public OneVsRestModel fit(Dataset<?> dataset)
      Description copied from class: Estimator
      Fits a model to the input data.
      Specified by:
      fit in class Estimator<OneVsRestModel>
      Parameters:
      dataset - (undocumented)
      Returns:
      (undocumented)
    • copy

      public OneVsRest copy(ParamMap extra)
      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 Estimator<OneVsRestModel>
      Parameters:
      extra - (undocumented)
      Returns:
      (undocumented)
    • write

      public MLWriter write()
      Description copied from interface: MLWritable
      Returns an MLWriter instance for this ML instance.
      Specified by:
      write in interface MLWritable
      Returns:
      (undocumented)