Package org.apache.spark.ml.evaluation
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
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 Summary
ConstructorsConstructorDescription -
Method Summary
Modifier and TypeMethodDescriptionfinal DoubleParambeta()The beta value, which controls precision vs recall weighting, used in"weightedFMeasure","fMeasureByLabel".Creates a copy of this instance with the same UID and some extra params.final DoubleParameps()param for eps.doubleEvaluates model output and returns a scalar metric.doublegetBeta()doublegetEps()doublegetMetrics(Dataset<?> dataset) Get a MulticlassMetrics, which can be used to get multiclass classification metrics such as accuracy, weightedPrecision, etc.booleanIndicates whether the metric returned byevaluateshould be maximized (true, default) or minimized (false).labelCol()Param for label column name.final DoubleParamThe class whose metric will be computed in"truePositiveRateByLabel","falsePositiveRateByLabel","precisionByLabel","recallByLabel","fMeasureByLabel".param for metric name in evaluation (supports"f1"(default),"accuracy","weightedPrecision","weightedRecall","weightedTruePositiveRate","weightedFalsePositiveRate","weightedFMeasure","truePositiveRateByLabel","falsePositiveRateByLabel","precisionByLabel","recallByLabel","fMeasureByLabel","logLoss","hammingLoss")Param for prediction column name.Param for Column name for predicted class conditional probabilities.static MLReader<T>read()setBeta(double value) setEps(double value) setLabelCol(String value) setMetricLabel(double value) setMetricName(String value) setPredictionCol(String value) setProbabilityCol(String value) setWeightCol(String value) toString()uid()An immutable unique ID for the object and its derivatives.Param for weight column name.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.spark.ml.util.DefaultParamsWritable
writeMethods inherited from interface org.apache.spark.ml.param.shared.HasLabelCol
getLabelColMethods inherited from interface org.apache.spark.ml.param.shared.HasPredictionCol
getPredictionColMethods inherited from interface org.apache.spark.ml.param.shared.HasProbabilityCol
getProbabilityColMethods inherited from interface org.apache.spark.ml.param.shared.HasWeightCol
getWeightColMethods inherited from interface org.apache.spark.ml.util.MLWritable
saveMethods inherited from interface org.apache.spark.ml.param.Params
clear, copyValues, defaultCopy, defaultParamMap, explainParam, explainParams, extractParamMap, extractParamMap, get, getDefault, getOrDefault, getParam, hasDefault, hasParam, isDefined, isSet, onParamChange, paramMap, params, set, set, set, setDefault, setDefault, shouldOwn
-
Constructor Details
-
MulticlassClassificationEvaluator
-
MulticlassClassificationEvaluator
public MulticlassClassificationEvaluator()
-
-
Method Details
-
load
-
read
-
probabilityCol
Description copied from interface:HasProbabilityColParam 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:
probabilityColin interfaceHasProbabilityCol- Returns:
- (undocumented)
-
weightCol
Description copied from interface:HasWeightColParam for weight column name. If this is not set or empty, we treat all instance weights as 1.0.- Specified by:
weightColin interfaceHasWeightCol- Returns:
- (undocumented)
-
labelCol
Description copied from interface:HasLabelColParam for label column name.- Specified by:
labelColin interfaceHasLabelCol- Returns:
- (undocumented)
-
predictionCol
Description copied from interface:HasPredictionColParam for prediction column name.- Specified by:
predictionColin interfaceHasPredictionCol- Returns:
- (undocumented)
-
uid
Description copied from interface:IdentifiableAn immutable unique ID for the object and its derivatives.- Specified by:
uidin interfaceIdentifiable- Returns:
- (undocumented)
-
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
-
setMetricName
-
setPredictionCol
-
setLabelCol
-
setWeightCol
-
setProbabilityCol
-
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
-
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
-
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
-
evaluate
Description copied from class:EvaluatorEvaluates model output and returns a scalar metric. The value ofEvaluator.isLargerBetter()specifies whether larger values are better. -
getMetrics
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:EvaluatorIndicates whether the metric returned byevaluateshould be maximized (true, default) or minimized (false). A given evaluator may support multiple metrics which may be maximized or minimized.- Overrides:
isLargerBetterin classEvaluator- Returns:
- (undocumented)
-
copy
Description copied from interface:ParamsCreates a copy of this instance with the same UID and some extra params. Subclasses should implement this method and set the return type properly. SeedefaultCopy(). -
toString
- Specified by:
toStringin interfaceIdentifiable- Overrides:
toStringin classObject
-