Skip to content

Commit c8f2545

Browse files
dongjoon-hyunmengxr
authored andcommitted
[SPARK-13676] Fix mismatched default values for regParam in LogisticRegression
## What changes were proposed in this pull request? The default value of regularization parameter for `LogisticRegression` algorithm is different in Scala and Python. We should provide the same value. **Scala** ``` scala> new org.apache.spark.ml.classification.LogisticRegression().getRegParam res0: Double = 0.0 ``` **Python** ``` >>> from pyspark.ml.classification import LogisticRegression >>> LogisticRegression().getRegParam() 0.1 ``` ## How was this patch tested? manual. Check the following in `pyspark`. ``` >>> from pyspark.ml.classification import LogisticRegression >>> LogisticRegression().getRegParam() 0.0 ``` Author: Dongjoon Hyun <dongjoon@apache.org> Closes #11519 from dongjoon-hyun/SPARK-13676.
1 parent e617508 commit c8f2545

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

python/pyspark/ml/classification.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,33 +79,33 @@ class LogisticRegression(JavaEstimator, HasFeaturesCol, HasLabelCol, HasPredicti
7979

8080
@keyword_only
8181
def __init__(self, featuresCol="features", labelCol="label", predictionCol="prediction",
82-
maxIter=100, regParam=0.1, elasticNetParam=0.0, tol=1e-6, fitIntercept=True,
82+
maxIter=100, regParam=0.0, elasticNetParam=0.0, tol=1e-6, fitIntercept=True,
8383
threshold=0.5, thresholds=None, probabilityCol="probability",
8484
rawPredictionCol="rawPrediction", standardization=True, weightCol=None):
8585
"""
8686
__init__(self, featuresCol="features", labelCol="label", predictionCol="prediction", \
87-
maxIter=100, regParam=0.1, elasticNetParam=0.0, tol=1e-6, fitIntercept=True, \
87+
maxIter=100, regParam=0.0, elasticNetParam=0.0, tol=1e-6, fitIntercept=True, \
8888
threshold=0.5, thresholds=None, probabilityCol="probability", \
8989
rawPredictionCol="rawPrediction", standardization=True, weightCol=None)
9090
If the threshold and thresholds Params are both set, they must be equivalent.
9191
"""
9292
super(LogisticRegression, self).__init__()
9393
self._java_obj = self._new_java_obj(
9494
"org.apache.spark.ml.classification.LogisticRegression", self.uid)
95-
self._setDefault(maxIter=100, regParam=0.1, tol=1E-6, threshold=0.5)
95+
self._setDefault(maxIter=100, regParam=0.0, tol=1E-6, threshold=0.5)
9696
kwargs = self.__init__._input_kwargs
9797
self.setParams(**kwargs)
9898
self._checkThresholdConsistency()
9999

100100
@keyword_only
101101
@since("1.3.0")
102102
def setParams(self, featuresCol="features", labelCol="label", predictionCol="prediction",
103-
maxIter=100, regParam=0.1, elasticNetParam=0.0, tol=1e-6, fitIntercept=True,
103+
maxIter=100, regParam=0.0, elasticNetParam=0.0, tol=1e-6, fitIntercept=True,
104104
threshold=0.5, thresholds=None, probabilityCol="probability",
105105
rawPredictionCol="rawPrediction", standardization=True, weightCol=None):
106106
"""
107107
setParams(self, featuresCol="features", labelCol="label", predictionCol="prediction", \
108-
maxIter=100, regParam=0.1, elasticNetParam=0.0, tol=1e-6, fitIntercept=True, \
108+
maxIter=100, regParam=0.0, elasticNetParam=0.0, tol=1e-6, fitIntercept=True, \
109109
threshold=0.5, thresholds=None, probabilityCol="probability", \
110110
rawPredictionCol="rawPrediction", standardization=True, weightCol=None)
111111
Sets params for logistic regression.

0 commit comments

Comments
 (0)