Skip to content

Commit b224f6d

Browse files
authored
MAINT add compatibilty for sklearn 1.0 (#949)
1 parent 8e767d2 commit b224f6d

31 files changed

+327
-84
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
.. |PythonMinVersion| replace:: 3.8
3131
.. |NumPyMinVersion| replace:: 1.17.3
3232
.. |SciPyMinVersion| replace:: 1.3.2
33-
.. |ScikitLearnMinVersion| replace:: 1.1.3
33+
.. |ScikitLearnMinVersion| replace:: 1.0.2
3434
.. |MatplotlibMinVersion| replace:: 3.1.2
3535
.. |PandasMinVersion| replace:: 1.0.5
3636
.. |TensorflowMinVersion| replace:: 2.4.3

azure-pipelines.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ jobs:
158158
# Linux environment to test the latest available dependencies and MKL.
159159
pylatest_pip_openblas_pandas:
160160
DISTRIB: 'conda-pip-latest'
161-
PYTHON_VERSION: '3.9'
161+
PYTHON_VERSION: '*'
162162
TEST_DOCS: 'true'
163163
TEST_DOCSTRINGS: 'true'
164164
CHECK_WARNINGS: 'true'
@@ -185,7 +185,7 @@ jobs:
185185
TENSORFLOW_VERSION: 'min'
186186
TEST_DOCS: 'true'
187187
TEST_DOCSTRINGS: 'false' # it is going to fail because of scikit-learn inheritance
188-
CHECK_WARNINGS: 'true'
188+
CHECK_WARNINGS: 'false' # in case the older version raise some FutureWarnings
189189
pylatest_pip_keras:
190190
DISTRIB: 'conda-pip-latest-keras'
191191
CONDA_CHANNEL: 'conda-forge'
@@ -209,7 +209,7 @@ jobs:
209209
KERAS_VERSION: 'min'
210210
TEST_DOCS: 'true'
211211
TEST_DOCSTRINGS: 'false' # it is going to fail because of scikit-learn inheritance
212-
CHECK_WARNINGS: 'true'
212+
CHECK_WARNINGS: 'false' # in case the older version raise some FutureWarnings
213213

214214
# Currently runs on Python 3.8 while only Python 3.7 available
215215
# - template: build_tools/azure/posix-docker.yml

build_tools/azure/posix-docker.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ jobs:
3030
THREADPOOLCTL_VERSION: 'latest'
3131
COVERAGE: 'false'
3232
TEST_DOCSTRINGS: 'false'
33+
CHECK_WARNINGS: 'false'
3334
BLAS: 'openblas'
3435
# Set in azure-pipelines.yml
3536
DISTRIB: ''

build_tools/azure/posix.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ jobs:
3636
COVERAGE: 'true'
3737
TEST_DOCS: 'false'
3838
TEST_DOCSTRINGS: 'false'
39+
CHECK_WARNINGS: 'false'
3940
SHOW_SHORT_SUMMARY: 'false'
4041
strategy:
4142
matrix:

build_tools/azure/test_script.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ if [[ "$COVERAGE" == "true" ]]; then
3434
TEST_CMD="$TEST_CMD --cov-config='$COVERAGE_PROCESS_START' --cov imblearn --cov-report="
3535
fi
3636

37-
if [[ -n "$CHECK_WARNINGS" ]]; then
37+
if [[ "$CHECK_WARNINGS" == "true" ]]; then
3838
# numpy's 1.19.0's tostring() deprecation is ignored until scipy and joblib removes its usage
3939
TEST_CMD="$TEST_CMD -Werror::DeprecationWarning -Werror::FutureWarning -Wignore:tostring:DeprecationWarning"
4040

build_tools/azure/windows.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
PYTEST_XDIST_VERSION: 'latest'
2222
TEST_DIR: '$(Agent.WorkFolder)/tmp_folder'
2323
CPU_COUNT: '2'
24+
CHECK_WARNINGS: 'false'
2425
strategy:
2526
matrix:
2627
${{ insert }}: ${{ parameters.matrix }}

doc/ensemble.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ data set, this classifier will favor the majority classes::
3838
>>> bc.fit(X_train, y_train) #doctest:
3939
BaggingClassifier(...)
4040
>>> y_pred = bc.predict(X_test)
41-
>>> balanced_accuracy_score(y_test, y_pred) # doctest:
41+
>>> balanced_accuracy_score(y_test, y_pred)
4242
0.77...
4343

4444
In :class:`BalancedBaggingClassifier`, each bootstrap sample will be further
@@ -54,10 +54,10 @@ sampling is controlled by the parameter `sampler` or the two parameters
5454
... sampling_strategy='auto',
5555
... replacement=False,
5656
... random_state=0)
57-
>>> bbc.fit(X_train, y_train) # doctest:
57+
>>> bbc.fit(X_train, y_train)
5858
BalancedBaggingClassifier(...)
5959
>>> y_pred = bbc.predict(X_test)
60-
>>> balanced_accuracy_score(y_test, y_pred) # doctest:
60+
>>> balanced_accuracy_score(y_test, y_pred)
6161
0.8...
6262

6363
Changing the `sampler` will give rise to different known implementation
@@ -78,10 +78,10 @@ each tree of the forest will be provided a balanced bootstrap sample
7878

7979
>>> from imblearn.ensemble import BalancedRandomForestClassifier
8080
>>> brf = BalancedRandomForestClassifier(n_estimators=100, random_state=0)
81-
>>> brf.fit(X_train, y_train) # doctest:
81+
>>> brf.fit(X_train, y_train)
8282
BalancedRandomForestClassifier(...)
8383
>>> y_pred = brf.predict(X_test)
84-
>>> balanced_accuracy_score(y_test, y_pred) # doctest:
84+
>>> balanced_accuracy_score(y_test, y_pred)
8585
0.8...
8686

8787
.. _boosting:
@@ -97,10 +97,10 @@ a boosting iteration :cite:`seiffert2009rusboost`::
9797
>>> from imblearn.ensemble import RUSBoostClassifier
9898
>>> rusboost = RUSBoostClassifier(n_estimators=200, algorithm='SAMME.R',
9999
... random_state=0)
100-
>>> rusboost.fit(X_train, y_train) # doctest:
100+
>>> rusboost.fit(X_train, y_train)
101101
RUSBoostClassifier(...)
102102
>>> y_pred = rusboost.predict(X_test)
103-
>>> balanced_accuracy_score(y_test, y_pred) # doctest:
103+
>>> balanced_accuracy_score(y_test, y_pred)
104104
0...
105105

106106
A specific method which uses :class:`~sklearn.ensemble.AdaBoostClassifier` as
@@ -111,10 +111,10 @@ the :class:`BalancedBaggingClassifier` API, one can construct the ensemble as::
111111

112112
>>> from imblearn.ensemble import EasyEnsembleClassifier
113113
>>> eec = EasyEnsembleClassifier(random_state=0)
114-
>>> eec.fit(X_train, y_train) # doctest:
114+
>>> eec.fit(X_train, y_train)
115115
EasyEnsembleClassifier(...)
116116
>>> y_pred = eec.predict(X_test)
117-
>>> balanced_accuracy_score(y_test, y_pred) # doctest:
117+
>>> balanced_accuracy_score(y_test, y_pred)
118118
0.6...
119119

120120
.. topic:: Examples

imblearn/_min_dependencies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
NUMPY_MIN_VERSION = "1.17.3"
55
SCIPY_MIN_VERSION = "1.3.2"
66
PANDAS_MIN_VERSION = "1.0.5"
7-
SKLEARN_MIN_VERSION = "1.1.3"
7+
SKLEARN_MIN_VERSION = "1.0.2"
88
TENSORFLOW_MIN_VERSION = "2.4.3"
99
KERAS_MIN_VERSION = "2.4.3"
1010
JOBLIB_MIN_VERSION = "1.1.1"

imblearn/combine/_smote_enn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class SMOTEENN(BaseSampler):
8989
9090
>>> from collections import Counter
9191
>>> from sklearn.datasets import make_classification
92-
>>> from imblearn.combine import SMOTEENN # doctest:
92+
>>> from imblearn.combine import SMOTEENN
9393
>>> X, y = make_classification(n_classes=2, class_sep=2,
9494
... weights=[0.1, 0.9], n_informative=3, n_redundant=1, flip_y=0,
9595
... n_features=20, n_clusters_per_class=1, n_samples=1000, random_state=10)

imblearn/combine/_smote_tomek.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ class SMOTETomek(BaseSampler):
8787
8888
>>> from collections import Counter
8989
>>> from sklearn.datasets import make_classification
90-
>>> from imblearn.combine import \
91-
SMOTETomek # doctest:
90+
>>> from imblearn.combine import SMOTETomek
9291
>>> X, y = make_classification(n_classes=2, class_sep=2,
9392
... weights=[0.1, 0.9], n_informative=3, n_redundant=1, flip_y=0,
9493
... n_features=20, n_clusters_per_class=1, n_samples=1000, random_state=10)

0 commit comments

Comments
 (0)