Skip to content

Commit 2257fca

Browse files
author
Omede Firouz
committed
[MLLIB] Add fitIntercept param to logistic regression
Made the trait default true Changed float comparisons to === in unit tests
1 parent 329c1e2 commit 2257fca

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

mllib/src/main/scala/org/apache/spark/ml/classification/LogisticRegression.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ class LogisticRegression
4646
with LogisticRegressionParams {
4747

4848
setRegParam(0.1)
49-
setFitIntercept(true)
5049
setMaxIter(100)
5150
setThreshold(0.5)
5251

mllib/src/main/scala/org/apache/spark/ml/param/sharedParams.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ private[ml] trait HasFitIntercept extends Params {
112112
* @group param
113113
*/
114114
val fitIntercept: BooleanParam =
115-
new BooleanParam(this, "fitIntercept", "indicates whether to fit an intercept term")
115+
new BooleanParam(this, "fitIntercept", "indicates whether to fit an intercept term", Some(true))
116116

117117
/** @group getParam */
118118
def getFitIntercept: Boolean = get(fitIntercept)

mllib/src/test/scala/org/apache/spark/ml/classification/LogisticRegressionSuite.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@ class LogisticRegressionSuite extends FunSuite with MLlibTestSparkContext {
5656
assert(model.getPredictionCol == "prediction")
5757
assert(model.getRawPredictionCol == "rawPrediction")
5858
assert(model.getProbabilityCol == "probability")
59-
assert(model.intercept != 0.0)
59+
assert(model.intercept !== 0.0)
6060
}
6161

6262
test("logistic regression doesn't fit intercept when fitIntercept is off") {
6363
val lr = new LogisticRegression
6464
lr.setFitIntercept(false)
6565
val model = lr.fit(dataset)
66-
assert(model.intercept == 0.0)
66+
assert(model.intercept === 0.0)
6767
}
6868

6969
test("logistic regression with setters") {

0 commit comments

Comments
 (0)