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

Skip to content

DOC Clarify primal and dual formulations in Ridge solvers - #34899

Open
jasperjonkhans wants to merge 1 commit into
scikit-learn:mainfrom
jasperjonkhans:issue-34807
Open

DOC Clarify primal and dual formulations in Ridge solvers#34899
jasperjonkhans wants to merge 1 commit into
scikit-learn:mainfrom
jasperjonkhans:issue-34807

Conversation

@jasperjonkhans

Copy link
Copy Markdown

Reference Issues/PRs

Fixes #34807.

What does this implement/fix? Explain your changes.

Document primal/dual selection for cholesky and sparse_cg across the Ridge APIs. Explain the equations and Cholesky memory costs in the user guide, distinguishing matrix-free sparse_cg. No runtime changes.

Introduce yourself

I am a student in CS and Math. I regularly use scikit-learn for my side projects and partime job. I enjoy the community and want to contribute a bit.

AI usage disclosure

I used AI assistance for:

  • grammar and spelling
  • research on the methods and doc writing best practices

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown

Thank you for opening your first pull request to scikit-learn! πŸŽ‰

To help get your contribution reviewed, please make sure that:

  • You have filled out the pull request template.

  • The pull request addresses an existing issue that is ready for contribution (e.g. not tagged as 'Needs Triage', 'Needs Decision', ...). If you are proposing a new feature, please open an issue to discuss it first.

  • There are no other open pull requests already targeting the same issue.

  • You have followed the pull request checklist. In particular, linting and tests should pass.

@itz-puneet

itz-puneet commented Sep 7, 2026

Copy link
Copy Markdown

Closing my duplicate (#34893) in favour of this one β€” you had the assignment, and the user-guide half here is the more complete fix. Two things from my version that might be worth folding in:

1. Writing the dual system out explicitly in the docstrings. The RidgeCV Notes section in the same file already uses this notation (w = H^-1 X' y = X' c where c = G^-1 y), so c stays consistent with what's there:

... solves (X X' + alpha*I) c = y for the dual coefficients c, and obtains coef_ from X' c

2. The coefficient orientation. X' c comes out as (n_features, n_targets), while coef_ is (n_targets, n_features) β€” hence the trailing .T at _ridge.py:763. Worth stating, since a reader following the math otherwise lands on the transposed shape. Checked on a dual-branch fit with n_samples=50, n_features=200, n_targets=3: c is (50, 3), X' c is (200, 3), and coef_ is (3, 200).

Both are docstring-only, so take or leave them as you prefer.

(Edited to fix transposed shape figures in point 2.)

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.

Dual problem formulation approach is not mentioned in Ridge solvers

2 participants