Skip to content

ENH add solver option auto to LogisticRegression and other GLMs - #35110

Merged
virchan merged 11 commits into
scikit-learn:mainfrom
lorentzenchr:solver_auto
Oct 20, 2026
Merged

virchan merged 11 commits into
scikit-learn:mainfrom
lorentzenchr:solver_auto

Conversation

@lorentzenchr

@lorentzenchr lorentzenchr commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Reference Issues/PRs

Fixes #33401.

What does this implement/fix? Explain your changes.

This PR add the option solver="auto" and the attribute solver_ to

  • LogisticRegression
  • LogisticRegressionCV
  • GammaRegressor
  • PoissonRegressor
  • TweedieRegressor

The idea is to have a solver that just works out-of-the-box. Option "auto" explicitly states that it may change the selected solver without deprecation. This PR still selects lbfgs for L2-problems, so no change here.

AI usage disclosure

None yet.

Any other comments?

This PR adds a test for tags of LR.

@lorentzenchr

Copy link
Copy Markdown
Member Author

@OmarManzoor @virchan @antoinebaker @ogrisel This PR would make the 1.10 release for linear models a good "package" as this PR is a small extension with real user impact: You don't need to change the default solver, it will always work not matter which penalty (l1_ratio) you've chosen.

@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. I think adding an auto option seems nice.

Comment thread sklearn/linear_model/_glm/glm.py Resolved
Comment thread sklearn/linear_model/_glm/glm.py Resolved
Comment thread sklearn/linear_model/_glm/glm.py Resolved
Comment thread sklearn/linear_model/_glm/glm.py Resolved
Comment thread sklearn/linear_model/_logistic.py Resolved
Comment thread sklearn/linear_model/_logistic.py Resolved
Comment thread sklearn/linear_model/_logistic.py Resolved

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

@OmarManzoor OmarManzoor added the Waiting for Second Reviewer First reviewer is done, need a second one! label Oct 16, 2026

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

Fixing the bullets list in the doc-strings.

Comment thread sklearn/linear_model/_glm/glm.py Resolved
Comment thread sklearn/linear_model/_logistic.py Resolved
Comment thread sklearn/linear_model/_logistic.py Resolved

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

Overall, LGTM. I made a few commits to your branch to improve how the description of auto renders in the documentation (LogisticRegressionCV before vs. after).

If it's not too much trouble, could you please also update the docstrings for Poisson, Tweedie, and Gamma? I'm happy to merge once that's done.

@github-actions

Copy link
Copy Markdown

This PR exceeds the recommended size of 500 lines changed. Consider splitting it into smaller PRs to ease the review process. Please make sure you read our Contributing guide and in particular our Pull Request guidelines

@lorentzenchr

Copy link
Copy Markdown
Member Author

FYI: I thought about using n_features * n_classes for logistic regression. But then we need n_classes before X, y validation ... and I ended up with the motto: Let's start simple.

@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! Thank you everyone for your time!

Merging.

@virchan
virchan merged commit 1065739 into scikit-learn:main Oct 20, 2026
37 of 38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module:linear_model size/XL Waiting for Second Reviewer First reviewer is done, need a second one!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add "auto" option as default solver to GLMs Introduce a solver="auto" for LogisticRegression

3 participants