Skip to content

Commit 839df67

Browse files
committed
MAINT: cleanup deprecation warning in tests and source code (#466)
1 parent c0a4208 commit 839df67

36 files changed

+260
-156
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ matrix:
3535
- env: DISTRIB="conda" PYTHON_VERSION="2.7"
3636
NUMPY_VERSION="1.13.1" SCIPY_VERSION="0.19.1" SKLEARN_VERSION="0.20rc"
3737
- env: DISTRIB="conda" PYTHON_VERSION="3.6"
38-
NUMPY_VERSION="1.13.1" SCIPY_VERSION="0.19.1" SKLEARN_VERSION="0.20rc"
38+
NUMPY_VERSION="*" SCIPY_VERSION="*" SKLEARN_VERSION="0.20rc"
3939
- env: DISTRIB="conda" PYTHON_VERSION="3.7"
4040
NUMPY_VERSION="1.13.1" SCIPY_VERSION="0.19.1" SKLEARN_VERSION="0.20rc"
4141
- env: DISTRIB="conda" PYTHON_VERSION="3.7"

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ install:
4242
- activate testenv
4343
- conda install scipy numpy -y -q
4444
- pip install --pre scikit-learn
45-
- "conda install %OPTIONAL_DEP% -y -q"
45+
- conda install %OPTIONAL_DEP% -y -q
4646
- conda install pytest pytest-cov -y -q
4747
- pip install codecov
4848
- pip install .

build_tools/circle/build_doc.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,12 @@ conda update --yes --quiet conda
8888

8989
# Configure the conda environment and put it in the path using the
9090
# provided versions
91-
conda create -n $CONDA_ENV_NAME --yes --quiet python=3
91+
conda create -n $CONDA_ENV_NAME --yes --quiet python=3.6
9292
source activate $CONDA_ENV_NAME
9393

94-
conda install --yes pip numpy scipy scikit-learn pillow matplotlib sphinx \
94+
conda install --yes pip numpy scipy pillow matplotlib sphinx \
9595
sphinx_rtd_theme numpydoc pandas keras
96+
pip install --pre scikit-learn
9697
pip install -U git+https://github.com/sphinx-gallery/sphinx-gallery.git
9798

9899
# Build and install imbalanced-learn in dev mode

build_tools/travis/install.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ if [[ "$DISTRIB" == "conda" ]]; then
4040
source activate testenv
4141
conda install --yes numpy=$NUMPY_VERSION scipy=$SCIPY_VERSION
4242

43-
if [[ $PYTHON_VERSION == "3.7" ]]; then
44-
conda install --yes pandas
45-
conda install --yes -c conda-forge keras
43+
if [[ $PYTHON_VERSION == "3.6" ]]; then
44+
# Tensorflow is not available in Python 3.7 yet.
45+
conda install --yes pandas keras tensorflow
4646
KERAS_BACKEND=tensorflow
4747
python -c "import keras.backend"
4848
sed -i -e 's/"backend":[[:space:]]*"[^"]*/"backend":\ "'$KERAS_BACKEND'/g' ~/.keras/keras.json;

doc/ensemble.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ under-sampling the original set::
3232
>>> print(sorted(Counter(y).items()))
3333
[(0, 64), (1, 262), (2, 4674)]
3434
>>> from imblearn.ensemble import EasyEnsemble
35-
>>> ee = EasyEnsemble(random_state=0, n_subsets=10)
36-
>>> X_resampled, y_resampled = ee.fit_resample(X, y)
37-
>>> print(X_resampled.shape)
35+
>>> ee = EasyEnsemble(random_state=0, n_subsets=10) # doctest: +SKIP
36+
>>> X_resampled, y_resampled = ee.fit_resample(X, y) # doctest: +SKIP
37+
>>> print(X_resampled.shape) # doctest: +SKIP
3838
(10, 192, 2)
39-
>>> print(sorted(Counter(y_resampled[0]).items()))
39+
>>> print(sorted(Counter(y_resampled[0]).items())) # doctest: +SKIP
4040
[(0, 64), (1, 64), (2, 64)]
4141

4242
:class:`EasyEnsemble` has two important parameters: (i) ``n_subsets`` will be
@@ -53,7 +53,9 @@ parameter ``n_max_subset`` and an additional bootstraping can be activated with
5353
>>> from imblearn.ensemble import BalanceCascade
5454
>>> from sklearn.linear_model import LogisticRegression
5555
>>> bc = BalanceCascade(random_state=0,
56-
... estimator=LogisticRegression(random_state=0),
56+
... estimator=LogisticRegression(solver='lbfgs',
57+
... multi_class='auto',
58+
... random_state=0),
5759
... n_max_subset=4)
5860
>>> X_resampled, y_resampled = bc.fit_resample(X, y)
5961
>>> print(X_resampled.shape)

doc/under_sampling.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ used as::
340340
>>> oss = OneSidedSelection(random_state=0)
341341
>>> X_resampled, y_resampled = oss.fit_resample(X, y)
342342
>>> print(sorted(Counter(y_resampled).items()))
343-
[(0, 64), (1, 174), (2, 4403)]
343+
[(0, 64), (1, 174), (2, 4404)]
344344

345345
Our implementation offer to set the number of seeds to put in the set :math:`C`
346346
originally by setting the parameter ``n_seeds_S``.
@@ -379,7 +379,8 @@ removed. The class can be used as::
379379
>>> from sklearn.linear_model import LogisticRegression
380380
>>> from imblearn.under_sampling import InstanceHardnessThreshold
381381
>>> iht = InstanceHardnessThreshold(random_state=0,
382-
... estimator=LogisticRegression())
382+
... estimator=LogisticRegression(
383+
... solver='lbfgs', multi_class='auto'))
383384
>>> X_resampled, y_resampled = iht.fit_resample(X, y)
384385
>>> print(sorted(Counter(y_resampled).items()))
385386
[(0, 64), (1, 64), (2, 64)]

doc/whats_new/v0.0.4.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ Maintenance
9797
- Upgrade requirements to scikit-learn 0.20.
9898
:issue:`379` by :user:`Guillaume Lemaitre <glemaitre>`.
9999

100+
- Catch deprecation warning in testing.
101+
:issue:`441` by :user:`Guillaume Lemaitre <glemaitre>`.
102+
100103
Documentation
101104
.............
102105

examples/plot_outlier_rejections.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def plot_scatter(X, y, title):
3737
plt.legend()
3838
plt.title(title)
3939

40+
4041
##############################################################################
4142
# Toy data generation
4243
##############################################################################
@@ -82,11 +83,13 @@ def plot_scatter(X, y, title):
8283
# :class:`imblearn.FunctionSampler` will be called when using the method
8384
# ``fit_resample``.
8485

86+
8587
def outlier_rejection(X, y):
8688
"""This will be our function used to resample our dataset."""
8789
model = IsolationForest(max_samples=100,
8890
contamination=0.4,
89-
random_state=rng)
91+
random_state=rng,
92+
behaviour='new')
9093
model.fit(X)
9194
y_pred = model.predict(X)
9295
return X[y_pred == 1], y[y_pred == 1]
@@ -105,11 +108,12 @@ def outlier_rejection(X, y):
105108
# affected during the prediction.
106109

107110
pipe = make_pipeline(FunctionSampler(func=outlier_rejection),
108-
LogisticRegression(random_state=rng))
111+
LogisticRegression(solver='lbfgs', multi_class='auto',
112+
random_state=rng))
109113
y_pred = pipe.fit(X_train, y_train).predict(X_test)
110114
print(classification_report(y_test, y_pred))
111115

112-
clf = LogisticRegression(random_state=rng)
116+
clf = LogisticRegression(solver='lbfgs', multi_class='auto', random_state=rng)
113117
y_pred = clf.fit(X_train, y_train).predict(X_test)
114118
print(classification_report(y_test, y_pred))
115119

examples/under-sampling/plot_comparison_under_sampling.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,9 @@ def plot_decision_function(X, y, clf, ax):
235235
clf = LinearSVC().fit(X, y)
236236
plot_decision_function(X, y, clf, ax1)
237237
ax1.set_title('Linear SVC with y={}'.format(Counter(y)))
238-
sampler = InstanceHardnessThreshold(random_state=0,
239-
estimator=LogisticRegression())
238+
sampler = InstanceHardnessThreshold(
239+
random_state=0, estimator=LogisticRegression(solver='lbfgs',
240+
multi_class='auto'))
240241
clf = make_pipeline(sampler, LinearSVC())
241242
clf.fit(X, y)
242243
plot_decision_function(X, y, clf, ax2)

examples/under-sampling/plot_instance_hardness_threshold.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ def plot_resampling(ax, X, y, title):
6060
c0, c1 = plot_resampling(ax, X_vis, y, 'Original set')
6161
else:
6262
iht = InstanceHardnessThreshold(sampling_strategy=sampling_strategy,
63-
estimator=LogisticRegression(),
63+
estimator=LogisticRegression(
64+
solver='lbfgs',
65+
multi_class='auto'),
6466
return_indices=True)
6567
X_res, y_res, idx_res = iht.fit_resample(X, y)
6668
X_res_vis = pca.transform(X_res)

0 commit comments

Comments
 (0)