From 0f9420590dae5358e86710df2eb9774ee9d34108 Mon Sep 17 00:00:00 2001 From: murunlin Date: Thu, 15 May 2025 09:37:34 +0800 Subject: [PATCH] fix: best_model_for_estimator returns inconsistent feature_importances_ compared to automl.model (#1429) * mrl-issue1422-0513 * fix version dependency * fix datasets version * test completion --------- Co-authored-by: Runlin Mu (FESCO Adecco Human Resources) Co-authored-by: Li Jiang --- flaml/automl/automl.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/flaml/automl/automl.py b/flaml/automl/automl.py index fcdef2d62..3233a1cff 100644 --- a/flaml/automl/automl.py +++ b/flaml/automl/automl.py @@ -424,6 +424,8 @@ class AutoML(BaseEstimator): If `model_history` was set to True, then the returned model is trained. """ state = self._search_states.get(estimator_name) + if state and estimator_name == self._best_estimator: + return self.model return state and getattr(state, "trained_estimator", None) @property