diff --git a/imblearn/over_sampling/_smote.py b/imblearn/over_sampling/_smote.py index bb5b3bd01..ee652928f 100644 --- a/imblearn/over_sampling/_smote.py +++ b/imblearn/over_sampling/_smote.py @@ -554,12 +554,19 @@ def _fit_resample(self, X, y): support_vector = _safe_indexing(X, support_index) self.nn_m_.fit(X) + + prev_support_vector = support_vector + noise_bool = self._in_danger_noise( self.nn_m_, support_vector, class_sample, y, kind="noise" ) support_vector = _safe_indexing( support_vector, np.flatnonzero(np.logical_not(noise_bool)) ) + + if len(support_vector) == 0: + support_vector = prev_support_vector + danger_bool = self._in_danger_noise( self.nn_m_, support_vector, class_sample, y, kind="danger" )