Class MultilabelClassificationEvaluator

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

public class MultilabelClassificationEvaluator extends Evaluator implements HasPredictionCol, HasLabelCol, DefaultParamsWritable
:: Experimental :: Evaluator for multi-label classification, which expects two input columns: prediction and label.
See Also:
  • Constructor Details

    • MultilabelClassificationEvaluator

      public MultilabelClassificationEvaluator(String uid)
    • MultilabelClassificationEvaluator

      public MultilabelClassificationEvaluator()
  • Method Details

    • load

      public static MultilabelClassificationEvaluator load(String path)
    • read

      public static MLReader<T> read()
    • 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 final Param<String> metricName()
      param for metric name in evaluation (supports "f1Measure" (default), "subsetAccuracy", "accuracy", "hammingLoss", "precision", "recall", "precisionByLabel", "recallByLabel", "f1MeasureByLabel", "microPrecision", "microRecall", "microF1Measure")
      Returns:
      (undocumented)
    • getMetricName

      public String getMetricName()
    • setMetricName

      public MultilabelClassificationEvaluator setMetricName(String value)
    • metricLabel

      public final DoubleParam metricLabel()
      param for the class whose metric will be computed in "precisionByLabel", "recallByLabel", "f1MeasureByLabel".
      Returns:
      (undocumented)
    • getMetricLabel

      public double getMetricLabel()
    • setMetricLabel

      public MultilabelClassificationEvaluator setMetricLabel(double value)
    • setPredictionCol

      public MultilabelClassificationEvaluator setPredictionCol(String value)
    • setLabelCol

      public MultilabelClassificationEvaluator setLabelCol(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 MultilabelMetrics getMetrics(Dataset<?> dataset)
      Get a MultilabelMetrics, which can be used to get multilabel classification metrics such as accuracy, precision, precisionByLabel, etc.

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