Package org.apache.spark.ml.evaluation
Class RankingEvaluator
Object
org.apache.spark.ml.evaluation.Evaluator
org.apache.spark.ml.evaluation.RankingEvaluator
- All Implemented Interfaces:
Serializable
,Params
,HasLabelCol
,HasPredictionCol
,DefaultParamsWritable
,Identifiable
,MLWritable
public class RankingEvaluator
extends Evaluator
implements HasPredictionCol, HasLabelCol, DefaultParamsWritable
:: Experimental ::
Evaluator for ranking, which expects two input columns: prediction and label.
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionCreates a copy of this instance with the same UID and some extra params.double
Evaluates model output and returns a scalar metric.int
getK()
getMetrics
(Dataset<?> dataset) Get a RankingMetrics, which can be used to get ranking metrics such as meanAveragePrecision, meanAveragePrecisionAtK, etc.boolean
Indicates whether the metric returned byevaluate
should be maximized (true, default) or minimized (false).final IntParam
k()
param for ranking position value used in"meanAveragePrecisionAtK"
,"precisionAtK"
,"ndcgAtK"
,"recallAtK"
.labelCol()
Param for label column name.static RankingEvaluator
param for metric name in evaluation (supports"meanAveragePrecision"
(default),"meanAveragePrecisionAtK"
,"precisionAtK"
,"ndcgAtK"
,"recallAtK"
)Param for prediction column name.static MLReader<T>
read()
setK
(int value) setLabelCol
(String value) setMetricName
(String value) setPredictionCol
(String value) toString()
uid()
An immutable unique ID for the object and its derivatives.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.spark.ml.util.DefaultParamsWritable
write
Methods inherited from interface org.apache.spark.ml.param.shared.HasLabelCol
getLabelCol
Methods inherited from interface org.apache.spark.ml.param.shared.HasPredictionCol
getPredictionCol
Methods inherited from interface org.apache.spark.ml.util.MLWritable
save
Methods 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
-
RankingEvaluator
-
RankingEvaluator
public RankingEvaluator()
-
-
Method Details
-
load
-
read
-
labelCol
Description copied from interface:HasLabelCol
Param for label column name.- Specified by:
labelCol
in interfaceHasLabelCol
- Returns:
- (undocumented)
-
predictionCol
Description copied from interface:HasPredictionCol
Param for prediction column name.- Specified by:
predictionCol
in interfaceHasPredictionCol
- Returns:
- (undocumented)
-
uid
Description copied from interface:Identifiable
An immutable unique ID for the object and its derivatives.- Specified by:
uid
in interfaceIdentifiable
- Returns:
- (undocumented)
-
metricName
param for metric name in evaluation (supports"meanAveragePrecision"
(default),"meanAveragePrecisionAtK"
,"precisionAtK"
,"ndcgAtK"
,"recallAtK"
)- Returns:
- (undocumented)
-
getMetricName
-
setMetricName
-
k
param for ranking position value used in"meanAveragePrecisionAtK"
,"precisionAtK"
,"ndcgAtK"
,"recallAtK"
. Must be > 0. The default value is 10.- Returns:
- (undocumented)
-
getK
public int getK() -
setK
-
setPredictionCol
-
setLabelCol
-
evaluate
Description copied from class:Evaluator
Evaluates model output and returns a scalar metric. The value ofEvaluator.isLargerBetter()
specifies whether larger values are better. -
getMetrics
Get a RankingMetrics, which can be used to get ranking metrics such as meanAveragePrecision, meanAveragePrecisionAtK, etc.- Parameters:
dataset
- a dataset that contains labels/observations and predictions.- Returns:
- RankingMetrics
-
isLargerBetter
public boolean isLargerBetter()Description copied from class:Evaluator
Indicates whether the metric returned byevaluate
should be maximized (true, default) or minimized (false). A given evaluator may support multiple metrics which may be maximized or minimized.- Overrides:
isLargerBetter
in classEvaluator
- 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. SeedefaultCopy()
. -
toString
- Specified by:
toString
in interfaceIdentifiable
- Overrides:
toString
in classObject
-