From 0ea382b3f4ffb7afff1a24b89abaac58f8675d0e Mon Sep 17 00:00:00 2001 From: Mariam Zakaria <123750992+mariam851@users.noreply.github.com> Date: Sat, 20 Dec 2025 04:11:15 +0200 Subject: [PATCH 1/5] feat: remove comments --- mlxtend/feature_selection/sequential_feature_selector.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mlxtend/feature_selection/sequential_feature_selector.py b/mlxtend/feature_selection/sequential_feature_selector.py index 835d7a3f9..fe5e7d121 100644 --- a/mlxtend/feature_selection/sequential_feature_selector.py +++ b/mlxtend/feature_selection/sequential_feature_selector.py @@ -197,12 +197,14 @@ def __init__( clone_estimator=True, fixed_features=None, feature_groups=None, + tol = None ): self.estimator = estimator self.k_features = k_features self.forward = forward self.floating = floating self.pre_dispatch = pre_dispatch + self.tol=tol # Want to raise meaningful error message if a # cross-validation generator is inputted if isinstance(cv, types.GeneratorType): @@ -569,6 +571,13 @@ def fit(self, X, y, groups=None, **fit_params): "avg_score": k_score, } + if self.tol is not None and k > 1: + prev_k = k - 1 if self.forward else k + 1 + if prev_k in self.subsets_: + diff = k_score - self.subsets_[prev_k]["avg_score"] + if diff < self.tol: + k_stop = k + if self.floating: # floating direction is opposite of self.forward, i.e. in # forward selection, we do floating in backward manner, From 7ca31171fe9367d6ed1e288cba74e6d3568a76e9 Mon Sep 17 00:00:00 2001 From: Sebastian Raschka Date: Sat, 20 Dec 2025 10:38:59 -0600 Subject: [PATCH 2/5] Apply suggestion from @rasbt --- mlxtend/feature_selection/sequential_feature_selector.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mlxtend/feature_selection/sequential_feature_selector.py b/mlxtend/feature_selection/sequential_feature_selector.py index fe5e7d121..3f5e10de8 100644 --- a/mlxtend/feature_selection/sequential_feature_selector.py +++ b/mlxtend/feature_selection/sequential_feature_selector.py @@ -204,7 +204,7 @@ def __init__( self.forward = forward self.floating = floating self.pre_dispatch = pre_dispatch - self.tol=tol + self.tol = tol # Want to raise meaningful error message if a # cross-validation generator is inputted if isinstance(cv, types.GeneratorType): From 6494c062ef006028dd1c90fd8ee8018ac06af598 Mon Sep 17 00:00:00 2001 From: Sebastian Raschka Date: Sat, 20 Dec 2025 10:42:08 -0600 Subject: [PATCH 3/5] Apply suggestion from @rasbt --- mlxtend/feature_selection/sequential_feature_selector.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mlxtend/feature_selection/sequential_feature_selector.py b/mlxtend/feature_selection/sequential_feature_selector.py index 3f5e10de8..04c019676 100644 --- a/mlxtend/feature_selection/sequential_feature_selector.py +++ b/mlxtend/feature_selection/sequential_feature_selector.py @@ -197,7 +197,7 @@ def __init__( clone_estimator=True, fixed_features=None, feature_groups=None, - tol = None + tol=None ): self.estimator = estimator self.k_features = k_features From 9bb140cfc71b7477346ae10af182e20ee3c9dfae Mon Sep 17 00:00:00 2001 From: Sebastian Raschka Date: Sat, 20 Dec 2025 10:44:57 -0600 Subject: [PATCH 4/5] Apply suggestion from @rasbt --- mlxtend/feature_selection/sequential_feature_selector.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mlxtend/feature_selection/sequential_feature_selector.py b/mlxtend/feature_selection/sequential_feature_selector.py index 04c019676..47937281a 100644 --- a/mlxtend/feature_selection/sequential_feature_selector.py +++ b/mlxtend/feature_selection/sequential_feature_selector.py @@ -197,7 +197,7 @@ def __init__( clone_estimator=True, fixed_features=None, feature_groups=None, - tol=None + tol=None, ): self.estimator = estimator self.k_features = k_features From a8d88c14d29eb62340a16ee4591d39f102761169 Mon Sep 17 00:00:00 2001 From: Sebastian Raschka Date: Sat, 20 Dec 2025 10:48:17 -0600 Subject: [PATCH 5/5] Apply suggestion from @rasbt --- mlxtend/feature_selection/sequential_feature_selector.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mlxtend/feature_selection/sequential_feature_selector.py b/mlxtend/feature_selection/sequential_feature_selector.py index 47937281a..80e08f343 100644 --- a/mlxtend/feature_selection/sequential_feature_selector.py +++ b/mlxtend/feature_selection/sequential_feature_selector.py @@ -204,7 +204,7 @@ def __init__( self.forward = forward self.floating = floating self.pre_dispatch = pre_dispatch - self.tol = tol + self.tol = tol # Want to raise meaningful error message if a # cross-validation generator is inputted if isinstance(cv, types.GeneratorType):