Github user feynmanliang commented on a diff in the pull request:
https://github.com/apache/spark/pull/8022#discussion_r37824112
--- Diff:
mllib/src/main/scala/org/apache/spark/mllib/regression/StreamingLinearAlgorithm.scala
---
@@ -84,7 +87,20 @@ abstract class StreamingLinearAlgorithm[
}
data.foreachRDD { (rdd, time) =>
if (!rdd.isEmpty) {
- model = Some(algorithm.run(rdd, model.get.weights))
+ val newModel = algorithm.run(rdd, model.get.weights)
+
+ val numNewDataPoints = rdd.count()
+ val discount = getDiscount(numNewDataPoints)
+
+ val updatedDataWeight = previousDataWeight * discount +
numNewDataPoints
+ val lambda = numNewDataPoints / math.max(updatedDataWeight, 1e-16)
--- End diff --
Assuming `previousDataWeight >= 0` and `discount >= 0`, `updatedDataWeight
>= numNewDataPoints` so there's no need for protecting against div by zero here.
We should remove the check but keep a comment here in case readers of the
code worry about it
---
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]