Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged

Conversation

antoinebaker
Copy link
Contributor

@antoinebaker antoinebaker commented Jan 14, 2025

Reference Issues/PRs

Part of meta issue #16298

What does this implement/fix? Explain your changes.

Some of the code in BayesianRidge did not handle sample_weight properly, in particular the initialization and update for the alpha_ hyperparameter. Now BayesianRidge passes the check_sample_weight_equivalence test.

Any other comments?

Renaming rmse -> sse as it is actually the sum of squared errors.

Copy link

github-actions bot commented Jan 14, 2025

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: 28e6ddb. Link to the linter CI: here

@ogrisel
Copy link
Member

ogrisel commented Jan 15, 2025

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?

Copy link
Member

@ogrisel ogrisel left a 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:

@@ -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)
Copy link
Member

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?

Copy link
Contributor Author

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

@antoinebaker
Copy link
Contributor Author

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?

I think it's now ready for review.

@antoinebaker antoinebaker marked this pull request as ready for review January 16, 2025 08:51
Copy link
Member

@ogrisel ogrisel left a 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!

Copy link
Contributor

@OmarManzoor OmarManzoor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks @antoinebaker

@OmarManzoor OmarManzoor enabled auto-merge (squash) January 17, 2025 06:17
@OmarManzoor OmarManzoor merged commit 9a53acf into scikit-learn:main Jan 17, 2025
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants