From 6fc2a37cc98c60de7c09eb17a107a7b7e8d9e852 Mon Sep 17 00:00:00 2001 From: Guillaume Lemaitre Date: Sun, 1 Jan 2017 13:44:43 +0100 Subject: [PATCH 1/9] change the way to check the version --- imblearn/metrics/tests/test_score_objects.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/imblearn/metrics/tests/test_score_objects.py b/imblearn/metrics/tests/test_score_objects.py index 65a28cc98..608beed4b 100644 --- a/imblearn/metrics/tests/test_score_objects.py +++ b/imblearn/metrics/tests/test_score_objects.py @@ -10,8 +10,8 @@ geometric_mean_score, make_index_balanced_accuracy) # Get the version -(major, minor, _) = sklearn.__version__.split('.') -if int(minor) < 18: +sk_version = sklearn.__version__ +if sk_version < '0.18': from sklearn.cross_validation import train_test_split from sklearn.grid_search import GridSearchCV else: From f5d012f967412470dc8fddfc5e1647cfcb567454 Mon Sep 17 00:00:00 2001 From: Guillaume Lemaitre Date: Sun, 1 Jan 2017 14:03:39 +0100 Subject: [PATCH 2/9] Force the version of the dependencies --- .travis.yml | 6 +++--- build_tools/travis/install.sh | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4567b167d..de8e463ed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,13 +29,13 @@ env: matrix: # This environment tests the using anaconda - DISTRIB="conda" PYTHON_VERSION="2.7" COVERAGE="true" - NUMPY_VERSION="1.9.3" SCIPY_VERSION="0.16.0" + NUMPY_VERSION="1.10.4" SCIPY_VERSION="0.17.1" SKLEARN_VERSION="0.18.1" - DISTRIB="conda" PYTHON_VERSION="3.5" COVERAGE="true" - NUMPY_VERSION="1.10.4" SCIPY_VERSION="0.17.0" + NUMPY_VERSION="1.10.4" SCIPY_VERSION="0.17.1" SKLEARN_VERSION="0.18.1" # flake8 linting on diff wrt common ancestor with upstream/master - RUN_FLAKE8="true" SKIP_TESTS="true" DISTRIB="conda" PYTHON_VERSION="3.5" - NUMPY_VERSION="1.10.4" SCIPY_VERSION="0.17.0" + NUMPY_VERSION="1.10.4" SCIPY_VERSION="0.17.0" SKLEARN_VERSION="0.18.1" install: source build_tools/travis/install.sh script: bash build_tools/travis/test_script.sh diff --git a/build_tools/travis/install.sh b/build_tools/travis/install.sh index 938d703f4..a3221afc8 100644 --- a/build_tools/travis/install.sh +++ b/build_tools/travis/install.sh @@ -25,18 +25,18 @@ popd # Configure the conda environment and put it in the path using the # provided versions conda create -n testenv --yes python=$PYTHON_VERSION pip nose \ - numpy=$NUMPY_VERSION scipy=$SCIPY_VERSION \ + numpy=$NUMPY_VERSION scipy=$SCIPY_VERSION scikit-learn=$SKLEARN_VERSION \ libgfortran nomkl flake8 -#source activate testenv +source activate testenv # Install nose-timer via pip pip install nose-timer -# Install libgfortran with conda -conda install --yes libgfortran \ - numpy=1.10.4 scipy=0.17.1 \ - scikit-learn=0.17.1 \ - six=1.10.0 +# # Install libgfortran with conda +# conda install --yes libgfortran \ +# numpy=1.10.4 scipy=0.17.1 \ +# scikit-learn=0.17.1 \ +# six=1.10.0 if [[ "$COVERAGE" == "true" ]]; then pip install coverage coveralls From 9a86b69a6cd3628831af2a7c65a76e36a1ce27b0 Mon Sep 17 00:00:00 2001 From: Guillaume Lemaitre Date: Sun, 1 Jan 2017 14:14:21 +0100 Subject: [PATCH 3/9] update travis --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index de8e463ed..9c70cc38b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,13 +29,13 @@ env: matrix: # This environment tests the using anaconda - DISTRIB="conda" PYTHON_VERSION="2.7" COVERAGE="true" - NUMPY_VERSION="1.10.4" SCIPY_VERSION="0.17.1" SKLEARN_VERSION="0.18.1" + NUMPY_VERSION="1.11.2" SCIPY_VERSION="0.18.1" SKLEARN_VERSION="0.18.1" - DISTRIB="conda" PYTHON_VERSION="3.5" COVERAGE="true" - NUMPY_VERSION="1.10.4" SCIPY_VERSION="0.17.1" SKLEARN_VERSION="0.18.1" + NUMPY_VERSION="1.11.2" SCIPY_VERSION="0.18.1" SKLEARN_VERSION="0.18.1" # flake8 linting on diff wrt common ancestor with upstream/master - RUN_FLAKE8="true" SKIP_TESTS="true" DISTRIB="conda" PYTHON_VERSION="3.5" - NUMPY_VERSION="1.10.4" SCIPY_VERSION="0.17.0" SKLEARN_VERSION="0.18.1" + NUMPY_VERSION="1.11.2" SCIPY_VERSION="0.18.1" SKLEARN_VERSION="0.18.1" install: source build_tools/travis/install.sh script: bash build_tools/travis/test_script.sh From 64ff42b9ed6fe8e3900d443451f0d6b083a5bb41 Mon Sep 17 00:00:00 2001 From: Guillaume Lemaitre Date: Sun, 1 Jan 2017 14:19:15 +0100 Subject: [PATCH 4/9] remove last dependency --- imblearn/ensemble/balance_cascade.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/imblearn/ensemble/balance_cascade.py b/imblearn/ensemble/balance_cascade.py index edc33574f..14d70a302 100644 --- a/imblearn/ensemble/balance_cascade.py +++ b/imblearn/ensemble/balance_cascade.py @@ -9,8 +9,7 @@ from sklearn.neighbors import KNeighborsClassifier from sklearn.utils import check_random_state from sklearn.utils.validation import has_fit_parameter - -from six import string_types +from sklearn.externals.six import string_types from ..base import BaseBinarySampler From d50e72338165129bcc69f81b6b2496c81adda059 Mon Sep 17 00:00:00 2001 From: Guillaume Lemaitre Date: Sun, 1 Jan 2017 14:21:07 +0100 Subject: [PATCH 5/9] Update appveyor version --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 51f4d1563..29a855532 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -24,7 +24,7 @@ install: - "python -c \"import struct; print(struct.calcsize('P') * 8)\"" # Installed prebuilt dependencies from conda - - "conda install pip numpy scipy scikit-learn nose wheel matplotlib -y -q" + - "conda install pip numpy=1.11.2 scipy=0.18.1 scikit-learn=0.18.1 nose wheel matplotlib -y -q" # Install other nilearn dependencies - "pip install coverage nose-timer" From 773d31007e2dbec2c1d9ad44ac601be6f85613aa Mon Sep 17 00:00:00 2001 From: Guillaume Lemaitre Date: Sun, 1 Jan 2017 14:35:19 +0100 Subject: [PATCH 6/9] Update doc string --- imblearn/combine/smote_enn.py | 2 +- imblearn/over_sampling/adasyn.py | 2 +- imblearn/pipeline.py | 6 +++--- imblearn/under_sampling/edited_nearest_neighbours.py | 6 +++--- imblearn/under_sampling/instance_hardness_threshold.py | 9 ++++----- imblearn/under_sampling/neighbourhood_cleaning_rule.py | 2 +- imblearn/under_sampling/one_sided_selection.py | 2 +- 7 files changed, 14 insertions(+), 15 deletions(-) diff --git a/imblearn/combine/smote_enn.py b/imblearn/combine/smote_enn.py index c48c8970c..f3e526106 100644 --- a/imblearn/combine/smote_enn.py +++ b/imblearn/combine/smote_enn.py @@ -128,7 +128,7 @@ class SMOTEENN(BaseBinarySampler): >>> sme = SMOTEENN(random_state=42) >>> X_res, y_res = sme.fit_sample(X, y) >>> print('Resampled dataset shape {}'.format(Counter(y_res))) - Resampled dataset shape Counter({0: 900, 1: 865}) + Resampled dataset shape Counter({0: 900, 1: 881}) References ---------- diff --git a/imblearn/over_sampling/adasyn.py b/imblearn/over_sampling/adasyn.py index 833d7a1eb..72f62dfd5 100644 --- a/imblearn/over_sampling/adasyn.py +++ b/imblearn/over_sampling/adasyn.py @@ -84,7 +84,7 @@ class ADASYN(BaseBinarySampler): >>> ada = ADASYN(random_state=42) >>> X_res, y_res = ada.fit_sample(X, y) >>> print('Resampled dataset shape {}'.format(Counter(y_res))) - Resampled dataset shape Counter({0: 909, 1: 900}) + Resampled dataset shape Counter({0: 904, 1: 900}) References ---------- diff --git a/imblearn/pipeline.py b/imblearn/pipeline.py index 303a7c7a1..a13d0d237 100644 --- a/imblearn/pipeline.py +++ b/imblearn/pipeline.py @@ -103,10 +103,10 @@ class Pipeline(pipeline.Pipeline): >>> print(classification_report(y_test, y_hat)) precision recall f1-score support - 0 0.71 1.00 0.83 24 - 1 1.00 0.96 0.98 226 + 0 0.87 1.00 0.93 26 + 1 1.00 0.98 0.99 224 - avg / total 0.97 0.96 0.96 250 + avg / total 0.99 0.98 0.98 250 """ diff --git a/imblearn/under_sampling/edited_nearest_neighbours.py b/imblearn/under_sampling/edited_nearest_neighbours.py index 244469a91..9c450b4ff 100644 --- a/imblearn/under_sampling/edited_nearest_neighbours.py +++ b/imblearn/under_sampling/edited_nearest_neighbours.py @@ -91,7 +91,7 @@ class EditedNearestNeighbours(BaseMulticlassSampler): >>> enn = EditedNearestNeighbours(random_state=42) >>> X_res, y_res = enn.fit_sample(X, y) >>> print('Resampled dataset shape {}'.format(Counter(y_res))) - Resampled dataset shape Counter({1: 883, 0: 100}) + Resampled dataset shape Counter({1: 887, 0: 100}) References ---------- @@ -331,7 +331,7 @@ class RepeatedEditedNearestNeighbours(BaseMulticlassSampler): >>> renn = RepeatedEditedNearestNeighbours(random_state=42) >>> X_res, y_res = renn.fit_sample(X, y) >>> print('Resampled dataset shape {}'.format(Counter(y_res))) - Resampled dataset shape Counter({1: 883, 0: 100}) + Resampled dataset shape Counter({1: 887, 0: 100}) References ---------- @@ -576,7 +576,7 @@ class AllKNN(BaseMulticlassSampler): >>> allknn = AllKNN(random_state=42) >>> X_res, y_res = allknn.fit_sample(X, y) >>> print('Resampled dataset shape {}'.format(Counter(y_res))) - Resampled dataset shape Counter({1: 883, 0: 100}) + Resampled dataset shape Counter({1: 887, 0: 100}) References ---------- diff --git a/imblearn/under_sampling/instance_hardness_threshold.py b/imblearn/under_sampling/instance_hardness_threshold.py index 5d53c1285..16967a1eb 100644 --- a/imblearn/under_sampling/instance_hardness_threshold.py +++ b/imblearn/under_sampling/instance_hardness_threshold.py @@ -103,17 +103,16 @@ class InstanceHardnessThreshold(BaseBinarySampler): >>> from collections import Counter >>> from sklearn.datasets import make_classification - >>> from imblearn.under_sampling import \ - RepeatedEditedNearestNeighbours # doctest: +NORMALIZE_WHITESPACE + >>> from imblearn.under_sampling import InstanceHardnessThreshold >>> X, y = make_classification(n_classes=2, class_sep=2, ... weights=[0.1, 0.9], n_informative=3, n_redundant=1, flip_y=0, ... n_features=20, n_clusters_per_class=1, n_samples=1000, random_state=10) >>> print('Original dataset shape {}'.format(Counter(y))) Original dataset shape Counter({1: 900, 0: 100}) - >>> renn = RepeatedEditedNearestNeighbours(random_state=42) - >>> X_res, y_res = renn.fit_sample(X, y) + >>> iht = InstanceHardnessThreshold(random_state=42) + >>> X_res, y_res = iht.fit_sample(X, y) >>> print('Resampled dataset shape {}'.format(Counter(y_res))) - Resampled dataset shape Counter({1: 883, 0: 100}) + Resampled dataset shape Counter({1: 811, 0: 100}) References ---------- diff --git a/imblearn/under_sampling/neighbourhood_cleaning_rule.py b/imblearn/under_sampling/neighbourhood_cleaning_rule.py index 843813aff..1a725b851 100644 --- a/imblearn/under_sampling/neighbourhood_cleaning_rule.py +++ b/imblearn/under_sampling/neighbourhood_cleaning_rule.py @@ -77,7 +77,7 @@ class NeighbourhoodCleaningRule(BaseMulticlassSampler): >>> ncr = NeighbourhoodCleaningRule(random_state=42) >>> X_res, y_res = ncr.fit_sample(X, y) >>> print('Resampled dataset shape {}'.format(Counter(y_res))) - Resampled dataset shape Counter({1: 884, 0: 100}) + Resampled dataset shape Counter({1: 891, 0: 100}) References ---------- diff --git a/imblearn/under_sampling/one_sided_selection.py b/imblearn/under_sampling/one_sided_selection.py index 55dd1266c..e8303620e 100644 --- a/imblearn/under_sampling/one_sided_selection.py +++ b/imblearn/under_sampling/one_sided_selection.py @@ -82,7 +82,7 @@ class OneSidedSelection(BaseBinarySampler): >>> oss = OneSidedSelection(random_state=42) >>> X_res, y_res = oss.fit_sample(X, y) >>> print('Resampled dataset shape {}'.format(Counter(y_res))) - Resampled dataset shape Counter({1: 595, 0: 100}) + Resampled dataset shape Counter({1: 496, 0: 100}) References ---------- From 29832cde757a1756af7bedbb6acb2f3a04228d64 Mon Sep 17 00:00:00 2001 From: Guillaume Lemaitre Date: Sun, 1 Jan 2017 14:42:49 +0100 Subject: [PATCH 7/9] Fix doctest --- imblearn/under_sampling/instance_hardness_threshold.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imblearn/under_sampling/instance_hardness_threshold.py b/imblearn/under_sampling/instance_hardness_threshold.py index 16967a1eb..91a9074a4 100644 --- a/imblearn/under_sampling/instance_hardness_threshold.py +++ b/imblearn/under_sampling/instance_hardness_threshold.py @@ -112,7 +112,7 @@ class InstanceHardnessThreshold(BaseBinarySampler): >>> iht = InstanceHardnessThreshold(random_state=42) >>> X_res, y_res = iht.fit_sample(X, y) >>> print('Resampled dataset shape {}'.format(Counter(y_res))) - Resampled dataset shape Counter({1: 811, 0: 100}) + Resampled dataset shape Counter({1: 840, 0: 100}) References ---------- From 4269197d8bbb53bc3d78ad79cabd57468de5b192 Mon Sep 17 00:00:00 2001 From: Guillaume Lemaitre Date: Sun, 1 Jan 2017 14:52:05 +0100 Subject: [PATCH 8/9] trying to use conda-forge --- build_tools/travis/install.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/build_tools/travis/install.sh b/build_tools/travis/install.sh index a3221afc8..c8ea00474 100644 --- a/build_tools/travis/install.sh +++ b/build_tools/travis/install.sh @@ -24,11 +24,15 @@ popd # Configure the conda environment and put it in the path using the # provided versions -conda create -n testenv --yes python=$PYTHON_VERSION pip nose \ - numpy=$NUMPY_VERSION scipy=$SCIPY_VERSION scikit-learn=$SKLEARN_VERSION \ - libgfortran nomkl flake8 +conda create -n testenv --yes python=$PYTHON_VERSION pip nose mkl + # numpy=$NUMPY_VERSION scipy=$SCIPY_VERSION scikit-learn=$SKLEARN_VERSION \ + # libgfortran nomkl source activate testenv +conda install --yes openblas blas numpy=$NUMPY_VERSION scipy=$SCIPY_VERSION \ + scikit-learn -c conda-forge + + # Install nose-timer via pip pip install nose-timer From 99fd0d4e8bfcd8ce4775fbb58a86c94f4648194f Mon Sep 17 00:00:00 2001 From: Guillaume Lemaitre Date: Sun, 1 Jan 2017 16:28:04 +0100 Subject: [PATCH 9/9] Fix the test --- build_tools/travis/install.sh | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/build_tools/travis/install.sh b/build_tools/travis/install.sh index c8ea00474..a6667fcc0 100644 --- a/build_tools/travis/install.sh +++ b/build_tools/travis/install.sh @@ -24,24 +24,17 @@ popd # Configure the conda environment and put it in the path using the # provided versions -conda create -n testenv --yes python=$PYTHON_VERSION pip nose mkl - # numpy=$NUMPY_VERSION scipy=$SCIPY_VERSION scikit-learn=$SKLEARN_VERSION \ - # libgfortran nomkl +conda create -n testenv --yes python=$PYTHON_VERSION pip nose + numpy=$NUMPY_VERSION scipy=$SCIPY_VERSION \ + libgfortran nomkl source activate testenv -conda install --yes openblas blas numpy=$NUMPY_VERSION scipy=$SCIPY_VERSION \ - scikit-learn -c conda-forge - +# Install scikit-learn +conda install --yes scikit-learn=$SKLEARN_VERSION # Install nose-timer via pip pip install nose-timer -# # Install libgfortran with conda -# conda install --yes libgfortran \ -# numpy=1.10.4 scipy=0.17.1 \ -# scikit-learn=0.17.1 \ -# six=1.10.0 - if [[ "$COVERAGE" == "true" ]]; then pip install coverage coveralls fi