Github user srowen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19029#discussion_r135385006
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/ml/optim/WeightedLeastSquares.scala ---
    @@ -439,8 +439,9 @@ private[ml] object WeightedLeastSquares {
     
         /**
          * Weighted population standard deviation of labels.
    +     * We prevent variance from negative value caused by numerical error.
          */
    -    def bStd: Double = math.sqrt(bbSum / wSum - bBar * bBar)
    +    def bStd: Double = math.sqrt(math.max(bbSum / wSum - bBar * bBar, 0.0))
    --- End diff --
    
    There are a couple more places where variance is computed in this file -- I 
think they need this too?


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to