fix: LRL1 results now reproducible#1546
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves determinism for FLAML’s lrl1 estimator by ensuring LRL1Classifier seeds scikit-learn’s stochastic LogisticRegression(solver="saga", penalty="l1"), and re-enables reproducibility coverage for lrl1 in the classification test suite.
Changes:
- Set
LRL1Classifier.params["random_state"]from FLAML’s internalrandom_seed(defaulting to10242048) when the caller hasn’t explicitly providedrandom_state. - Remove (
pop)random_seedfromLRL1Classifier.paramsto avoid passing an unsupported parameter into scikit-learn constructors. - Re-enable
lrl1in both classification reproducibility parametrized test lists.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
flaml/automl/model.py |
Seeds LRL1Classifier’s underlying LogisticRegression via random_state for deterministic saga behavior. |
test/automl/test_classification.py |
Re-enables lrl1 in reproducibility test parametrizations to prevent regressions. |
thinkall
approved these changes
May 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why are these changes needed?
Summary
random_stateonLRL1ClassifiersoLogisticRegression(solver="saga", penalty="l1")produces deterministic results across runs.random_seedkey fromself.params, and only setrandom_statewhen the caller has not already provided one."lrl1"in both classification reproducibility test parametrize lists (it was previously disabled).Why
LRL1Classifierdefaults tosolver="saga", a stochastic-gradient solver that shuffles samples each pass. Withoutrandom_state, identical fits produce different results — same root cause as SGD (#1541).LRL2Classifieris unaffected since it uses the deterministiclbfgssolver.Test plan
pytest test/automl/test_classification.py -k "reproducibility and lrl1"— both wrapper and underlying-model tests passpre-commit run --files flaml/automl/model.py test/automl/test_classification.py— all hooks passRelated issue number
Follows the same pattern as LGBM (#1369), CatBoost (#1364), ElasticNet (#1374), LinearSVC (#1376), and SGD (#1541).
Checks