Skip to content

Commit

Permalink
allow to add intercept in Ridge and Lasso
Browse files Browse the repository at this point in the history
  • Loading branch information
mengxr committed Apr 29, 2014
1 parent c66c56f commit 03389c0
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,6 @@ class LassoWithSGD private (
*/
def this() = this(1.0, 100, 1.0, 1.0)

override def setIntercept(addIntercept: Boolean): this.type = {
// TODO: Support adding intercept.
if (addIntercept) throw new UnsupportedOperationException("Adding intercept is not supported.")
this
}

override protected def createModel(weights: Vector, intercept: Double) = {
new LassoModel(weights, intercept)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,6 @@ class RidgeRegressionWithSGD private (
*/
def this() = this(1.0, 100, 1.0, 1.0)

override def setIntercept(addIntercept: Boolean): this.type = {
// TODO: Support adding intercept.
if (addIntercept) throw new UnsupportedOperationException("Adding intercept is not supported.")
this
}

override protected def createModel(weights: Vector, intercept: Double) = {
new RidgeRegressionModel(weights, intercept)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,4 @@ class LassoSuite extends FunSuite with LocalSparkContext {
// Test prediction on Array.
validatePrediction(validationData.map(row => model.predict(row.features)), validationData)
}

test("do not support intercept") {
intercept[UnsupportedOperationException] {
new LassoWithSGD().setIntercept(true)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,4 @@ class RidgeRegressionSuite extends FunSuite with LocalSparkContext {
assert(ridgeErr < linearErr,
"ridgeError (" + ridgeErr + ") was not less than linearError(" + linearErr + ")")
}

test("do not support intercept") {
intercept[UnsupportedOperationException] {
new RidgeRegressionWithSGD().setIntercept(true)
}
}
}

0 comments on commit 03389c0

Please sign in to comment.