Skip to content

fix: LRL1/LRL2 — migrate off sklearn 1.10 deprecations (penalty, n_jobs)#1556

Open
immu4989 wants to merge 1 commit into
microsoft:mainfrom
immu4989:flaml-fix-lrl-sklearn-1.10-deprecations
Open

fix: LRL1/LRL2 — migrate off sklearn 1.10 deprecations (penalty, n_jobs)#1556
immu4989 wants to merge 1 commit into
microsoft:mainfrom
immu4989:flaml-fix-lrl-sklearn-1.10-deprecations

Conversation

@immu4989
Copy link
Copy Markdown
Contributor

Why are these changes needed?

LRL1Classifier and LRL2Classifier configure sklearn's LogisticRegression with two arguments that were deprecated in scikit-learn 1.8 and scheduled for removal in scikit-learn 1.10:

  • penalty= (use l1_ratio or C instead — l1_ratio=1 for L1, l1_ratio=0 for L2)
  • n_jobs= (has no effect since 1.8 — SGDEstimator.config2params already pops this for the regression case)

Each lrl1 / lrl2 fit on sklearn ≥ 1.8 currently emits a FutureWarning for penalty, a UserWarning for penalty=l1 with l1_ratio=0.0, and a FutureWarning for n_jobs. Once scikit-learn 1.10 ships, these become TypeErrors and the two estimators hard-break.

This PR version-gates the configuration in config2params using the existing SKLEARN_VERSION constant in flaml/automl/model.py (already in use for the SGD loss migration at lines 2383 and 2437):

  • LRL1Classifier: on sklearn ≥ 1.8, set l1_ratio=1.0 and drop n_jobs; on older sklearn, keep penalty="l1".
  • LRL2Classifier: on sklearn ≥ 1.8, just drop n_jobs (the default LogisticRegression penalty is already "l2"); on older sklearn, keep penalty="l2".

Verified locally on sklearn 1.8.0: both migrations produce identical coef_ to the legacy configuration, the existing lrl1 / lrl2 reproducibility tests continue to pass, and no FutureWarning / UserWarning about penalty or n_jobs is emitted during fit.

Related issue number

Closes #1555

Checks

@thinkall
Copy link
Copy Markdown
Collaborator

The ci errors are caused by openml dataset downloading. Re-running.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: LRL1Classifier and LRL2Classifier hit sklearn 1.8 FutureWarnings (penalty, n_jobs) — will hard-break at sklearn 1.10

2 participants