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

Skip to content

MNT clean up class_weight in LogisticRegression - #34499

Merged
OmarManzoor merged 5 commits into
scikit-learn:mainfrom
lorentzenchr:logreg_refactor_y
Jul 17, 2026
Merged

MNT clean up class_weight in LogisticRegression#34499
OmarManzoor merged 5 commits into
scikit-learn:mainfrom
lorentzenchr:logreg_refactor_y

Conversation

@lorentzenchr

Copy link
Copy Markdown
Member

Reference Issues/PRs

Makes #33906 a bit easier.

What does this implement/fix? Explain your changes.

This PR cleans up the logic of class_weight in LogisticRegression and similar functions.

AI usage disclosure

None

Any other comments?

@lorentzenchr

Copy link
Copy Markdown
Member Author

@OmarManzoor ping

@OmarManzoor

Copy link
Copy Markdown
Contributor

Oh that was quick 😆

@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/tests/test_logistic.py Outdated
Comment thread sklearn/linear_model/tests/test_logistic.py Outdated
Comment thread sklearn/linear_model/_logistic.py
Comment thread sklearn/linear_model/_logistic.py
Comment thread sklearn/linear_model/_logistic.py
Comment on lines 558 to 571
lbfgs_bridge = _LbfgsCallbackBridge(
callback_ctx,
estimator,
X,
y,
callback_metadata,
w0,
n_classes=n_classes,
is_binary=is_binary,
fit_intercept=fit_intercept,
coefs_order=coefs_order,
xp=xp,
device_=device_,
)

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.

The only concern is that this was originally using the original y not the encoded one. So will this still work as expected when we pass transformed values now?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

don't know. I rely on the tests. In my understanding, the object that LBFGS sees should be passed.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@jeremiedbb You expertise would help here.

Comment thread sklearn/linear_model/_logistic.py Outdated
Comment thread sklearn/linear_model/_logistic.py
Comment thread sklearn/linear_model/_logistic.py
Comment thread sklearn/linear_model/_logistic.py
Comment on lines 558 to 571
lbfgs_bridge = _LbfgsCallbackBridge(
callback_ctx,
estimator,
X,
y,
callback_metadata,
w0,
n_classes=n_classes,
is_binary=is_binary,
fit_intercept=fit_intercept,
coefs_order=coefs_order,
xp=xp,
device_=device_,
)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

don't know. I rely on the tests. In my understanding, the object that LBFGS sees should be passed.

Comment thread sklearn/linear_model/_logistic.py Outdated
@OmarManzoor

Copy link
Copy Markdown
Contributor

@lorentzenchr I think this generally looks good other than the one clarification related to _LbfgsCallbackBridge. Could you check the CodeCov errors though to see if they can be addressed?

@lorentzenchr

Copy link
Copy Markdown
Member Author

clarification related to _LbfgsCallbackBridge

I think this is fine and we can merge. No test complains. If it is a bug, we can fix it once detected.

@OmarManzoor

Copy link
Copy Markdown
Contributor

Okay enabling auto-merge!

@OmarManzoor
OmarManzoor enabled auto-merge (squash) July 17, 2026 12:51

@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 merged commit 28ba5c0 into scikit-learn:main Jul 17, 2026
38 checks passed
@lorentzenchr
lorentzenchr deleted the logreg_refactor_y branch July 17, 2026 13:33
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.

2 participants