Skip to content

Commit f052175

Browse files
authored
Address issue #140 - Add condition to raise warning in NearMiss
2 parents 80f8f6b + ae403a0 commit f052175

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

imblearn/under_sampling/nearmiss.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,11 @@ def _selection_dist_based(self, X, y, dist_vec, num_samples, key,
175175

176176
# Throw a warning to tell the user that we did not have enough samples
177177
# to select and that we just select everything
178-
warnings.warn('The number of the samples to be selected is larger than'
179-
' the number of samples available. The balancing ratio'
180-
' cannot be ensure and all samples will be returned.')
178+
if len(sorted_idx) < num_samples:
179+
warnings.warn('The number of the samples to be selected is larger'
180+
' than the number of samples available. The'
181+
' balancing ratio cannot be ensure and all samples'
182+
' will be returned.')
181183

182184
# Select the desired number of samples
183185
sel_idx = sorted_idx[:num_samples]

0 commit comments

Comments
 (0)