Skip to content

Commit 32176be

Browse files
authored
fix: RandomForestEstimator honors random_seed config (#1547)
1 parent 4dc2de8 commit 32176be

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

flaml/automl/model.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1970,8 +1970,6 @@ def config2params(self, config: dict) -> dict:
19701970
params["max_leaf_nodes"] = params.get("max_leaf_nodes", params.pop("max_leaves"))
19711971
if not self._task.is_classification() and "criterion" in params:
19721972
params.pop("criterion")
1973-
if "random_state" not in params:
1974-
params["random_state"] = 12032022
19751973
return params
19761974

19771975
def __init__(
@@ -1981,6 +1979,9 @@ def __init__(
19811979
):
19821980
super().__init__(task, **params)
19831981
self.params["verbose"] = 0
1982+
random_seed = self.params.pop("random_seed", params.get("random_seed", 12032022))
1983+
if "random_state" not in self.params:
1984+
self.params["random_state"] = random_seed
19841985

19851986
if self._task.is_classification():
19861987
self.estimator_class = RandomForestClassifier

0 commit comments

Comments
 (0)