Skip to content

DOC: Note alpha_per_target incompatibility with cv in RidgeCV#33819

Merged
GaelVaroquaux merged 1 commit intoscikit-learn:mainfrom
shouhamdi:doc/ridgecv-alpha-per-target-cv-note
Apr 28, 2026
Merged

DOC: Note alpha_per_target incompatibility with cv in RidgeCV#33819
GaelVaroquaux merged 1 commit intoscikit-learn:mainfrom
shouhamdi:doc/ridgecv-alpha-per-target-cv-note

Conversation

@shouhamdi
Copy link
Copy Markdown
Contributor

@shouhamdi shouhamdi commented Apr 21, 2026

Summary

The alpha_per_target parameter of RidgeCV raises a ValueError when
used together with cv != None, but the docstring does not mention this
restriction. This PR adds the same one-line note already present on the
sibling parameter store_cv_results:

This flag is only compatible with cv=None (i.e. using
Leave-One-Out Cross-Validation).

Evidence

  • Runtime guard in _BaseRidgeCV.fit():
    if self.alpha_per_target:
        raise ValueError("cv!=None and alpha_per_target=True are incompatible")
  • Existing test in test_ridge.py (test_ridge_gcv_vs_ridge_loo_cv) confirms
    this ValueError is expected for both cv=LeaveOneOut() and cv=6.
  • The parallel parameter store_cv_results already documents an identical
    constraint — this PR brings alpha_per_target in line.

Change

Two lines added to the alpha_per_target docstring in RidgeCV
(sklearn/linear_model/_ridge.py). No code or test changes.

Made with @tomMoral and @kingjr

alpha_per_target=True raises ValueError when cv is not None,
but the docstring did not mention this. Add the same note
already used by store_cv_results.

Made-with: Cursor
Copy link
Copy Markdown
Contributor

@AnneBeyer AnneBeyer left a comment

Choose a reason for hiding this comment

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

Thank you @shouhamdi for spotting this. LGTM!

Copy link
Copy Markdown

@Abdeltoto Abdeltoto left a comment

Choose a reason for hiding this comment

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

Thanks, this looks correct to me. I checked that the added note matches the existing \ValueError\ path for \�lpha_per_target=True\ with \cv is not None, and it is consistent with the neighboring \store_cv_results\ documentation.

Copy link
Copy Markdown
Member

@GaelVaroquaux GaelVaroquaux 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 a lot @shouhamdi for the PR, and @AnneBeyer and @Abdeltoto for the reviews.

Merging, as such a DOC PR needs only one core-dev review

@GaelVaroquaux GaelVaroquaux merged commit edbf20b into scikit-learn:main Apr 28, 2026
40 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.

4 participants