From ec20028efc8007ed1f795c9fafb95bfdd7e6c027 Mon Sep 17 00:00:00 2001 From: Guillaume Lemaitre Date: Tue, 18 Oct 2016 16:31:42 +0200 Subject: [PATCH 01/16] Change the unique checking --- imblearn/base.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/imblearn/base.py b/imblearn/base.py index 610896113..107d37a77 100644 --- a/imblearn/base.py +++ b/imblearn/base.py @@ -76,14 +76,11 @@ def fit(self, X, y): self.logger.info('Compute classes statistics ...') - # Get all the unique elements in the target array - uniques = np.unique(y) - # # Raise an error if there is only one class # if uniques.size == 1: # raise RuntimeError("Only one class detected, aborting...") # Raise a warning for the moment to be compatible with BaseEstimator - if uniques.size == 1: + if np.unique(y).size == 1: warnings.warn('Only one class detected, something will get wrong', RuntimeWarning) @@ -98,7 +95,7 @@ def fit(self, X, y): self.min_c_ = min(self.stats_c_, key=self.stats_c_.get) self.maj_c_ = max(self.stats_c_, key=self.stats_c_.get) - self.logger.info('%s classes detected: %s', uniques.size, + self.logger.info('%s classes detected: %s', np.unique(y).size, self.stats_c_) # Check if the ratio provided at initialisation make sense From a3d38f211b2bead29cc0313bfefb54a1b11dc8ab Mon Sep 17 00:00:00 2001 From: Guillaume Lemaitre Date: Tue, 18 Oct 2016 16:39:11 +0200 Subject: [PATCH 02/16] Change type of warning --- imblearn/base.py | 3 +-- imblearn/combine/tests/test_smote_enn.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/imblearn/base.py b/imblearn/base.py index 107d37a77..708afe27c 100644 --- a/imblearn/base.py +++ b/imblearn/base.py @@ -81,8 +81,7 @@ def fit(self, X, y): # raise RuntimeError("Only one class detected, aborting...") # Raise a warning for the moment to be compatible with BaseEstimator if np.unique(y).size == 1: - warnings.warn('Only one class detected, something will get wrong', - RuntimeWarning) + warnings.warn('Only one class detected, something will get wrong') # Store the size of X to check at sampling time if we have the # same data diff --git a/imblearn/combine/tests/test_smote_enn.py b/imblearn/combine/tests/test_smote_enn.py index f3506eab4..e83c98b83 100644 --- a/imblearn/combine/tests/test_smote_enn.py +++ b/imblearn/combine/tests/test_smote_enn.py @@ -74,7 +74,7 @@ def test_smote_fit_single_class(): # Resample the data # Create a wrong y y_single_class = np.zeros((X.shape[0], )) - assert_warns(RuntimeWarning, smote.fit, X, y_single_class) + assert_warns(UserWarning, smote.fit, X, y_single_class) def test_smote_fit(): From 315d30bb0d20e42863ee808e7e448593d9688f71 Mon Sep 17 00:00:00 2001 From: Guillaume Lemaitre Date: Tue, 18 Oct 2016 17:11:42 +0200 Subject: [PATCH 03/16] Change runtimewarning to userwarning --- imblearn/combine/tests/test_smote_tomek.py | 2 +- imblearn/ensemble/tests/test_balance_cascade.py | 2 +- imblearn/ensemble/tests/test_easy_ensemble.py | 2 +- imblearn/over_sampling/tests/test_adasyn.py | 2 +- imblearn/over_sampling/tests/test_random_over_sampler.py | 2 +- imblearn/over_sampling/tests/test_smote.py | 2 +- imblearn/under_sampling/tests/test_allknn.py | 2 +- imblearn/under_sampling/tests/test_cluster_centroids.py | 2 +- .../under_sampling/tests/test_condensed_nearest_neighbour.py | 2 +- imblearn/under_sampling/tests/test_edited_nearest_neighbours.py | 2 +- .../under_sampling/tests/test_instance_hardness_threshold.py | 2 +- imblearn/under_sampling/tests/test_nearmiss_1.py | 2 +- imblearn/under_sampling/tests/test_nearmiss_2.py | 2 +- imblearn/under_sampling/tests/test_nearmiss_3.py | 2 +- .../under_sampling/tests/test_neighbourhood_cleaning_rule.py | 2 +- imblearn/under_sampling/tests/test_one_sided_selection.py | 2 +- imblearn/under_sampling/tests/test_random_under_sampler.py | 2 +- .../tests/test_repeated_edited_nearest_neighbours.py | 2 +- imblearn/under_sampling/tests/test_tomek_links.py | 2 +- 19 files changed, 19 insertions(+), 19 deletions(-) diff --git a/imblearn/combine/tests/test_smote_tomek.py b/imblearn/combine/tests/test_smote_tomek.py index 423faf3f6..9582e77f1 100644 --- a/imblearn/combine/tests/test_smote_tomek.py +++ b/imblearn/combine/tests/test_smote_tomek.py @@ -74,7 +74,7 @@ def test_smote_fit_single_class(): # Resample the data # Create a wrong y y_single_class = np.zeros((X.shape[0], )) - assert_warns(RuntimeWarning, smote.fit, X, y_single_class) + assert_warns(UserWarning, smote.fit, X, y_single_class) def test_smote_fit(): diff --git a/imblearn/ensemble/tests/test_balance_cascade.py b/imblearn/ensemble/tests/test_balance_cascade.py index eff8a809c..c8d1bb088 100644 --- a/imblearn/ensemble/tests/test_balance_cascade.py +++ b/imblearn/ensemble/tests/test_balance_cascade.py @@ -90,7 +90,7 @@ def test_bc_fit_single_class(): # Resample the data # Create a wrong y y_single_class = np.zeros((X.shape[0], )) - assert_warns(RuntimeWarning, bc.fit, X, y_single_class) + assert_warns(UserWarning, bc.fit, X, y_single_class) def test_bc_fit_invalid_ratio(): diff --git a/imblearn/ensemble/tests/test_easy_ensemble.py b/imblearn/ensemble/tests/test_easy_ensemble.py index 9852cf2f3..02aef5bee 100644 --- a/imblearn/ensemble/tests/test_easy_ensemble.py +++ b/imblearn/ensemble/tests/test_easy_ensemble.py @@ -81,7 +81,7 @@ def test_ee_fit_single_class(): # Resample the data # Create a wrong y y_single_class = np.zeros((X.shape[0], )) - assert_warns(RuntimeWarning, ee.fit, X, y_single_class) + assert_warns(UserWarning, ee.fit, X, y_single_class) def test_ee_fit_invalid_ratio(): diff --git a/imblearn/over_sampling/tests/test_adasyn.py b/imblearn/over_sampling/tests/test_adasyn.py index 7937cebdc..9c38d3c5f 100644 --- a/imblearn/over_sampling/tests/test_adasyn.py +++ b/imblearn/over_sampling/tests/test_adasyn.py @@ -84,7 +84,7 @@ def test_ada_fit_single_class(): # Resample the data # Create a wrong y y_single_class = np.zeros((X.shape[0], )) - assert_warns(RuntimeWarning, ada.fit, X, y_single_class) + assert_warns(UserWarning, ada.fit, X, y_single_class) def test_ada_fit_invalid_ratio(): diff --git a/imblearn/over_sampling/tests/test_random_over_sampler.py b/imblearn/over_sampling/tests/test_random_over_sampler.py index 20a65b9fd..db6f50462 100644 --- a/imblearn/over_sampling/tests/test_random_over_sampler.py +++ b/imblearn/over_sampling/tests/test_random_over_sampler.py @@ -75,7 +75,7 @@ def test_ros_fit_single_class(): # Resample the data # Create a wrong y y_single_class = np.zeros((X.shape[0], )) - assert_warns(RuntimeWarning, ros.fit, X, y_single_class) + assert_warns(UserWarning, ros.fit, X, y_single_class) def test_ros_fit_invalid_ratio(): diff --git a/imblearn/over_sampling/tests/test_smote.py b/imblearn/over_sampling/tests/test_smote.py index 33c93620e..46c01ceec 100644 --- a/imblearn/over_sampling/tests/test_smote.py +++ b/imblearn/over_sampling/tests/test_smote.py @@ -83,7 +83,7 @@ def test_smote_fit_single_class(): # Resample the data # Create a wrong y y_single_class = np.zeros((X.shape[0], )) - assert_warns(RuntimeWarning, smote.fit, X, y_single_class) + assert_warns(UserWarning, smote.fit, X, y_single_class) def test_smote_fit(): diff --git a/imblearn/under_sampling/tests/test_allknn.py b/imblearn/under_sampling/tests/test_allknn.py index e8afa702e..3bd0f2075 100644 --- a/imblearn/under_sampling/tests/test_allknn.py +++ b/imblearn/under_sampling/tests/test_allknn.py @@ -83,7 +83,7 @@ def test_allknn_fit_single_class(): # Resample the data # Create a wrong y y_single_class = np.zeros((X.shape[0], )) - assert_warns(RuntimeWarning, allknn.fit, X, y_single_class) + assert_warns(UserWarning, allknn.fit, X, y_single_class) def test_allknn_fit(): diff --git a/imblearn/under_sampling/tests/test_cluster_centroids.py b/imblearn/under_sampling/tests/test_cluster_centroids.py index eb0a4cbdc..bacf03b48 100644 --- a/imblearn/under_sampling/tests/test_cluster_centroids.py +++ b/imblearn/under_sampling/tests/test_cluster_centroids.py @@ -78,7 +78,7 @@ def test_cc_fit_single_class(): # Resample the data # Create a wrong y y_single_class = np.zeros((X.shape[0], )) - assert_warns(RuntimeWarning, cc.fit, X, y_single_class) + assert_warns(UserWarning, cc.fit, X, y_single_class) def test_cc_fit_invalid_ratio(): diff --git a/imblearn/under_sampling/tests/test_condensed_nearest_neighbour.py b/imblearn/under_sampling/tests/test_condensed_nearest_neighbour.py index 60f078609..2ddcd1a19 100644 --- a/imblearn/under_sampling/tests/test_condensed_nearest_neighbour.py +++ b/imblearn/under_sampling/tests/test_condensed_nearest_neighbour.py @@ -60,7 +60,7 @@ def test_cnn_fit_single_class(): # Resample the data # Create a wrong y y_single_class = np.zeros((X.shape[0], )) - assert_warns(RuntimeWarning, cnn.fit, X, y_single_class) + assert_warns(UserWarning, cnn.fit, X, y_single_class) def test_cnn_fit(): diff --git a/imblearn/under_sampling/tests/test_edited_nearest_neighbours.py b/imblearn/under_sampling/tests/test_edited_nearest_neighbours.py index 4b8240552..6471dcb79 100644 --- a/imblearn/under_sampling/tests/test_edited_nearest_neighbours.py +++ b/imblearn/under_sampling/tests/test_edited_nearest_neighbours.py @@ -61,7 +61,7 @@ def test_enn_fit_single_class(): # Resample the data # Create a wrong y y_single_class = np.zeros((X.shape[0], )) - assert_warns(RuntimeWarning, enn.fit, X, y_single_class) + assert_warns(UserWarning, enn.fit, X, y_single_class) def test_enn_fit(): diff --git a/imblearn/under_sampling/tests/test_instance_hardness_threshold.py b/imblearn/under_sampling/tests/test_instance_hardness_threshold.py index 8ab19f9ad..02a057d4f 100644 --- a/imblearn/under_sampling/tests/test_instance_hardness_threshold.py +++ b/imblearn/under_sampling/tests/test_instance_hardness_threshold.py @@ -93,7 +93,7 @@ def test_iht_fit_single_class(): # Resample the data # Create a wrong y y_single_class = np.zeros((X.shape[0], )) - assert_warns(RuntimeWarning, iht.fit, X, y_single_class) + assert_warns(UserWarning, iht.fit, X, y_single_class) def test_iht_fit_invalid_ratio(): diff --git a/imblearn/under_sampling/tests/test_nearmiss_1.py b/imblearn/under_sampling/tests/test_nearmiss_1.py index 1852e93a4..67b1aba6f 100644 --- a/imblearn/under_sampling/tests/test_nearmiss_1.py +++ b/imblearn/under_sampling/tests/test_nearmiss_1.py @@ -97,7 +97,7 @@ def test_nearmiss_fit_single_class(): # Resample the data # Create a wrong y y_single_class = np.zeros((X.shape[0], )) - assert_warns(RuntimeWarning, nm1.fit, X, y_single_class) + assert_warns(UserWarning, nm1.fit, X, y_single_class) def test_nm_fit_invalid_ratio(): diff --git a/imblearn/under_sampling/tests/test_nearmiss_2.py b/imblearn/under_sampling/tests/test_nearmiss_2.py index cf23c0af6..142b377b6 100644 --- a/imblearn/under_sampling/tests/test_nearmiss_2.py +++ b/imblearn/under_sampling/tests/test_nearmiss_2.py @@ -97,7 +97,7 @@ def test_nearmiss_fit_single_class(): # Resample the data # Create a wrong y y_single_class = np.zeros((X.shape[0], )) - assert_warns(RuntimeWarning, nm2.fit, X, y_single_class) + assert_warns(UserWarning, nm2.fit, X, y_single_class) def test_nm_fit_invalid_ratio(): diff --git a/imblearn/under_sampling/tests/test_nearmiss_3.py b/imblearn/under_sampling/tests/test_nearmiss_3.py index 62fc7c297..c73fd8087 100644 --- a/imblearn/under_sampling/tests/test_nearmiss_3.py +++ b/imblearn/under_sampling/tests/test_nearmiss_3.py @@ -97,7 +97,7 @@ def test_nearmiss_fit_single_class(): # Resample the data # Create a wrong y y_single_class = np.zeros((X.shape[0], )) - assert_warns(RuntimeWarning, nm3.fit, X, y_single_class) + assert_warns(UserWarning, nm3.fit, X, y_single_class) def test_nm_fit_invalid_ratio(): diff --git a/imblearn/under_sampling/tests/test_neighbourhood_cleaning_rule.py b/imblearn/under_sampling/tests/test_neighbourhood_cleaning_rule.py index e8997e55a..24cd9c556 100644 --- a/imblearn/under_sampling/tests/test_neighbourhood_cleaning_rule.py +++ b/imblearn/under_sampling/tests/test_neighbourhood_cleaning_rule.py @@ -55,7 +55,7 @@ def test_ncr_fit_single_class(): # Resample the data # Create a wrong y y_single_class = np.zeros((X.shape[0], )) - assert_warns(RuntimeWarning, ncr.fit, X, y_single_class) + assert_warns(UserWarning, ncr.fit, X, y_single_class) def test_ncr_fit(): diff --git a/imblearn/under_sampling/tests/test_one_sided_selection.py b/imblearn/under_sampling/tests/test_one_sided_selection.py index 09269df7c..80eb4aaea 100644 --- a/imblearn/under_sampling/tests/test_one_sided_selection.py +++ b/imblearn/under_sampling/tests/test_one_sided_selection.py @@ -57,7 +57,7 @@ def test_oss_fit_single_class(): # Resample the data # Create a wrong y y_single_class = np.zeros((X.shape[0], )) - assert_warns(RuntimeWarning, oss.fit, X, y_single_class) + assert_warns(UserWarning, oss.fit, X, y_single_class) def test_oss_fit(): diff --git a/imblearn/under_sampling/tests/test_random_under_sampler.py b/imblearn/under_sampling/tests/test_random_under_sampler.py index 5d1a714ca..a77b65e25 100644 --- a/imblearn/under_sampling/tests/test_random_under_sampler.py +++ b/imblearn/under_sampling/tests/test_random_under_sampler.py @@ -74,7 +74,7 @@ def test_rus_fit_single_class(): # Resample the data # Create a wrong y y_single_class = np.zeros((X.shape[0], )) - assert_warns(RuntimeWarning, rus.fit, X, y_single_class) + assert_warns(UserWarning, rus.fit, X, y_single_class) def test_rus_fit_invalid_ratio(): diff --git a/imblearn/under_sampling/tests/test_repeated_edited_nearest_neighbours.py b/imblearn/under_sampling/tests/test_repeated_edited_nearest_neighbours.py index 1f5536b06..ba24e3189 100644 --- a/imblearn/under_sampling/tests/test_repeated_edited_nearest_neighbours.py +++ b/imblearn/under_sampling/tests/test_repeated_edited_nearest_neighbours.py @@ -94,7 +94,7 @@ def test_renn_fit_single_class(): # Resample the data # Create a wrong y y_single_class = np.zeros((X.shape[0], )) - assert_warns(RuntimeWarning, renn.fit, X, y_single_class) + assert_warns(UserWarning, renn.fit, X, y_single_class) def test_renn_fit(): diff --git a/imblearn/under_sampling/tests/test_tomek_links.py b/imblearn/under_sampling/tests/test_tomek_links.py index 670dfe58a..a2e979799 100644 --- a/imblearn/under_sampling/tests/test_tomek_links.py +++ b/imblearn/under_sampling/tests/test_tomek_links.py @@ -59,7 +59,7 @@ def test_tl_fit_single_class(): # Resample the data # Create a wrong y y_single_class = np.zeros((X.shape[0], )) - assert_warns(RuntimeWarning, tl.fit, X, y_single_class) + assert_warns(UserWarning, tl.fit, X, y_single_class) def test_tl_fit(): From 15b0b7172e60852b30e51ccd8c43f62d915be525 Mon Sep 17 00:00:00 2001 From: Guillaume Lemaitre Date: Tue, 18 Oct 2016 17:40:20 +0200 Subject: [PATCH 04/16] Set the warnings filters --- imblearn/base.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/imblearn/base.py b/imblearn/base.py index 708afe27c..bb6856d21 100644 --- a/imblearn/base.py +++ b/imblearn/base.py @@ -15,6 +15,9 @@ from sklearn.utils.multiclass import type_of_target +warnings.simplefilter('always', category=UserWarning) + + class SamplerMixin(six.with_metaclass(ABCMeta, BaseEstimator)): """Mixin class for samplers with abstact method. From 770ccb0085900a3f089e0399b8acd35faf11107d Mon Sep 17 00:00:00 2001 From: Guillaume Lemaitre Date: Tue, 18 Oct 2016 17:52:45 +0200 Subject: [PATCH 05/16] Add some debugging --- imblearn/base.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/imblearn/base.py b/imblearn/base.py index bb6856d21..b3116c188 100644 --- a/imblearn/base.py +++ b/imblearn/base.py @@ -15,7 +15,7 @@ from sklearn.utils.multiclass import type_of_target -warnings.simplefilter('always', category=UserWarning) +warnings.simplefilter('always', UserWarning) class SamplerMixin(six.with_metaclass(ABCMeta, BaseEstimator)): @@ -83,6 +83,9 @@ def fit(self, X, y): # if uniques.size == 1: # raise RuntimeError("Only one class detected, aborting...") # Raise a warning for the moment to be compatible with BaseEstimator + self.logger.debug('The number of classes is %s', np.unique(y).size) + self.logger.debug('Shall we raise a warning: %s', + np.unique(y).size == 1) if np.unique(y).size == 1: warnings.warn('Only one class detected, something will get wrong') From ef26b1f4d97f03f6f04318c3aef3f6d5d6990914 Mon Sep 17 00:00:00 2001 From: Guillaume Lemaitre Date: Tue, 18 Oct 2016 18:04:19 +0200 Subject: [PATCH 06/16] Downgrade python --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 51f4d1563..54cff10bb 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,7 +6,7 @@ environment: # We use miniconda versions of Python provided by appveyor windows images matrix: - PYTHON: "C:\\Miniconda-x64" - PYTHON_VERSION: "2.7.x" + PYTHON_VERSION: "2.7.11" PYTHON_ARCH: "64" - PYTHON: "C:\\Miniconda3-x64" From c89e2083703a2ff1ff28aa34b7d2150a3cb3178e Mon Sep 17 00:00:00 2001 From: Guillaume Lemaitre Date: Tue, 18 Oct 2016 19:01:49 +0200 Subject: [PATCH 07/16] add some dbg --- imblearn/base.py | 1 + 1 file changed, 1 insertion(+) diff --git a/imblearn/base.py b/imblearn/base.py index b3116c188..790a0aab3 100644 --- a/imblearn/base.py +++ b/imblearn/base.py @@ -88,6 +88,7 @@ def fit(self, X, y): np.unique(y).size == 1) if np.unique(y).size == 1: warnings.warn('Only one class detected, something will get wrong') + self.logger.debug('The warning should has been raised.') # Store the size of X to check at sampling time if we have the # same data From 7c8423c689f8ff76b233311eb92b9527c956358f Mon Sep 17 00:00:00 2001 From: Guillaume Lemaitre Date: Tue, 18 Oct 2016 19:13:20 +0200 Subject: [PATCH 08/16] avoid capturing the warning in logger --- imblearn/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imblearn/base.py b/imblearn/base.py index 790a0aab3..d5099a9cc 100644 --- a/imblearn/base.py +++ b/imblearn/base.py @@ -14,7 +14,7 @@ from sklearn.utils import check_X_y from sklearn.utils.multiclass import type_of_target - +logging.captureWarnings(False) warnings.simplefilter('always', UserWarning) From be3e6383fe6da9ca17a9c7b4f37618904a22ac27 Mon Sep 17 00:00:00 2001 From: Guillaume Lemaitre Date: Tue, 18 Oct 2016 19:19:47 +0200 Subject: [PATCH 09/16] Make crippy test --- imblearn/base.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/imblearn/base.py b/imblearn/base.py index d5099a9cc..c736af884 100644 --- a/imblearn/base.py +++ b/imblearn/base.py @@ -295,4 +295,7 @@ def fit(self, X, y): type_of_target(y) == 'multiclass'): warnings.warn('The target type should be binary or multiclass.') + if np.unique(X).size == 1: + warnings.warn('Hello') + return self From a36f17a6e1b7382d5b88949dc6cc34e5e1ff074c Mon Sep 17 00:00:00 2001 From: Guillaume Lemaitre Date: Tue, 18 Oct 2016 19:28:35 +0200 Subject: [PATCH 10/16] Create the warning 2 subclasses --- imblearn/base.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/imblearn/base.py b/imblearn/base.py index c736af884..023a3cb06 100644 --- a/imblearn/base.py +++ b/imblearn/base.py @@ -255,6 +255,9 @@ def fit(self, X, y): super(BaseBinarySampler, self).fit(X, y) + if np.unique(y) == 1: + warnings.warn('Hello') + # Check that the target type is binary if not type_of_target(y) == 'binary': warnings.warn('The target type should be binary.') @@ -290,12 +293,12 @@ def fit(self, X, y): super(BaseMulticlassSampler, self).fit(X, y) + if np.unique(y) == 1: + warnings.warn('Hello') + # Check that the target type is either binary or multiclass if not (type_of_target(y) == 'binary' or type_of_target(y) == 'multiclass'): warnings.warn('The target type should be binary or multiclass.') - if np.unique(X).size == 1: - warnings.warn('Hello') - return self From 70f94b95676797035a2aac92cadbf3bd4c5cb86b Mon Sep 17 00:00:00 2001 From: Guillaume Lemaitre Date: Tue, 18 Oct 2016 19:35:49 +0200 Subject: [PATCH 11/16] solve an error --- imblearn/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/imblearn/base.py b/imblearn/base.py index 023a3cb06..d1e006e48 100644 --- a/imblearn/base.py +++ b/imblearn/base.py @@ -255,7 +255,7 @@ def fit(self, X, y): super(BaseBinarySampler, self).fit(X, y) - if np.unique(y) == 1: + if np.size(np.unique(y)) == 1: warnings.warn('Hello') # Check that the target type is binary @@ -293,7 +293,7 @@ def fit(self, X, y): super(BaseMulticlassSampler, self).fit(X, y) - if np.unique(y) == 1: + if np.size(np.unique(y)) == 1: warnings.warn('Hello') # Check that the target type is either binary or multiclass From 9d1be2689eaf846f83c2d35db4791a31c037776c Mon Sep 17 00:00:00 2001 From: Guillaume Lemaitre Date: Tue, 18 Oct 2016 19:44:29 +0200 Subject: [PATCH 12/16] check if we remove something that rise somethign before --- imblearn/combine/tests/test_smote_enn.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/imblearn/combine/tests/test_smote_enn.py b/imblearn/combine/tests/test_smote_enn.py index e83c98b83..19c3f3ad3 100644 --- a/imblearn/combine/tests/test_smote_enn.py +++ b/imblearn/combine/tests/test_smote_enn.py @@ -36,9 +36,9 @@ Y = np.array([0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0]) -def test_senn_sk_estimator(): - """Test the sklearn estimator compatibility""" - check_estimator(SMOTEENN) +# def test_senn_sk_estimator(): +# """Test the sklearn estimator compatibility""" +# check_estimator(SMOTEENN) def test_senn_bad_ratio(): From fd5d977f8fe681d5b4750a94f2e7c9f09267ede2 Mon Sep 17 00:00:00 2001 From: Guillaume Lemaitre Date: Tue, 18 Oct 2016 19:53:21 +0200 Subject: [PATCH 13/16] Try something else --- imblearn/base.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/imblearn/base.py b/imblearn/base.py index d1e006e48..d5099a9cc 100644 --- a/imblearn/base.py +++ b/imblearn/base.py @@ -255,9 +255,6 @@ def fit(self, X, y): super(BaseBinarySampler, self).fit(X, y) - if np.size(np.unique(y)) == 1: - warnings.warn('Hello') - # Check that the target type is binary if not type_of_target(y) == 'binary': warnings.warn('The target type should be binary.') @@ -293,9 +290,6 @@ def fit(self, X, y): super(BaseMulticlassSampler, self).fit(X, y) - if np.size(np.unique(y)) == 1: - warnings.warn('Hello') - # Check that the target type is either binary or multiclass if not (type_of_target(y) == 'binary' or type_of_target(y) == 'multiclass'): From c49c58021eeb721e179b683b3b4466e80e3ce324 Mon Sep 17 00:00:00 2001 From: Guillaume Lemaitre Date: Tue, 18 Oct 2016 22:22:11 +0200 Subject: [PATCH 14/16] try to force the raising --- imblearn/base.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/imblearn/base.py b/imblearn/base.py index d5099a9cc..af0c4bffd 100644 --- a/imblearn/base.py +++ b/imblearn/base.py @@ -14,9 +14,6 @@ from sklearn.utils import check_X_y from sklearn.utils.multiclass import type_of_target -logging.captureWarnings(False) -warnings.simplefilter('always', UserWarning) - class SamplerMixin(six.with_metaclass(ABCMeta, BaseEstimator)): @@ -87,6 +84,7 @@ def fit(self, X, y): self.logger.debug('Shall we raise a warning: %s', np.unique(y).size == 1) if np.unique(y).size == 1: + warnings.simplefilter('always', UserWarning) warnings.warn('Only one class detected, something will get wrong') self.logger.debug('The warning should has been raised.') @@ -257,6 +255,7 @@ def fit(self, X, y): # Check that the target type is binary if not type_of_target(y) == 'binary': + warnings.simplefilter('always', UserWarning) warnings.warn('The target type should be binary.') return self @@ -293,6 +292,7 @@ def fit(self, X, y): # Check that the target type is either binary or multiclass if not (type_of_target(y) == 'binary' or type_of_target(y) == 'multiclass'): + warnings.simplefilter('always', UserWarning) warnings.warn('The target type should be binary or multiclass.') return self From 4683b65feb2cffaa2ce1ebe77105d710536c0505 Mon Sep 17 00:00:00 2001 From: Guillaume Lemaitre Date: Tue, 18 Oct 2016 22:27:20 +0200 Subject: [PATCH 15/16] add the check estimator again --- imblearn/combine/tests/test_smote_enn.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/imblearn/combine/tests/test_smote_enn.py b/imblearn/combine/tests/test_smote_enn.py index 19c3f3ad3..e83c98b83 100644 --- a/imblearn/combine/tests/test_smote_enn.py +++ b/imblearn/combine/tests/test_smote_enn.py @@ -36,9 +36,9 @@ Y = np.array([0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0]) -# def test_senn_sk_estimator(): -# """Test the sklearn estimator compatibility""" -# check_estimator(SMOTEENN) +def test_senn_sk_estimator(): + """Test the sklearn estimator compatibility""" + check_estimator(SMOTEENN) def test_senn_bad_ratio(): From 8f859218996e56fba3185a499ed37831d3ce64a6 Mon Sep 17 00:00:00 2001 From: Guillaume Lemaitre Date: Tue, 18 Oct 2016 22:29:13 +0200 Subject: [PATCH 16/16] reset appveyor --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 54cff10bb..51f4d1563 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,7 +6,7 @@ environment: # We use miniconda versions of Python provided by appveyor windows images matrix: - PYTHON: "C:\\Miniconda-x64" - PYTHON_VERSION: "2.7.11" + PYTHON_VERSION: "2.7.x" PYTHON_ARCH: "64" - PYTHON: "C:\\Miniconda3-x64"