@@ -205,6 +205,10 @@ def sample(self, X, y):
205
205
S_x = X [y == key ]
206
206
S_y = y [y == key ]
207
207
208
+ # Remove the seed from S since that it will be added anyway
209
+ S_x = np .delete (S_x , idx_maj_sample , axis = 0 )
210
+ S_y = np .delete (S_y , idx_maj_sample , axis = 0 )
211
+
208
212
# Create a k-NN classifier
209
213
knn = KNeighborsClassifier (n_neighbors = self .size_ngh ,
210
214
n_jobs = self .n_jobs ,
@@ -221,12 +225,23 @@ def sample(self, X, y):
221
225
sel_y = S_y [np .nonzero (pred_S_y != S_y )]
222
226
223
227
# If we need to offer support for the indices selected
228
+ # We concatenate the misclassified samples with the seed and the
229
+ # minority samples
224
230
if self .return_indices :
225
231
idx_tmp = np .nonzero (y == key )[0 ][np .nonzero (pred_S_y != S_y )]
226
- idx_under = np .concatenate ((idx_under , idx_tmp ), axis = 0 )
227
-
228
- X_resampled = np .concatenate ((X_resampled , sel_x ), axis = 0 )
229
- y_resampled = np .concatenate ((y_resampled , sel_y ), axis = 0 )
232
+ idx_under = np .concatenate ((idx_under ,
233
+ idx_maj_sample ,
234
+ idx_tmp ),
235
+ axis = 0 )
236
+
237
+ X_resampled = np .concatenate ((X_resampled ,
238
+ maj_sample ,
239
+ sel_x ),
240
+ axis = 0 )
241
+ y_resampled = np .concatenate ((y_resampled ,
242
+ [key ] * self .n_seeds_S ,
243
+ sel_y ),
244
+ axis = 0 )
230
245
231
246
# Find the nearest neighbour of every point
232
247
nn = NearestNeighbors (n_neighbors = 2 , n_jobs = self .n_jobs )
0 commit comments