Skip to content

Commit

Permalink
[MLLIB] Add fitIntercept param to logistic regression
Browse files Browse the repository at this point in the history
Made the trait default true
Changed float comparisons to === in unit tests
  • Loading branch information
Omede Firouz committed Apr 3, 2015
1 parent 329c1e2 commit 2257fca
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class LogisticRegression
with LogisticRegressionParams {

setRegParam(0.1)
setFitIntercept(true)
setMaxIter(100)
setThreshold(0.5)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private[ml] trait HasFitIntercept extends Params {
* @group param
*/
val fitIntercept: BooleanParam =
new BooleanParam(this, "fitIntercept", "indicates whether to fit an intercept term")
new BooleanParam(this, "fitIntercept", "indicates whether to fit an intercept term", Some(true))

/** @group getParam */
def getFitIntercept: Boolean = get(fitIntercept)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ class LogisticRegressionSuite extends FunSuite with MLlibTestSparkContext {
assert(model.getPredictionCol == "prediction")
assert(model.getRawPredictionCol == "rawPrediction")
assert(model.getProbabilityCol == "probability")
assert(model.intercept != 0.0)
assert(model.intercept !== 0.0)
}

test("logistic regression doesn't fit intercept when fitIntercept is off") {
val lr = new LogisticRegression
lr.setFitIntercept(false)
val model = lr.fit(dataset)
assert(model.intercept == 0.0)
assert(model.intercept === 0.0)
}

test("logistic regression with setters") {
Expand Down

0 comments on commit 2257fca

Please sign in to comment.