-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-21818][ML][MLLIB] Fix bug of MultivariateOnlineSummarizer.variance generate negative result #19029
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-21818][ML][MLLIB] Fix bug of MultivariateOnlineSummarizer.variance generate negative result #19029
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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)) | ||
|
||
|
|
||
| /** | ||
| * Weighted mean of (label * features). | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not so against this, but this is really an implementation detail and not relevant to the caller. It's a value that is by definition nonnegative.