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

Skip to content

ENH Newton-CD part 5: add NewtonCDGramSolver for L1-penalized GLMs - #34377

Merged
OmarManzoor merged 8 commits into
scikit-learn:mainfrom
lorentzenchr:logistic_lasso_newton_part_5
Jul 20, 2026
Merged

ENH Newton-CD part 5: add NewtonCDGramSolver for L1-penalized GLMs#34377
OmarManzoor merged 8 commits into
scikit-learn:mainfrom
lorentzenchr:logistic_lasso_newton_part_5

Conversation

@lorentzenchr

@lorentzenchr lorentzenchr commented Jun 23, 2026

Copy link
Copy Markdown
Member

Reference Issues/PRs

Part 5 of #33160.

What does this implement/fix? Explain your changes.

This PR implements the new GLM-solver class NewtonCDGramSolver. It uses our coordinate-descent function enet_coordinate_descent_gram under the hood as inner solver.

In this PR, the solver="newton-cd-gram" is publicly exposed in LogisticRegression and LogisticRegressionCV, but not yet (only privately) in PoissonRegressor, GammaRegressor, TweedieRegressor. The reason is that for the latter, a new parameter l1_ratio needs to be introduced. Not doing so keeps this PR a bit smaller.

The tests are quite rigorous in my opinion and they pass.

The mechanics of a Newton Solver:

  • Outer loop
    • Compute gradients g and hessians H
    • Inner loop:
      Compute a Newton step H @ step = -g
      This solver uses coordinate descent.
    • Line search (guarantee global convergence)
    • Check for convergenge
  • End outer loop

AI usage disclosure

None

Any other comments?

This solver is good for n_features << n_samples.

@lorentzenchr
lorentzenchr force-pushed the logistic_lasso_newton_part_5 branch 2 times, most recently from 960dddf to a2d10ec Compare June 27, 2026 14:22
@lorentzenchr
lorentzenchr force-pushed the logistic_lasso_newton_part_5 branch 2 times, most recently from 39c75ac to 018cad9 Compare June 27, 2026 19:48
@lorentzenchr
lorentzenchr force-pushed the logistic_lasso_newton_part_5 branch from 018cad9 to a7d0150 Compare July 7, 2026 15:59
@lorentzenchr

Copy link
Copy Markdown
Member Author

@OmarManzoor @virchan in the past, we 3 were quite a successful team. I hope this continues a little further.

@OmarManzoor

Copy link
Copy Markdown
Contributor

The PR looks amazing but because of the higher proportion of mathematics involved in the new solver it is a bit complicated to review.

@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.

Thank you for the PR @lorentzenchr

Comment thread sklearn/linear_model/_glm/_newton_solver.py
Comment thread sklearn/linear_model/_glm/_newton_solver.py Outdated
Comment thread sklearn/linear_model/_glm/_newton_solver.py Outdated
Comment thread sklearn/linear_model/_glm/_newton_solver.py Outdated
Comment thread sklearn/linear_model/_glm/_newton_solver.py Outdated
Comment thread sklearn/linear_model/_glm/_newton_solver.py
Comment thread sklearn/linear_model/_glm/_newton_solver.py Outdated
Comment thread sklearn/linear_model/_glm/glm.py Outdated
Comment thread sklearn/linear_model/_linear_loss.py Outdated
Comment thread sklearn/linear_model/_linear_loss.py Outdated
Comment thread sklearn/linear_model/_linear_loss.py Outdated

@virchan virchan 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.

Thank you for the PR, @lorentzenchr.

This is indeed a large one, so I'll need some time to go through it.

Comment thread sklearn/linear_model/_glm/tests/test_newton_solver.py Outdated
@lorentzenchr

Copy link
Copy Markdown
Member Author

@OmarManzoor @virchan Take your time, no need to rush. I am so happy to have you both on board.

@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.

Some further minor suggestions

Comment thread sklearn/linear_model/_glm/glm.py Outdated
Comment thread sklearn/linear_model/_linear_loss.py
Comment thread sklearn/linear_model/_logistic.py Outdated
Comment thread sklearn/linear_model/_logistic.py Outdated
Comment thread sklearn/linear_model/_logistic.py Outdated
Comment thread sklearn/linear_model/_logistic.py Outdated
Comment thread sklearn/linear_model/_logistic.py Outdated
Comment thread sklearn/linear_model/_logistic.py Outdated
Comment thread sklearn/linear_model/_logistic.py Outdated
Comment thread sklearn/linear_model/_glm/tests/test_glm.py

@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.

A few more comments related to comments/docstrings otherwise this looks good now.

Comment thread sklearn/linear_model/_glm/_newton_solver.py Outdated
Comment thread sklearn/linear_model/_glm/_newton_solver.py Outdated
Comment thread sklearn/linear_model/_glm/_newton_solver.py Outdated
Comment thread sklearn/linear_model/_glm/_newton_solver.py Outdated
Comment thread sklearn/linear_model/_glm/_newton_solver.py Outdated

@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 this amazing PR @lorentzenchr

Comment thread sklearn/linear_model/_glm/_newton_solver.py Outdated

@virchan virchan 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! Let's merge this!

Thanks, everyone, for your time!

@virchan

virchan commented Jul 20, 2026

Copy link
Copy Markdown
Member

Oops, I just noticed that there is a merge conflict to resolve. Once that is fixed, this should be ready to merge!

@lorentzenchr

Copy link
Copy Markdown
Member Author

Merge conflict resolved and CI 🟢

@OmarManzoor
OmarManzoor merged commit 0ea563f into scikit-learn:main Jul 20, 2026
38 checks passed
@lorentzenchr
lorentzenchr deleted the logistic_lasso_newton_part_5 branch July 20, 2026 09:37
prady0t pushed a commit to prady0t/scikit-learn that referenced this pull request Sep 2, 2026
@jeremiedbb jeremiedbb mentioned this pull request Sep 8, 2026
14 tasks
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