Skip to content

Commit

Permalink
sort feature indices
Browse files Browse the repository at this point in the history
  • Loading branch information
rasbt committed Oct 12, 2017
1 parent bb9af54 commit 1550820
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions docs/sources/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ The CHANGELOG for the current development version is available at
- Added `'leverage'` and `'conviction` as evaluation metrics to the `frequent_patterns.association_rules` function. [#246](https://github.com/rasbt/mlxtend/pull/246) & [#247](https://github.com/rasbt/mlxtend/pull/247)
- Added a `loadings_` attribute to `PrincipalComponentAnalysis` to compute the factor loadings of the features on the principal components. [#251](https://github.com/rasbt/mlxtend/pull/251)
- Allow grid search over classifiers/regressors in ensemble and stacking estimators [#259](https://github.com/rasbt/mlxtend/pull/259)
- Added a `recursive_floating` parameter to the `SequentialFeatureSelector` to enable the continuation of the floating inclusion/exclusion as described in Novovicova & Kittler (1994) [#262](https://github.com/rasbt/mlxtend/pull/262)

##### Changes

- The `'support'` column returned by `frequent_patterns.association_rules` was changed to compute the support of "antecedant union consequent", and new `antecedant support'` and `'consequent support'` column were added to avoid ambiguity. [#245](https://github.com/rasbt/mlxtend/pull/245)
- Allow the `OnehotTransactions` to be cloned via scikit-learn's `clone` function, which is required by e.g., scikit-learn's `FeatureUnion` or `GridSearchCV` (via [Iaroslav Shcherbatyi](https://github.com/iaroslav-ai)). [#249](https://github.com/rasbt/mlxtend/pull/249)
- All feature indix tuples in `SequentialFeatureSelector` or now in sorted order [#262](https://github.com/rasbt/mlxtend/pull/262)

##### Bug Fixes

Expand Down
4 changes: 3 additions & 1 deletion mlxtend/feature_selection/sequential_feature_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,9 @@ def fit(self, X, y):
# floating can lead to multiple same-sized subsets
if k not in self.subsets_ or (k_score >
self.subsets_[k]['avg_score']):

k_idx = tuple(sorted(k_idx))

self.subsets_[k] = {
'feature_idx': k_idx,
'cv_scores': cv_scores,
Expand Down Expand Up @@ -424,7 +427,6 @@ def fit(self, X, y):

self.k_feature_idx_ = k_idx
self.k_score_ = k_score
self.subsets_plus_ = dict()
self.fitted = True
return self

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ def test_regression_sbfs():
cv=10,
verbose=0)
sfs_r = sfs_r.fit(X, y)
assert sfs_r.k_feature_idx_ == (10, 12, 7), sfs_r.k_feature_idx_
assert sfs_r.k_feature_idx_ == (7, 10, 12), sfs_r.k_feature_idx_


def test_regression_sbfs_recursive_floating():
Expand All @@ -516,7 +516,7 @@ def test_regression_sbfs_recursive_floating():
recursive_floating=True,
verbose=0)
sfs_r = sfs_r.fit(X, y)
assert sfs_r.k_feature_idx_ == (10, 12, 7), sfs_r.k_feature_idx_
assert sfs_r.k_feature_idx_ == (7, 10, 12), sfs_r.k_feature_idx_


def test_regression_in_range():
Expand Down Expand Up @@ -741,4 +741,4 @@ def test_max_feature_subset_parsimonious():
cv=10)

sfs = sfs.fit(X, y)
assert sfs.k_feature_idx_ == (10, 11, 12, 5)
assert sfs.k_feature_idx_ == (5, 10, 11, 12)

0 comments on commit 1550820

Please sign in to comment.