Skip to content

Commit a888ffc

Browse files
author
Guillaume Lemaitre
committed
Fix the bug about the indices of CNN
1 parent 279190c commit a888ffc

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

imblearn/under_sampling/condensed_nearest_neighbour.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,12 @@ def _sample(self, X, y):
189189
sel_x = np.squeeze(S_x[idx_maj_sample, :])
190190
sel_y = S_y[idx_maj_sample]
191191

192+
# The indexes found are relative to the current class, we need to
193+
# find the absolute value
194+
# Build the array with the absolute position
195+
abs_pos = np.flatnonzero(y == key)
196+
idx_maj_sample = abs_pos[idx_maj_sample]
197+
192198
# If we need to offer support for the indices selected
193199
if self.return_indices:
194200
idx_under = np.concatenate((idx_under, idx_maj_sample), axis=0)

0 commit comments

Comments
 (0)