From 197c11967485d54f5a9e785564fed985527920cf Mon Sep 17 00:00:00 2001 From: Guillaume Lemaitre Date: Tue, 30 Aug 2016 20:39:31 +0200 Subject: [PATCH 1/2] Fix the bug about the indices of CNN --- imblearn/under_sampling/condensed_nearest_neighbour.py | 6 ++++++ 1 file changed, 6 insertions(+) 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) From db4a0e5e9e90411a6e620626ab22ab0c75c03979 Mon Sep 17 00:00:00 2001 From: Guillaume Lemaitre Date: Tue, 30 Aug 2016 20:42:15 +0200 Subject: [PATCH 2/2] Update the history --- doc/whats_new.rst | 1 + 1 file changed, 1 insertion(+) 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 ~~~~~~~~~~~~