Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions python/pyspark/ml/classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,8 @@ def setThreshold(self, value):
Sets the value of :py:attr:`threshold`.
Clears value of :py:attr:`thresholds` if it has been set.
"""
self._paramMap[self.threshold] = value
if self.isSet(self.thresholds):
del self._paramMap[self.thresholds]
self._set(threshold=value)
self._clear(self.thresholds)
return self

@since("1.4.0")
Expand All @@ -169,9 +168,8 @@ def setThresholds(self, value):
Sets the value of :py:attr:`thresholds`.
Clears value of :py:attr:`threshold` if it has been set.
"""
self._paramMap[self.thresholds] = value
if self.isSet(self.threshold):
del self._paramMap[self.threshold]
self._set(thresholds=value)
self._clear(self.threshold)
return self

@since("1.5.0")
Expand Down Expand Up @@ -471,7 +469,7 @@ def setImpurity(self, value):
"""
Sets the value of :py:attr:`impurity`.
"""
self._paramMap[self.impurity] = value
self._set(impurity=value)
return self

@since("1.6.0")
Expand Down Expand Up @@ -820,7 +818,7 @@ def setLossType(self, value):
"""
Sets the value of :py:attr:`lossType`.
"""
self._paramMap[self.lossType] = value
self._set(lossType=value)
return self

@since("1.4.0")
Expand Down Expand Up @@ -950,7 +948,7 @@ def setSmoothing(self, value):
"""
Sets the value of :py:attr:`smoothing`.
"""
self._paramMap[self.smoothing] = value
self._set(smoothing=value)
return self

@since("1.5.0")
Expand All @@ -965,7 +963,7 @@ def setModelType(self, value):
"""
Sets the value of :py:attr:`modelType`.
"""
self._paramMap[self.modelType] = value
self._set(modelType=value)
return self

@since("1.5.0")
Expand Down Expand Up @@ -1095,7 +1093,7 @@ def setLayers(self, value):
"""
Sets the value of :py:attr:`layers`.
"""
self._paramMap[self.layers] = value
self._set(layers=value)
return self

@since("1.6.0")
Expand All @@ -1110,7 +1108,7 @@ def setBlockSize(self, value):
"""
Sets the value of :py:attr:`blockSize`.
"""
self._paramMap[self.blockSize] = value
self._set(blockSize=value)
return self

@since("1.6.0")
Expand Down
10 changes: 5 additions & 5 deletions python/pyspark/ml/clustering.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def setK(self, value):
"""
Sets the value of :py:attr:`k`.
"""
self._paramMap[self.k] = value
self._set(k=value)
return self

@since("1.5.0")
Expand All @@ -145,7 +145,7 @@ def setInitMode(self, value):
"""
Sets the value of :py:attr:`initMode`.
"""
self._paramMap[self.initMode] = value
self._set(initMode=value)
return self

@since("1.5.0")
Expand All @@ -160,7 +160,7 @@ def setInitSteps(self, value):
"""
Sets the value of :py:attr:`initSteps`.
"""
self._paramMap[self.initSteps] = value
self._set(initSteps=value)
return self

@since("1.5.0")
Expand Down Expand Up @@ -280,7 +280,7 @@ def setK(self, value):
"""
Sets the value of :py:attr:`k`.
"""
self._paramMap[self.k] = value
self._set(k=value)
return self

@since("2.0.0")
Expand All @@ -295,7 +295,7 @@ def setMinDivisibleClusterSize(self, value):
"""
Sets the value of :py:attr:`minDivisibleClusterSize`.
"""
self._paramMap[self.minDivisibleClusterSize] = value
self._set(minDivisibleClusterSize=value)
return self

@since("2.0.0")
Expand Down
17 changes: 10 additions & 7 deletions python/pyspark/ml/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from pyspark import since
from pyspark.ml.wrapper import JavaParams
from pyspark.ml.param import Param, Params
from pyspark.ml.param import Param, Params, TypeConverters
from pyspark.ml.param.shared import HasLabelCol, HasPredictionCol, HasRawPredictionCol
from pyspark.ml.util import keyword_only
from pyspark.mllib.common import inherit_doc
Expand Down Expand Up @@ -125,7 +125,8 @@ class BinaryClassificationEvaluator(JavaEvaluator, HasLabelCol, HasRawPrediction
"""

metricName = Param(Params._dummy(), "metricName",
"metric name in evaluation (areaUnderROC|areaUnderPR)")
"metric name in evaluation (areaUnderROC|areaUnderPR)",
typeConverter=TypeConverters.toString)

@keyword_only
def __init__(self, rawPredictionCol="rawPrediction", labelCol="label",
Expand All @@ -147,7 +148,7 @@ def setMetricName(self, value):
"""
Sets the value of :py:attr:`metricName`.
"""
self._paramMap[self.metricName] = value
self._set(metricName=value)
return self

@since("1.4.0")
Expand Down Expand Up @@ -194,7 +195,8 @@ class RegressionEvaluator(JavaEvaluator, HasLabelCol, HasPredictionCol):
# when we evaluate a metric that is needed to minimize (e.g., `"rmse"`, `"mse"`, `"mae"`),
# we take and output the negative of this metric.
metricName = Param(Params._dummy(), "metricName",
"metric name in evaluation (mse|rmse|r2|mae)")
"metric name in evaluation (mse|rmse|r2|mae)",
typeConverter=TypeConverters.toString)

@keyword_only
def __init__(self, predictionCol="prediction", labelCol="label",
Expand All @@ -216,7 +218,7 @@ def setMetricName(self, value):
"""
Sets the value of :py:attr:`metricName`.
"""
self._paramMap[self.metricName] = value
self._set(metricName=value)
return self

@since("1.4.0")
Expand Down Expand Up @@ -260,7 +262,8 @@ class MulticlassClassificationEvaluator(JavaEvaluator, HasLabelCol, HasPredictio
"""
metricName = Param(Params._dummy(), "metricName",
"metric name in evaluation "
"(f1|precision|recall|weightedPrecision|weightedRecall)")
"(f1|precision|recall|weightedPrecision|weightedRecall)",
typeConverter=TypeConverters.toString)

@keyword_only
def __init__(self, predictionCol="prediction", labelCol="label",
Expand All @@ -282,7 +285,7 @@ def setMetricName(self, value):
"""
Sets the value of :py:attr:`metricName`.
"""
self._paramMap[self.metricName] = value
self._set(metricName=value)
return self

@since("1.5.0")
Expand Down
Loading