Github user dbtsai commented on a diff in the pull request:
https://github.com/apache/spark/pull/8884#discussion_r40518703
--- Diff:
mllib/src/test/scala/org/apache/spark/ml/regression/LinearRegressionSuite.scala
---
@@ -350,28 +364,31 @@ class LinearRegressionSuite extends SparkFunSuite
with MLlibTestSparkContext {
as.numeric.data.V2. 5.263704
as.numeric.data.V3. 4.187419
*/
- val interceptR2 = 0.0
- val weightsR2 = Vectors.dense(5.263704, 4.187419)
-
- assert(model2.intercept ~== interceptR2 absTol 1E-3)
- assert(model2.weights ~= weightsR2 relTol 1E-3)
-
- model1.transform(dataset).select("features",
"prediction").collect().foreach {
- case Row(features: DenseVector, prediction1: Double) =>
- val prediction2 =
- features(0) * model1.weights(0) + features(1) *
model1.weights(1) + model1.intercept
- assert(prediction1 ~== prediction2 relTol 1E-5)
- }
+ val interceptR2 = 0.0
+ val weightsR2 = Vectors.dense(5.263704, 4.187419)
+
+ assert(model2.intercept ~== interceptR2 absTol 1E-3)
+ assert(model2.weights ~= weightsR2 relTol 1E-3)
+
+ model1.transform(dataset).select("features",
"prediction").collect().foreach {
+ case Row(features: DenseVector, prediction1: Double) =>
+ val prediction2 =
+ features(0) * model1.weights(0) + features(1) *
model1.weights(1) + model1.intercept
+ assert(prediction1 ~== prediction2 relTol 1E-5)
+ }
+ })
}
test("linear regression with intercept with ElasticNet regularization") {
- val trainer1 = (new
LinearRegression).setElasticNetParam(0.3).setRegParam(1.6)
- val trainer2 = (new
LinearRegression).setElasticNetParam(0.3).setRegParam(1.6)
- .setStandardization(false)
- val model1 = trainer1.fit(dataset)
- val model2 = trainer2.fit(dataset)
-
- /*
+ Seq("auto").foreach(solver => {
+ val trainer1 = (new
LinearRegression).setElasticNetParam(0.3).setRegParam(1.6)
+ .setSolver(solver)
+ val trainer2 = (new
LinearRegression).setElasticNetParam(0.3).setRegParam(1.6)
+ .setStandardization(false).setSolver(solver)
+ val model1 = trainer1.fit(dataset)
+ val model2 = trainer2.fit(dataset)
+
+ /*
weights <- coef(glmnet(features, label, family="gaussian", alpha =
0.3, lambda = 1.6))
--- End diff --
ditto. indentation
---
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]