Repository navigation
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 |
OmarManzoor
left a comment
There was a problem hiding this comment.
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.