Describe the bug
LRL1Classifier and LRL2Classifier configure sklearn's LogisticRegression with the legacy penalty argument (and inherit a default n_jobs from the base estimator config), both of which were deprecated in sklearn 1.8 and are scheduled for removal in sklearn 1.10. As a result, every lrl1/lrl2 run today emits three FutureWarning/UserWarning messages per fit, and once sklearn 1.10 ships these will become TypeErrors that hard-break the lrl1/lrl2 estimators.
Reproduced today with sklearn 1.8.0:
FutureWarning: 'penalty' was deprecated in version 1.8 and will be removed in 1.10.
Use l1_ratio=0 instead of penalty='l2', l1_ratio=1 instead of penalty='l1',
and C=np.inf instead of penalty=None.
UserWarning: Inconsistent values: penalty=l1 with l1_ratio=0.0. penalty is deprecated.
FutureWarning: 'n_jobs' has no effect since 1.8 and will be removed in 1.10.
Steps to reproduce
import warnings
warnings.simplefilter("default")
from sklearn.datasets import load_breast_cancer
from flaml import AutoML
X, y = load_breast_cancer(return_X_y=True, as_frame=True)
automl = AutoML()
automl.fit(
X_train=X, y_train=y,
estimator_list=["lrl1", "lrl2"],
task="classification",
eval_method="cv",
n_splits=3,
time_budget=-1,
max_iter=2,
)
Model Used
No response
Expected Behavior
No FutureWarning / UserWarning from sklearn's LogisticRegression. The lrl1 / lrl2 estimators should remain compatible with sklearn ≥ 1.10.
Screenshots and logs
Suggested fix
Version-gate the configuration in LRL1Classifier.config2params and LRL2Classifier.config2params in flaml/automl/model.py, using the existing SKLEARN_VERSION constant (already in use for the SGD loss migration at lines 2383 and 2437):
- LRL1: when SKLEARN_VERSION >= "1.8", set l1_ratio=1.0 and omit penalty; otherwise keep penalty="l1".
- LRL2: when SKLEARN_VERSION >= "1.8", omit penalty (the default is "l2"); otherwise keep penalty="l2".
- Both: when SKLEARN_VERSION >= "1.8", drop n_jobs (mirrors how SGDEstimator.config2params already pops n_jobs for the regression case).
I've verified locally on sklearn 1.8.0 that both migrations produce identical coefficients to the legacy configuration. Happy to take this on.
Additional Information
FLAML version: latest main (verified through a45f4f4, the merge commit of #1554)
scikit-learn: 1.8.0
Python: 3.12
Describe the bug
LRL1Classifier and LRL2Classifier configure sklearn's LogisticRegression with the legacy penalty argument (and inherit a default n_jobs from the base estimator config), both of which were deprecated in sklearn 1.8 and are scheduled for removal in sklearn 1.10. As a result, every lrl1/lrl2 run today emits three FutureWarning/UserWarning messages per fit, and once sklearn 1.10 ships these will become TypeErrors that hard-break the lrl1/lrl2 estimators.
Reproduced today with sklearn 1.8.0:
FutureWarning: 'penalty' was deprecated in version 1.8 and will be removed in 1.10.
Use l1_ratio=0 instead of penalty='l2', l1_ratio=1 instead of penalty='l1',
and C=np.inf instead of penalty=None.
UserWarning: Inconsistent values: penalty=l1 with l1_ratio=0.0. penalty is deprecated.
FutureWarning: 'n_jobs' has no effect since 1.8 and will be removed in 1.10.
Steps to reproduce
Model Used
No response
Expected Behavior
No FutureWarning / UserWarning from sklearn's LogisticRegression. The lrl1 / lrl2 estimators should remain compatible with sklearn ≥ 1.10.
Screenshots and logs
Suggested fix
Version-gate the configuration in LRL1Classifier.config2params and LRL2Classifier.config2params in flaml/automl/model.py, using the existing SKLEARN_VERSION constant (already in use for the SGD loss migration at lines 2383 and 2437):
I've verified locally on sklearn 1.8.0 that both migrations produce identical coefficients to the legacy configuration. Happy to take this on.
Additional Information
FLAML version: latest main (verified through a45f4f4, the merge commit of #1554)
scikit-learn: 1.8.0
Python: 3.12