Package org.apache.spark.ml.evaluation
Class ClusteringEvaluator
Object
org.apache.spark.ml.evaluation.Evaluator
org.apache.spark.ml.evaluation.ClusteringEvaluator
- All Implemented Interfaces:
Serializable,Params,HasFeaturesCol,HasPredictionCol,HasWeightCol,DefaultParamsWritable,Identifiable,MLWritable
public class ClusteringEvaluator
extends Evaluator
implements HasPredictionCol, HasFeaturesCol, HasWeightCol, DefaultParamsWritable
Evaluator for clustering results.
The metric computes the Silhouette measure using the specified distance measure.
The Silhouette is a measure for the validation of the consistency within clusters. It ranges between 1 and -1, where a value close to 1 means that the points in a cluster are close to the other points in the same cluster and far from the points of the other clusters.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreates a copy of this instance with the same UID and some extra params.param for distance measure to be used in evaluation (supports"squaredEuclidean"(default),"cosine")doubleEvaluates model output and returns a scalar metric.Param for features column name.getMetrics(Dataset<?> dataset) Get a ClusteringMetrics, which can be used to get clustering metrics such as silhouette score.booleanIndicates whether the metric returned byevaluateshould be maximized (true, default) or minimized (false).static ClusteringEvaluatorparam for metric name in evaluation (supports"silhouette"(default))Param for prediction column name.static MLReader<T>read()setDistanceMeasure(String value) setFeaturesCol(String value) setMetricName(String value) setPredictionCol(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.HasFeaturesCol
getFeaturesColMethods inherited from interface org.apache.spark.ml.param.shared.HasPredictionCol
getPredictionColMethods 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, estimateMatadataSize, explainParam, explainParams, extractParamMap, extractParamMap, get, getDefault, getOrDefault, getParam, hasDefault, hasParam, isDefined, isSet, onParamChange, paramMap, params, set, set, set, setDefault, setDefault, shouldOwn
-
Constructor Details
-
ClusteringEvaluator
-
ClusteringEvaluator
public ClusteringEvaluator()
-
-
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)
-
featuresCol
Description copied from interface:HasFeaturesColParam for features column name.- Specified by:
featuresColin interfaceHasFeaturesCol- 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)
-
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(). -
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)
-
setPredictionCol
-
setFeaturesCol
-
setWeightCol
-
metricName
param for metric name in evaluation (supports"silhouette"(default))- Returns:
- (undocumented)
-
getMetricName
-
setMetricName
-
distanceMeasure
param for distance measure to be used in evaluation (supports"squaredEuclidean"(default),"cosine")- Returns:
- (undocumented)
-
getDistanceMeasure
-
setDistanceMeasure
-
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 ClusteringMetrics, which can be used to get clustering metrics such as silhouette score.- Parameters:
dataset- a dataset that contains labels/observations and predictions.- Returns:
- ClusteringMetrics
-
toString
- Specified by:
toStringin interfaceIdentifiable- Overrides:
toStringin classObject
-