Class BinaryClassificationEvaluator

Object
org.apache.spark.ml.evaluation.Evaluator
org.apache.spark.ml.evaluation.BinaryClassificationEvaluator
All Implemented Interfaces:
Serializable, Params, HasLabelCol, HasRawPredictionCol, HasWeightCol, DefaultParamsWritable, Identifiable, MLWritable, scala.Serializable

public class BinaryClassificationEvaluator extends Evaluator implements HasRawPredictionCol, HasLabelCol, HasWeightCol, DefaultParamsWritable
Evaluator for binary classification, which expects input columns rawPrediction, label and an optional weight column. The rawPrediction column can be of type double (binary 0/1 prediction, or probability of label 1) or of type vector (length-2 vector of raw predictions, scores, or label probabilities).
See Also:
  • Constructor Details

    • BinaryClassificationEvaluator

      public BinaryClassificationEvaluator(String uid)
    • BinaryClassificationEvaluator

      public BinaryClassificationEvaluator()
  • Method Details

    • load

      public static BinaryClassificationEvaluator load(String path)
    • read

      public static MLReader<T> read()
    • 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)
    • labelCol

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

      public Param<String> metricName()
      param for metric name in evaluation (supports "areaUnderROC" (default), "areaUnderPR")
      Returns:
      (undocumented)
    • getMetricName

      public String getMetricName()
    • setMetricName

      public BinaryClassificationEvaluator setMetricName(String value)
    • numBins

      public IntParam numBins()
      param for number of bins to down-sample the curves (ROC curve, PR curve) in area computation. If 0, no down-sampling will occur. Default: 1000.
      Returns:
      (undocumented)
    • getNumBins

      public int getNumBins()
    • setNumBins

      public BinaryClassificationEvaluator setNumBins(int value)
    • setRawPredictionCol

      public BinaryClassificationEvaluator setRawPredictionCol(String value)
    • setLabelCol

      public BinaryClassificationEvaluator setLabelCol(String value)
    • setWeightCol

      public BinaryClassificationEvaluator setWeightCol(String value)
    • evaluate

      public double evaluate(Dataset<?> dataset)
      Description copied from class: Evaluator
      Evaluates model output and returns a scalar metric. The value of Evaluator.isLargerBetter() specifies whether larger values are better.

      Specified by:
      evaluate in class Evaluator
      Parameters:
      dataset - a dataset that contains labels/observations and predictions.
      Returns:
      metric
    • getMetrics

      public BinaryClassificationMetrics getMetrics(Dataset<?> dataset)
      Get a BinaryClassificationMetrics, which can be used to get binary classification metrics such as areaUnderROC and areaUnderPR.

      Parameters:
      dataset - a dataset that contains labels/observations and predictions.
      Returns:
      BinaryClassificationMetrics
    • isLargerBetter

      public boolean isLargerBetter()
      Description copied from class: Evaluator
      Indicates whether the metric returned by evaluate should be maximized (true, default) or minimized (false). A given evaluator may support multiple metrics which may be maximized or minimized.
      Overrides:
      isLargerBetter in class Evaluator
      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 Evaluator
      Parameters:
      extra - (undocumented)
      Returns:
      (undocumented)
    • toString

      public String toString()
      Specified by:
      toString in interface Identifiable
      Overrides:
      toString in class Object