fix: SGD results now reproducible#1541
Merged
Merged
Conversation
Contributor
Author
|
@microsoft-github-policy-service agree |
There was a problem hiding this comment.
Pull request overview
This PR aims to make FLAML's SGDEstimator reproducible, aligning it with recent reproducibility fixes for other estimators in flaml/automl. It updates the SGD wrapper to seed the underlying sklearn model and extends the existing reproducibility test suites to cover SGD behavior.
Changes:
- Seed
SGDEstimatorwith a defaultrandom_statesoSGDClassifierandSGDRegressortrain deterministically. - Add
"sgd"to the wrapper-level reproducibility tests for classification and regression. - Document why SGD is still excluded from the underlying-model parity tests due to its extra
Normalizerpreprocessing layer.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
flaml/automl/model.py |
Adds deterministic seeding to SGDEstimator initialization. |
test/automl/test_classification.py |
Extends classification reproducibility coverage to SGD and documents the underlying-model test omission. |
test/automl/test_regression.py |
Extends regression reproducibility coverage to SGD and documents the underlying-model test omission. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
thinkall
requested changes
May 8, 2026
Contributor
Author
|
Thanks for the review! All comments addressed and resolved. Ready to merge whenever convenient |
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_stateonSGDEstimatorsoSGDClassifier/SGDRegressorproduce deterministic results (usesconfig.get("random_seed", 10242048), matching the LinearSVC and ElasticNet fixes)."sgd"totest_reproducibility_of_classification_modelsandtest_reproducibility_of_regression_models."sgd"to the*_underlying_*variants:SGDEstimatorwraps the sklearn model with aNormalizerpreprocessing step that the test helper does not replicate, so a bare-sklearn refit cannot match the wrapper's CV result. A short comment in each list documents this.Related issue number
Follows: #1369 (LGBM), #1374 (ElasticNet), #1376 (LinearSVC), #1364 (CatBoost).
Test plan
pytest test/automl/test_classification.py -k "reproducibility and sgd"— passespytest test/automl/test_regression.py -k "reproducibility and sgd"— passesChecks