-
-
Notifications
You must be signed in to change notification settings - Fork 26.1k
FIX LogisticRegression warm start with newton-cholesky solver #31866
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FIX LogisticRegression warm start with newton-cholesky solver #31866
Conversation
@david-cortes If you could review this one that would be great! |
This PR needs to be synced with |
Thanks for looking into it. Can confirm that the earlier problem with the intercepts is now solved. However it seems to be applying the warm-start logic in cases where it shouldn't - not sure if connected to the changes here though: import numpy as np
from sklearn.datasets import load_iris
from sklearn.linear_model import LogisticRegression
X, y = load_iris(return_X_y=True)
y_bin = (y == 0).astype(np.float64)
model1 = LogisticRegression(
solver="newton-cholesky",
max_iter=1
).fit(X, y_bin)
model2 = LogisticRegression(
solver="newton-cholesky",
max_iter=1,
warm_start=True
).fit(X, y).fit(X, y_bin)
# Coefficients are not equal
np.testing.assert_almost_equal(
model1.coef_,
model2.coef_
) |
@david-cortes The assert failure of your snippet goes away if you set |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thank you @lorentzenchr
@lorentzenchr Yes, but I don't think it should warm-start with coefficients that do not correspond to the same type of model being fitted. |
Reference Issues/PRs
Fixes ##31859.
What does this implement/fix? Explain your changes.
LogisticRegression(warm_start=True, solver="newton-cholesky")
for multi-class problems has a bug in that the already provided (warm started) coefficients are partially overwritten by zero instead of "unsymmetrized".Any other comments?
A corresponding test is added.