Skip to content

Commit b2ad0d4

Browse files
authored
Merge pull request #3 from aldder/sequentialfeatureselection_earlystop
fix rasbt#886 (comment) a…
2 parents 86a5124 + d5595a9 commit b2ad0d4

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

mlxtend/feature_selection/sequential_feature_selector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def __init__(self, estimator, k_features=1,
210210
if not isinstance(early_stop_rounds, int) or early_stop_rounds < 0:
211211
raise ValueError('Number of early stopping round should be '
212212
'an integer value greater than or equal to 0.'
213-
'Got %d' % early_stop_rounds)
213+
'Got %s' % early_stop_rounds)
214214

215215
self.early_stop_rounds = early_stop_rounds
216216

mlxtend/feature_selection/tests/test_sequential_feature_selector.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ def test_custom_feature_names():
978978
n_jobs=1)
979979

980980
sfs1 = sfs1.fit(X, y, custom_feature_names=(
981-
'sepal length', 'sepal width', 'petal length', 'petal width'))
981+
'sepal length', 'sepal width', 'petal length', 'petal width'))
982982
assert sfs1.k_feature_idx_ == (1, 3)
983983
assert sfs1.k_feature_names_ == ('sepal width', 'petal width')
984984
assert sfs1.subsets_[2]['feature_names'] == ('sepal width',
@@ -1000,13 +1000,12 @@ def test_run_forward_earlystop():
10001000
k_features='best',
10011001
forward=True,
10021002
floating=False,
1003-
early_stop=True,
10041003
early_stop_rounds=esr,
10051004
verbose=0)
10061005
sfs.fit(X_iris_with_noise, y_iris)
10071006
assert len(sfs.subsets_) < X_iris_with_noise.shape[1]
1008-
assert all([sfs.subsets_[list(sfs.subsets_)[-esr-1]]['avg_score']
1009-
>= sfs.subsets_[i]['avg_score'] for i in sfs.subsets_.keys()])
1007+
assert all([sfs.k_score_ >= sfs.subsets_[i]['avg_score']
1008+
for i in sfs.subsets_])
10101009

10111010

10121011
def test_run_backward_earlystop():
@@ -1024,10 +1023,9 @@ def test_run_backward_earlystop():
10241023
k_features='best',
10251024
forward=False,
10261025
floating=False,
1027-
early_stop=True,
10281026
early_stop_rounds=esr,
10291027
verbose=0)
10301028
sfs.fit(X_iris_with_noise, y_iris)
10311029
assert len(sfs.subsets_) > 1
1032-
assert all([sfs.subsets_[list(sfs.subsets_)[-esr-1]]['avg_score']
1033-
>= sfs.subsets_[i]['avg_score'] for i in sfs.subsets_.keys()])
1030+
assert all([sfs.k_score_ >= sfs.subsets_[i]['avg_score']
1031+
for i in sfs.subsets_])

0 commit comments

Comments
 (0)