Skip to content

Commit a955c24

Browse files
author
Guillaume Lemaitre
committed
Remove nonzero occurence in OSS
1 parent 317221d commit a955c24

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

imblearn/under_sampling/one_sided_selection.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def _sample(self, X, y):
115115

116116
# If we need to offer support for the indices
117117
if self.return_indices:
118-
idx_under = np.nonzero(y == self.min_c_)[0]
118+
idx_under = np.flatnonzero(y == self.min_c_)
119119

120120
# Loop over the other classes under picking at random
121121
for key in self.stats_c_.keys():
@@ -158,14 +158,15 @@ def _sample(self, X, y):
158158
pred_S_y = knn.predict(S_x)
159159

160160
# Find the misclassified S_y
161-
sel_x = np.squeeze(S_x[np.nonzero(pred_S_y != S_y), :])
162-
sel_y = S_y[np.nonzero(pred_S_y != S_y)]
161+
sel_x = S_x[np.flatnonzero(pred_S_y != S_y), :]
162+
sel_y = S_y[np.flatnonzero(pred_S_y != S_y)]
163163

164164
# If we need to offer support for the indices selected
165165
# We concatenate the misclassified samples with the seed and the
166166
# minority samples
167167
if self.return_indices:
168-
idx_tmp = np.nonzero(y == key)[0][np.nonzero(pred_S_y != S_y)]
168+
idx_tmp = np.flatnonzero(y == key)[
169+
np.flatnonzero(pred_S_y != S_y)]
169170
idx_under = np.concatenate((idx_under,
170171
idx_maj_sample,
171172
idx_tmp),

0 commit comments

Comments
 (0)