Class MulticlassClassificationEvaluator

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

public class MulticlassClassificationEvaluator extends Evaluator implements HasPredictionCol, HasLabelCol, HasWeightCol, HasProbabilityCol, DefaultParamsWritable
Evaluator for multiclass classification, which expects input columns: prediction, label, weight (optional) and probability (only for logLoss).
See Also:
  • Constructor Details

    • MulticlassClassificationEvaluator

      public MulticlassClassificationEvaluator(String uid)
    • MulticlassClassificationEvaluator

      public MulticlassClassificationEvaluator()
  • Method Details

    • load

      public static MulticlassClassificationEvaluator load(String path)
    • read

      public static MLReader<T> read()
    • probabilityCol

      public final Param<String> probabilityCol()
      Description copied from interface: HasProbabilityCol
      Param for Column name for predicted class conditional probabilities. Note: Not all models output well-calibrated probability estimates! These probabilities should be treated as confidences, not precise probabilities.
      Specified by:
      probabilityCol in interface HasProbabilityCol
      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)
    • labelCol

      public final Param<String> labelCol()
      Description copied from interface: HasLabelCol
      Param for label column name.
      Specified by:
      labelCol in interface HasLabelCol
      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)
    • 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 "f1" (default), "accuracy", "weightedPrecision", "weightedRecall", "weightedTruePositiveRate", "weightedFalsePositiveRate", "weightedFMeasure", "truePositiveRateByLabel", "falsePositiveRateByLabel", "precisionByLabel", "recallByLabel", "fMeasureByLabel", "logLoss", "hammingLoss")

      Returns:
      (undocumented)
    • getMetricName

      public String getMetricName()
    • setMetricName

      public MulticlassClassificationEvaluator setMetricName(String value)
    • setPredictionCol

      public MulticlassClassificationEvaluator setPredictionCol(String value)
    • setLabelCol

      public MulticlassClassificationEvaluator setLabelCol(String value)
    • setWeightCol

      public MulticlassClassificationEvaluator setWeightCol(String value)
    • setProbabilityCol

      public MulticlassClassificationEvaluator setProbabilityCol(String value)
    • metricLabel

      public final DoubleParam metricLabel()
      The class whose metric will be computed in "truePositiveRateByLabel", "falsePositiveRateByLabel", "precisionByLabel", "recallByLabel", "fMeasureByLabel". Must be greater than or equal to 0. The default value is 0.

      Returns:
      (undocumented)
    • getMetricLabel

      public double getMetricLabel()
    • setMetricLabel

      public MulticlassClassificationEvaluator setMetricLabel(double value)
    • beta

      public final DoubleParam beta()
      The beta value, which controls precision vs recall weighting, used in "weightedFMeasure", "fMeasureByLabel". Must be greater than 0. The default value is 1.

      Returns:
      (undocumented)
    • getBeta

      public double getBeta()
    • setBeta

      public MulticlassClassificationEvaluator setBeta(double value)
    • eps

      public final DoubleParam eps()
      param for eps. log-loss is undefined for p=0 or p=1, so probabilities are clipped to max(eps, min(1 - eps, p)). Must be in range (0, 0.5). The default value is 1e-15.

      Returns:
      (undocumented)
    • getEps

      public double getEps()
    • setEps

      public MulticlassClassificationEvaluator setEps(double 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 MulticlassMetrics getMetrics(Dataset<?> dataset)
      Get a MulticlassMetrics, which can be used to get multiclass classification metrics such as accuracy, weightedPrecision, etc.

      Parameters:
      dataset - a dataset that contains labels/observations and predictions.
      Returns:
      MulticlassMetrics
    • 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