Skip to content

Commit 80f8f6b

Browse files
author
Guillaume Lemaitre
committed
Merge branch 'issue_137'
Conflicts: doc/whats_new.rst
2 parents a5379ab + db4a0e5 commit 80f8f6b

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

doc/whats_new.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Bug fixes
1919
- Fixed a bug in :class:`ensemble.EasyEnsemble`, correction of the `random_state` generation. By `Guillaume Lemaitre`_ and `Christos Aridas`_.
2020
- Fixed a bug in :class:`under_sampling.RepeatedEditedNearestNeighbours`, add additional stopping criterion to avoid that the minority class become a majority class or that a class disappear. By `Guillaume Lemaitre`_.
2121
- Fixed a bug in :class:`under_sampling.AllKNN`, add stopping criteria to avoid that the minority class become a majority class or that a class disappear. By `Guillaume Lemaitre`_.
22+
- Fixed a bug in :class:`under_sampling.CondensedNeareastNeigbour`, correction of the list of indices returned. By `Guillaume Lemaitre`_.
2223

2324
New features
2425
~~~~~~~~~~~~

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)