Skip to content

FIX LogisticRegressionCV with explicit scorer and missing classes in CV folds - #32828

Merged
OmarManzoor merged 10 commits into
scikit-learn:mainfrom
lorentzenchr:fix_scoring_labels_logisticregressioncv
Feb 21, 2026
Merged

OmarManzoor merged 10 commits into
scikit-learn:mainfrom
lorentzenchr:fix_scoring_labels_logisticregressioncv

Conversation

@lorentzenchr

Copy link
Copy Markdown
Member

Reference Issues/PRs

Fixes #15389, follow-up of #32747.

What does this implement/fix? Explain your changes.

This PR enables LogisticRegressionCV to correctly work when the CV folds do not contain all classes and the scoring argument is explicitly passed.

Any other comments?

I don't like my own solution (too much code), but it seems to work.

@github-actions

github-actions Bot commented Dec 1, 2025 •

Copy link
Copy Markdown

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: 7b6637e. Link to the linter CI: here

@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. This generally looks good.
I added one suggestion to refactor the code. It might make the single elif condition more complex but it compresses basically the same code in both cases that differs only by pos_label

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

Copy link
Copy Markdown
Contributor

CC: @adrinjalali for a second review

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

The solution seems quite hackey. I'm wondering if something like #33209 would be easier?

Comment thread sklearn/linear_model/_logistic.py Resolved
Comment thread sklearn/linear_model/_logistic.py Resolved
@lorentzenchr
lorentzenchr force-pushed the fix_scoring_labels_logisticregressioncv branch from d45bdd5 to 96ebc84 Compare February 20, 2026 06:37
@lorentzenchr

Copy link
Copy Markdown
Member Author

@OmarManzoor Are you still on board with this simplified version?
As it is a (simple) FIX, we can merge with one approval.

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

Yes LGTM 👍. Lets merge

Comment thread sklearn/linear_model/_logistic.py Resolved
@OmarManzoor
OmarManzoor enabled auto-merge (squash) February 21, 2026 11:36
@OmarManzoor
OmarManzoor merged commit 9292c21 into scikit-learn:main Feb 21, 2026
30 checks passed
@lorentzenchr
lorentzenchr deleted the fix_scoring_labels_logisticregressioncv branch February 21, 2026 13:20
tonybaloney pushed a commit to tonybaloney/swe-complex-scikit-learn that referenced this pull request Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

3 participants