|
14 | 14 | from sklearn.utils import check_X_y
|
15 | 15 | from sklearn.utils.multiclass import type_of_target
|
16 | 16 |
|
17 |
| -logging.captureWarnings(False) |
18 |
| -warnings.simplefilter('always', UserWarning) |
19 |
| - |
20 | 17 |
|
21 | 18 | class SamplerMixin(six.with_metaclass(ABCMeta, BaseEstimator)):
|
22 | 19 |
|
@@ -87,6 +84,7 @@ def fit(self, X, y):
|
87 | 84 | self.logger.debug('Shall we raise a warning: %s',
|
88 | 85 | np.unique(y).size == 1)
|
89 | 86 | if np.unique(y).size == 1:
|
| 87 | + warnings.simplefilter('always', UserWarning) |
90 | 88 | warnings.warn('Only one class detected, something will get wrong')
|
91 | 89 | self.logger.debug('The warning should has been raised.')
|
92 | 90 |
|
@@ -257,6 +255,7 @@ def fit(self, X, y):
|
257 | 255 |
|
258 | 256 | # Check that the target type is binary
|
259 | 257 | if not type_of_target(y) == 'binary':
|
| 258 | + warnings.simplefilter('always', UserWarning) |
260 | 259 | warnings.warn('The target type should be binary.')
|
261 | 260 |
|
262 | 261 | return self
|
@@ -293,6 +292,7 @@ def fit(self, X, y):
|
293 | 292 | # Check that the target type is either binary or multiclass
|
294 | 293 | if not (type_of_target(y) == 'binary' or
|
295 | 294 | type_of_target(y) == 'multiclass'):
|
| 295 | + warnings.simplefilter('always', UserWarning) |
296 | 296 | warnings.warn('The target type should be binary or multiclass.')
|
297 | 297 |
|
298 | 298 | return self
|
0 commit comments