Skip to content

Commit 197c119

Browse files
author
Guillaume Lemaitre
committed
Fix the bug about the indices of CNN
1 parent f905274 commit 197c119

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
@@ -204,6 +204,12 @@ def _sample(self, X, y):
204204
sel_x = np.squeeze(S_x[idx_maj_sample, :])
205205
sel_y = S_y[idx_maj_sample]
206206

207+
# The indexes found are relative to the current class, we need to
208+
# find the absolute value
209+
# Build the array with the absolute position
210+
abs_pos = np.flatnonzero(y == key)
211+
idx_maj_sample = abs_pos[idx_maj_sample]
212+
207213
# If we need to offer support for the indices selected
208214
if self.return_indices:
209215
idx_under = np.concatenate((idx_under, idx_maj_sample), axis=0)

0 commit comments

Comments
 (0)