Skip to content

FIX BayesianRidge and ARDRegression predict to center X before computing std - #33918

Merged
OmarManzoor merged 4 commits into
scikit-learn:mainfrom
danilo-silva-ufsc:fix/bayesian-ridge-variance
May 4, 2026
Merged

OmarManzoor merged 4 commits into
scikit-learn:mainfrom
danilo-silva-ufsc:fix/bayesian-ridge-variance

Conversation

@danilo-silva-ufsc

Copy link
Copy Markdown
Contributor

Reference Issues/PRs

Fixes #33757

What does this implement/fix? Explain your changes.

When BayesianRidge and ARDRegression are fit with fit_intercept=True (default), features are centered by subtracting the mean. However, predict(return_std=True) was using the raw (uncentered) test features for variance computation, causing the model to report lowest uncertainty at the origin instead of near the training data.

The fix simply subtracts self.X_offset_ from X before the variance calculation, matching what happens during training.

Any other comments?

Originally the bug report was just for BayesianRidge, but when writing the non-regression test I noticed that it also applied to ARDRegression.

@ogrisel ogrisel left a comment

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.

LGTM, thanks very much for the fix!

@ogrisel ogrisel added Quick Review For PRs that are quick to review Waiting for Second Reviewer First reviewer is done, need a second one! labels May 4, 2026

@OmarManzoor OmarManzoor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Thank you for the PR @danilo-silva-ufsc

@OmarManzoor OmarManzoor removed the Waiting for Second Reviewer First reviewer is done, need a second one! label May 4, 2026
@OmarManzoor
OmarManzoor enabled auto-merge (squash) May 4, 2026 11:41
@OmarManzoor
OmarManzoor merged commit 15e9684 into scikit-learn:main May 4, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module:linear_model Quick Review For PRs that are quick to review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] BayesianRidge.predict with return_std=True fails to center test features, leading to incorrect predictive variance

3 participants