From a316f84fe1d3cfa15a7e66c0955fb3ee4dc06840 Mon Sep 17 00:00:00 2001 From: Daniel Grindrod Date: Thu, 31 Oct 2024 06:02:16 +0000 Subject: [PATCH] fix: LinearSVC results now reproducible (#1376) Co-authored-by: Daniel Grindrod --- flaml/automl/model.py | 5 +++++ test/automl/test_classification.py | 2 ++ 2 files changed, 7 insertions(+) diff --git a/flaml/automl/model.py b/flaml/automl/model.py index 8e3b88e6a..29c907dfc 100644 --- a/flaml/automl/model.py +++ b/flaml/automl/model.py @@ -2185,6 +2185,11 @@ class SVCEstimator(SKLearnEstimator): def __init__(self, task="binary", **config): super().__init__(task, **config) + self.params.update( + { + "random_state": config.get("random_seed", 10242048), + } + ) assert self._task.is_classification(), "LinearSVC for classification task only" self.estimator_class = LinearSVC diff --git a/test/automl/test_classification.py b/test/automl/test_classification.py index 942b5cda3..d4ff03b97 100644 --- a/test/automl/test_classification.py +++ b/test/automl/test_classification.py @@ -435,6 +435,7 @@ class TestClassification(unittest.TestCase): # "lrl1", "lrl2", "rf", + "svc", "xgboost", "xgb_limitdepth", ], @@ -495,6 +496,7 @@ def test_reproducibility_of_classification_models(estimator: str): # "lgbm", # "lrl1", "lrl2", + "svc", "rf", "xgboost", "xgb_limitdepth",