Github user mengxr commented on a diff in the pull request:
https://github.com/apache/spark/pull/2231#discussion_r17033162
--- Diff:
mllib/src/test/scala/org/apache/spark/mllib/classification/LogisticRegressionSuite.scala
---
@@ -125,4 +125,39 @@ class LogisticRegressionSuite extends FunSuite with
LocalSparkContext with Shoul
// Test prediction on Array.
validatePrediction(validationData.map(row =>
model.predict(row.features)), validationData)
}
+
+ test("logistic regression with initial weights and non-default
regularizer") {
+ val nPoints = 10000
+ val A = 2.0
+ val B = -1.5
+
+ val testData = LogisticRegressionSuite.generateLogisticInput(A, B,
nPoints, 42)
+
+ val initialB = -1.0
+ val initialWeights = Vectors.dense(initialB)
+
+ val testRDD = sc.parallelize(testData, 2)
+ testRDD.cache()
+
+ // Use half as many iterations as the previous test.
+ val lr = new LogisticRegressionWithSGD().setIntercept(true)
+ lr.optimizer.
+ setStepSize(10.0).
+ setNumIterations(10).
+ setRegParam(1.0)
+
+ val model = lr.run(testRDD, initialWeights)
+
+ val weight0 = model.weights(0)
+ assert(weight0 >= -450000.0 && weight0 <= -40000.0, weight0 + " not in
[-450000.0, -40000.0]")
+ assert(model.intercept >= 350000.0 && model.intercept <= 400000.0,
model.intercept + " not in [350000.0, 400000.0]")
--- End diff --
This line is too wide. We limit line width to 100 in Spark.
---
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]