Github user dbtsai commented on a diff in the pull request:
https://github.com/apache/spark/pull/17715#discussion_r113073040
--- Diff:
mllib/src/test/scala/org/apache/spark/ml/classification/LogisticRegressionSuite.scala
---
@@ -815,6 +904,40 @@ class LogisticRegressionSuite
assert(model2.coefficients ~= coefficientsR relTol 1E-3)
}
+ test("binary logistic regression with intercept with L2 regularization
with bound") {
+ val upperBoundOfCoefficients = Matrices.dense(1, 4, Array(1.0, 0.0,
1.0, 0.0))
+ val upperBoundOfIntercept = Vectors.dense(1.0)
+
+ val trainer1 = new LogisticRegression()
+ .setUpperBoundOfCoefficients(upperBoundOfCoefficients)
+ .setUpperBoundOfIntercept(upperBoundOfIntercept)
+ .setRegParam(1.37)
+ .setFitIntercept(true)
+ .setStandardization(true)
+ .setWeightCol("weight")
+ val trainer2 = new LogisticRegression()
+ .setUpperBoundOfCoefficients(upperBoundOfCoefficients)
+ .setUpperBoundOfIntercept(upperBoundOfIntercept)
+ .setRegParam(1.37)
+ .setFitIntercept(true)
+ .setStandardization(false)
+ .setWeightCol("weight")
+
+ val model1 = trainer1.fit(binaryDataset)
+ val model2 = trainer2.fit(binaryDataset)
+
+ // The solution is generated by
https://github.com/yanboliang/bound-optimization.
+ val coefficientsExpectedStd = Vectors.dense(-0.06985003, 0.0,
-0.04794278, -0.10168595)
--- End diff --
`coefficientsExpectedWithStd` is easier to read :)
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]