-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
FIX Sample weight in BayesianRidge #30644
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
FIX Sample weight in BayesianRidge #30644
Conversation
Thanks for the PR. It is marked draft, but I have the feeling it's ready for review. Is there anything left to do before reviewing? |
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.
Quick comment from a first glance at the diff:
sklearn/linear_model/_bayes.py
Outdated
@@ -394,12 +412,12 @@ def _update_coef_( | |||
[X.T, U / (eigen_vals_ + lambda_ / alpha_)[None, :], U.T, y] | |||
) | |||
|
|||
rmse_ = np.sum((y - np.dot(X, coef_)) ** 2) | |||
mse_ = np.sum((y - np.dot(X, coef_)) ** 2) |
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.
Don't we need to compute the weighted mse here as well?
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.
It's computing the weighted mse because the X
and y
are scaled by sample_weight
in _rescale_data
I think it's now ready for review. |
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.
A few more suggestions but otherwise LGTM!
Co-authored-by: Olivier Grisel <[email protected]>
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.
LGTM. Thanks @antoinebaker
Reference Issues/PRs
Part of meta issue #16298
What does this implement/fix? Explain your changes.
Some of the code in
BayesianRidge
did not handlesample_weight
properly, in particular the initialization and update for thealpha_
hyperparameter. NowBayesianRidge
passes thecheck_sample_weight_equivalence
test.Any other comments?
Renaming
rmse -> sse
as it is actually the sum of squared errors.