Skip to content

FIX Sample weight in BayesianRidge#30644

Merged
OmarManzoor merged 11 commits intoscikit-learn:mainfrom
antoinebaker:bayesian_ridge_sample_weight
Jan 17, 2025
Merged

FIX Sample weight in BayesianRidge#30644
OmarManzoor merged 11 commits intoscikit-learn:mainfrom
antoinebaker:bayesian_ridge_sample_weight

Conversation

@antoinebaker
Copy link
Copy Markdown
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.

@github-actions
Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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:

)

rmse_ = np.sum((y - np.dot(X, coef_)) ** 2)
mse_ = np.sum((y - np.dot(X, coef_)) ** 2)
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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!

antoinebaker and others added 2 commits January 16, 2025 17:38
Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org>
Copy link
Copy Markdown
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
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