diff --git a/doc/whats_new.rst b/doc/whats_new.rst index 5db36a918..2fb658be2 100644 --- a/doc/whats_new.rst +++ b/doc/whats_new.rst @@ -17,6 +17,7 @@ Bug fixes - Fixed a bug in :class:`under_sampling.NearMiss` which was not picking the right samples during under sampling for the method 3. By `Guillaume Lemaitre`_. - Fixed a bug in :class:`ensemble.EasyEnsemble`, correction of the `random_state` generation. By `Guillaume Lemaitre`_ and `Christos Aridas`_. +- Fixed a bug in :class:`under_sampling.CondensedNeareastNeigbour`, correction of the list of indices returned. By `Guillaume Lemaitre`_. New features ~~~~~~~~~~~~ diff --git a/imblearn/under_sampling/condensed_nearest_neighbour.py b/imblearn/under_sampling/condensed_nearest_neighbour.py index 17322bdbb..10ab37999 100644 --- a/imblearn/under_sampling/condensed_nearest_neighbour.py +++ b/imblearn/under_sampling/condensed_nearest_neighbour.py @@ -204,6 +204,12 @@ def _sample(self, X, y): sel_x = np.squeeze(S_x[idx_maj_sample, :]) sel_y = S_y[idx_maj_sample] + # The indexes found are relative to the current class, we need to + # find the absolute value + # Build the array with the absolute position + abs_pos = np.flatnonzero(y == key) + idx_maj_sample = abs_pos[idx_maj_sample] + # If we need to offer support for the indices selected if self.return_indices: idx_under = np.concatenate((idx_under, idx_maj_sample), axis=0)