Skip to content

Commit

Permalink
SFS finalize_fit() support for numpy >= 2.0 (#1107)
Browse files Browse the repository at this point in the history
* finalize_fit() support for numpy >= 2.0

* updated changelog

* flake8: removed blank line

* flake8: removed trailing whitespaces

* fixed changelog indents

* fix for isort / black formatter

* added change/feature description
  • Loading branch information
d-kleine authored Nov 3, 2024
1 parent 11a295e commit a78bd0b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 4 additions & 2 deletions docs/sources/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ 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.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/)
- [`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))
- 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

Expand Down
8 changes: 6 additions & 2 deletions mlxtend/feature_selection/sequential_feature_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,11 @@ 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
Expand All @@ -662,7 +666,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())
Expand Down

0 comments on commit a78bd0b

Please sign in to comment.