Skip to content

Commit 0fd4794

Browse files
committed
TST check behaviour of kind_sel in ENN
1 parent 6e9eeff commit 0fd4794

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

imblearn/under_sampling/_prototype_selection/tests/test_edited_nearest_neighbours.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from sklearn.utils._testing import assert_array_equal
1010

11+
from sklearn.datasets import make_classification
1112
from sklearn.neighbors import NearestNeighbors
1213

1314
from imblearn.under_sampling import EditedNearestNeighbours
@@ -127,3 +128,20 @@ def test_enn_not_good_object():
127128
enn = EditedNearestNeighbours(n_neighbors=nn, kind_sel="mode")
128129
with pytest.raises(ValueError, match="has to be one of"):
129130
enn.fit_resample(X, Y)
131+
132+
133+
def test_enn_check_kind_selection():
134+
"""Check that `check_sel="all"` is more conservative than
135+
`check_sel="mode"`."""
136+
137+
X, y = make_classification(
138+
n_samples=1000, n_classes=2, weights=[0.3, 0.7], random_state=0,
139+
)
140+
141+
enn_all = EditedNearestNeighbours(kind_sel="all")
142+
enn_mode = EditedNearestNeighbours(kind_sel="mode")
143+
144+
enn_all.fit_resample(X, y)
145+
enn_mode.fit_resample(X, y)
146+
147+
assert enn_all.sample_indices_.size < enn_mode.sample_indices_.size

0 commit comments

Comments
 (0)