Skip to content

Commit 5a6f9b4

Browse files
committed
Add metricName
1 parent 31b3c6c commit 5a6f9b4

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

python/pyspark/ml/evaluation.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -366,22 +366,41 @@ class ClusteringEvaluator(JavaEvaluator, HasPredictionCol, HasFeaturesCol,
366366
"""
367367

368368
@keyword_only
369-
def __init__(self, predictionCol="prediction", featuresCol="features"):
369+
def __init__(self, predictionCol="prediction", featuresCol="features",
370+
metricName="silhouette"):
370371
"""
371-
__init__(self, predictionCol="prediction", featuresCol="features")
372+
__init__(self, predictionCol="prediction", featuresCol="features", \
373+
metricName="silhouette")
372374
"""
373375
super(ClusteringEvaluator, self).__init__()
374376
self._java_obj = self._new_java_obj(
375377
"org.apache.spark.ml.evaluation.ClusteringEvaluator", self.uid)
376-
self._setDefault(predictionCol="prediction", featuresCol="features")
378+
self._setDefault(predictionCol="prediction", featuresCol="features",
379+
metricName="silhouette")
377380
kwargs = self._input_kwargs
378381
self._set(**kwargs)
379382

383+
@since("2.3.0")
384+
def setMetricName(self, value):
385+
"""
386+
Sets the value of :py:attr:`metricName`.
387+
"""
388+
return self._set(metricName=value)
389+
390+
@since("2.3.0")
391+
def getMetricName(self):
392+
"""
393+
Gets the value of metricName or its default value.
394+
"""
395+
return self.getOrDefault(self.metricName)
396+
380397
@keyword_only
381398
@since("2.3.0")
382-
def setParams(self, predictionCol="prediction", featuresCol="features"):
399+
def setParams(self, predictionCol="prediction", featuresCol="features",
400+
metricName="silhouette"):
383401
"""
384-
setParams(self, predictionCol="prediction", featuresCol="features")
402+
setParams(self, predictionCol="prediction", featuresCol="features", \
403+
metricName="silhouette")
385404
Sets params for clustering evaluator.
386405
"""
387406
kwargs = self._input_kwargs

0 commit comments

Comments
 (0)