Package org.apache.spark.ml.evaluation
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
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreates a copy of this instance with the same UID and some extra params.doubleEvaluates model output and returns a scalar metric.getMetrics(Dataset<?> dataset) Get a BinaryClassificationMetrics, which can be used to get binary classification metrics such as areaUnderROC and areaUnderPR.intbooleanIndicates whether the metric returned byevaluateshould be maximized (true, default) or minimized (false).labelCol()Param for label column name.param for metric name in evaluation (supports"areaUnderROC"(default),"areaUnderPR")numBins()param for number of bins to down-sample the curves (ROC curve, PR curve) in area computation.Param for raw prediction (a.k.a.static MLReader<T>read()setLabelCol(String value) setMetricName(String value) setNumBins(int value) setRawPredictionCol(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.HasRawPredictionCol
getRawPredictionColMethods 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
-
BinaryClassificationEvaluator
-
BinaryClassificationEvaluator
public BinaryClassificationEvaluator()
-
-
Method Details
-
load
-
read
-
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)
-
rawPredictionCol
Description copied from interface:HasRawPredictionColParam for raw prediction (a.k.a. confidence) column name.- Specified by:
rawPredictionColin interfaceHasRawPredictionCol- 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"areaUnderROC"(default),"areaUnderPR")- Returns:
- (undocumented)
-
getMetricName
-
setMetricName
-
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
-
setRawPredictionCol
-
setLabelCol
-
setWeightCol
-
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 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: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
-