Github user feynmanliang commented on a diff in the pull request:
https://github.com/apache/spark/pull/8022#discussion_r37824754
--- Diff:
mllib/src/test/scala/org/apache/spark/mllib/classification/StreamingLogisticRegressionSuite.scala
---
@@ -184,4 +184,72 @@ class StreamingLogisticRegressionSuite extends
SparkFunSuite with TestSuiteBase
)
val output: Seq[Seq[(Double, Double)]] = runStreams(ssc, numBatches,
numBatches)
}
+
+ test("parameter accuracy with full memory (decayFactor = 1)") {
+
+ val nPoints = 100
+
+ // create model
+ val model = new StreamingLogisticRegressionWithSGD()
+ .setDecayFactor(1)
+ .setInitialWeights(Vectors.dense(0.0))
+ .setStepSize(0.5)
+ .setNumIterations(50)
+
+ // generate sequence of simulated data
+ val numBatches = 20
+ // the first few RDD's are generated under the model A
+ val inputA = (0 until (numBatches - 1)).map { i =>
+ LogisticRegressionSuite.generateLogisticInput(0.0, 0.5, nPoints, 42
* (i + 1))
+ }
+ // the last RDD is generated under the model B
+ val inputB =
+ LogisticRegressionSuite.generateLogisticInput(0.0, 1.5, nPoints, 42
* (numBatches + 1))
+ val input = inputA :+ inputB
+
+ // apply model training to input stream
+ ssc = setupStreams(input, (inputDStream: DStream[LabeledPoint]) => {
+ model.trainOn(inputDStream)
+ inputDStream.count()
+ })
+ runStreams(ssc, numBatches, numBatches)
+
+ // with full memory, the final parameter estimates should be close to
model A
+ assert(model.latestModel().weights(0) ~== 0.5 relTol 0.5)
--- End diff --
A 50% tolerance is quite large, can the tests still regularly pass with a
smaller tolerance?
---
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]