From 4036e75bdfa2eba5a1bb1dc66bb43ddacb74ef17 Mon Sep 17 00:00:00 2001 From: Daniel Kleine <53251018+d-kleine@users.noreply.github.com> Date: Tue, 29 Oct 2024 03:29:53 +0100 Subject: [PATCH 1/7] finalize_fit() support for numpy >= 2.0 --- mlxtend/feature_selection/sequential_feature_selector.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mlxtend/feature_selection/sequential_feature_selector.py b/mlxtend/feature_selection/sequential_feature_selector.py index 0a766ed16..47909508f 100644 --- a/mlxtend/feature_selection/sequential_feature_selector.py +++ b/mlxtend/feature_selection/sequential_feature_selector.py @@ -651,7 +651,12 @@ def fit(self, X, y, groups=None, **fit_params): return self def finalize_fit(self): - max_score = np.NINF + if np.__version__ < '2.0': + ninf = np.NINF + else: + ninf = -np.inf + + max_score = ninf for k in self.subsets_: if ( k >= self.min_k @@ -662,7 +667,7 @@ def finalize_fit(self): best_subset = k k_score = max_score - if k_score == np.NINF: + if k_score == ninf: # i.e. all keys of self.subsets_ are not in interval `[self.min_k, self.max_k]` # this happens if KeyboardInterrupt happens keys = list(self.subsets_.keys()) From aeed2d8533419f7b1ecd284c0ec971a5724dd138 Mon Sep 17 00:00:00 2001 From: Daniel Kleine <53251018+d-kleine@users.noreply.github.com> Date: Wed, 30 Oct 2024 07:06:30 +0100 Subject: [PATCH 2/7] updated changelog --- docs/sources/CHANGELOG.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/sources/CHANGELOG.md b/docs/sources/CHANGELOG.md index efbf4fe61..498da8e94 100755 --- a/docs/sources/CHANGELOG.md +++ b/docs/sources/CHANGELOG.md @@ -24,8 +24,10 @@ Files updated: - ['mlxtend.frequent_patterns.fpgrowth'](https://rasbt.github.io/mlxtend/user_guide/frequent_patterns/fpgrowth/) - ['mlxtend.frequent_patterns.fpmax'](https://rasbt.github.io/mlxtend/user_guide/frequent_patterns/fpmax/) - [`mlxtend.frequent_patterns.association_rules`](https://rasbt.github.io/mlxtend/user_guide/frequent_patterns/association_rules/) -- [`mlxtend.frequent_patterns.association_rules`](https://rasbt.github.io/mlxtend/user_guide/frequent_patterns/association_rules/)Implemented three new metrics: Jaccard, Certainty, and Kulczynski. ([#1096](https://github.com/rasbt/mlxtend/issues/1096)) -- Integrated scikit-learn's `set_output` method into `TransactionEncoder` ([#1087](https://github.com/rasbt/mlxtend/issues/1087) via[it176131](https://github.com/it176131)) + - [`mlxtend.frequent_patterns.association_rules`](https://rasbt.github.io/mlxtend/user_guide/frequent_patterns/association_rules/) + - [`mlxtend.feature_selection.SequentialFeatureSelector`](https://github.com/rasbt/mlxtend/blob/master/mlxtend/feature_selection/sequential_feature_selector.py) + - Implemented three new metrics: Jaccard, Certainty, and Kulczynski. ([#1096](https://github.com/rasbt/mlxtend/issues/1096)) + - Integrated scikit-learn's `set_output` method into `TransactionEncoder` ([#1087](https://github.com/rasbt/mlxtend/issues/1087) via [it176131](https://github.com/it176131)) ##### Changes From 7cdb20df05732e8b419a7d250d584531bf65a115 Mon Sep 17 00:00:00 2001 From: Daniel Kleine <53251018+d-kleine@users.noreply.github.com> Date: Wed, 30 Oct 2024 07:10:05 +0100 Subject: [PATCH 3/7] flake8: removed blank line --- mlxtend/feature_selection/sequential_feature_selector.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mlxtend/feature_selection/sequential_feature_selector.py b/mlxtend/feature_selection/sequential_feature_selector.py index 47909508f..6bbcb2983 100644 --- a/mlxtend/feature_selection/sequential_feature_selector.py +++ b/mlxtend/feature_selection/sequential_feature_selector.py @@ -654,8 +654,7 @@ def finalize_fit(self): if np.__version__ < '2.0': ninf = np.NINF else: - ninf = -np.inf - + ninf = -np.inf max_score = ninf for k in self.subsets_: if ( From 50d634ffb287fd03f38f26d4527fe61e4693b1c6 Mon Sep 17 00:00:00 2001 From: Daniel Kleine <53251018+d-kleine@users.noreply.github.com> Date: Wed, 30 Oct 2024 07:10:59 +0100 Subject: [PATCH 4/7] flake8: removed trailing whitespaces --- 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 6bbcb2983..0fa46104a 100644 --- a/mlxtend/feature_selection/sequential_feature_selector.py +++ b/mlxtend/feature_selection/sequential_feature_selector.py @@ -654,7 +654,7 @@ def finalize_fit(self): if np.__version__ < '2.0': ninf = np.NINF else: - ninf = -np.inf + ninf = -np.inf max_score = ninf for k in self.subsets_: if ( From 99e0ecb0d457d8fcd0b3a2fb86402fa85eb9e422 Mon Sep 17 00:00:00 2001 From: Daniel Kleine <53251018+d-kleine@users.noreply.github.com> Date: Wed, 30 Oct 2024 07:19:13 +0100 Subject: [PATCH 5/7] fixed changelog indents --- docs/sources/CHANGELOG.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/sources/CHANGELOG.md b/docs/sources/CHANGELOG.md index 498da8e94..2d3382f6c 100755 --- a/docs/sources/CHANGELOG.md +++ b/docs/sources/CHANGELOG.md @@ -23,10 +23,9 @@ Files updated: - ['mlxtend.frequent_patterns.fpcommon'] - ['mlxtend.frequent_patterns.fpgrowth'](https://rasbt.github.io/mlxtend/user_guide/frequent_patterns/fpgrowth/) - ['mlxtend.frequent_patterns.fpmax'](https://rasbt.github.io/mlxtend/user_guide/frequent_patterns/fpmax/) - - [`mlxtend.frequent_patterns.association_rules`](https://rasbt.github.io/mlxtend/user_guide/frequent_patterns/association_rules/) - - [`mlxtend.frequent_patterns.association_rules`](https://rasbt.github.io/mlxtend/user_guide/frequent_patterns/association_rules/) - [`mlxtend.feature_selection.SequentialFeatureSelector`](https://github.com/rasbt/mlxtend/blob/master/mlxtend/feature_selection/sequential_feature_selector.py) - - Implemented three new metrics: Jaccard, Certainty, and Kulczynski. ([#1096](https://github.com/rasbt/mlxtend/issues/1096)) + - [`mlxtend.frequent_patterns.association_rules`](https://rasbt.github.io/mlxtend/user_guide/frequent_patterns/association_rules/) + - Implemented three new metrics: Jaccard, Certainty, and Kulczynski. ([#1096](https://github.com/rasbt/mlxtend/issues/1096)) - Integrated scikit-learn's `set_output` method into `TransactionEncoder` ([#1087](https://github.com/rasbt/mlxtend/issues/1087) via [it176131](https://github.com/it176131)) ##### Changes From a1a9fe7f1fade987c0999c443f409796a2c2bc9d Mon Sep 17 00:00:00 2001 From: Daniel Kleine <53251018+d-kleine@users.noreply.github.com> Date: Wed, 30 Oct 2024 20:38:32 +0100 Subject: [PATCH 6/7] fix for isort / black formatter --- 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 0fa46104a..590af7b81 100644 --- a/mlxtend/feature_selection/sequential_feature_selector.py +++ b/mlxtend/feature_selection/sequential_feature_selector.py @@ -651,7 +651,7 @@ def fit(self, X, y, groups=None, **fit_params): return self def finalize_fit(self): - if np.__version__ < '2.0': + if np.__version__ < "2.0": ninf = np.NINF else: ninf = -np.inf From dbcce14e9ac14ec6c0466797bd17d9147519da95 Mon Sep 17 00:00:00 2001 From: Daniel Kleine <53251018+d-kleine@users.noreply.github.com> Date: Thu, 31 Oct 2024 16:55:10 +0100 Subject: [PATCH 7/7] added change/feature description --- docs/sources/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/sources/CHANGELOG.md b/docs/sources/CHANGELOG.md index 2d3382f6c..3a0cca67c 100755 --- a/docs/sources/CHANGELOG.md +++ b/docs/sources/CHANGELOG.md @@ -24,6 +24,7 @@ Files updated: - ['mlxtend.frequent_patterns.fpgrowth'](https://rasbt.github.io/mlxtend/user_guide/frequent_patterns/fpgrowth/) - ['mlxtend.frequent_patterns.fpmax'](https://rasbt.github.io/mlxtend/user_guide/frequent_patterns/fpmax/) - [`mlxtend.feature_selection.SequentialFeatureSelector`](https://github.com/rasbt/mlxtend/blob/master/mlxtend/feature_selection/sequential_feature_selector.py) + - Updated negative infinity constant to be compatible with old and new (>=2.0) `numpy` versions - [`mlxtend.frequent_patterns.association_rules`](https://rasbt.github.io/mlxtend/user_guide/frequent_patterns/association_rules/) - Implemented three new metrics: Jaccard, Certainty, and Kulczynski. ([#1096](https://github.com/rasbt/mlxtend/issues/1096)) - Integrated scikit-learn's `set_output` method into `TransactionEncoder` ([#1087](https://github.com/rasbt/mlxtend/issues/1087) via [it176131](https://github.com/it176131))