From fea271f7201eb7aba7a2c7995b5fad80a058a260 Mon Sep 17 00:00:00 2001 From: Guillaume Lemaitre Date: Tue, 28 May 2024 15:56:14 +0200 Subject: [PATCH 1/2] MAINT avoid warning deprecation sklearn 1.5 --- doc/under_sampling.rst | 3 +-- examples/applications/plot_outlier_rejections.py | 4 ++-- imblearn/ensemble/tests/test_bagging.py | 4 ++-- imblearn/tests/test_docstring_parameters.py | 5 ----- imblearn/tests/test_pipeline.py | 4 ++-- 5 files changed, 7 insertions(+), 13 deletions(-) diff --git a/doc/under_sampling.rst b/doc/under_sampling.rst index 499b5a3d9..8f8e7fbb8 100644 --- a/doc/under_sampling.rst +++ b/doc/under_sampling.rst @@ -497,8 +497,7 @@ The class can be used as:: >>> from sklearn.linear_model import LogisticRegression >>> from imblearn.under_sampling import InstanceHardnessThreshold >>> iht = InstanceHardnessThreshold(random_state=0, - ... estimator=LogisticRegression( - ... solver='lbfgs', multi_class='auto')) + ... estimator=LogisticRegression()) >>> X_resampled, y_resampled = iht.fit_resample(X, y) >>> print(sorted(Counter(y_resampled).items())) [(0, 64), (1, 64), (2, 64)] diff --git a/examples/applications/plot_outlier_rejections.py b/examples/applications/plot_outlier_rejections.py index 55f03e273..985b9211a 100644 --- a/examples/applications/plot_outlier_rejections.py +++ b/examples/applications/plot_outlier_rejections.py @@ -109,12 +109,12 @@ def outlier_rejection(X, y): pipe = make_pipeline( FunctionSampler(func=outlier_rejection), - LogisticRegression(solver="lbfgs", multi_class="auto", random_state=rng), + LogisticRegression(random_state=rng), ) y_pred = pipe.fit(X_train, y_train).predict(X_test) print(classification_report(y_test, y_pred)) -clf = LogisticRegression(solver="lbfgs", multi_class="auto", random_state=rng) +clf = LogisticRegression(random_state=rng) y_pred = clf.fit(X_train, y_train).predict(X_test) print(classification_report(y_test, y_pred)) diff --git a/imblearn/ensemble/tests/test_bagging.py b/imblearn/ensemble/tests/test_bagging.py index 5705de553..382597183 100644 --- a/imblearn/ensemble/tests/test_bagging.py +++ b/imblearn/ensemble/tests/test_bagging.py @@ -174,7 +174,7 @@ def test_probability(): # Degenerate case, where some classes are missing ensemble = BalancedBaggingClassifier( - estimator=LogisticRegression(solver="lbfgs", multi_class="auto"), + estimator=LogisticRegression(solver="lbfgs"), random_state=0, max_samples=5, ) @@ -435,7 +435,7 @@ def test_estimators_samples(): # remap the y outside of the BalancedBaggingclassifier # _, y = np.unique(y, return_inverse=True) bagging = BalancedBaggingClassifier( - LogisticRegression(solver="lbfgs", multi_class="auto"), + LogisticRegression(), max_samples=0.5, max_features=0.5, random_state=1, diff --git a/imblearn/tests/test_docstring_parameters.py b/imblearn/tests/test_docstring_parameters.py index b595d77d7..1bd6ecf51 100644 --- a/imblearn/tests/test_docstring_parameters.py +++ b/imblearn/tests/test_docstring_parameters.py @@ -11,7 +11,6 @@ import pytest from sklearn.datasets import make_classification from sklearn.linear_model import LogisticRegression -from sklearn.utils import IS_PYPY from sklearn.utils._testing import ( _get_func_name, check_docstring_parameters, @@ -70,7 +69,6 @@ # Python 3.7 @pytest.mark.filterwarnings("ignore::FutureWarning") @pytest.mark.filterwarnings("ignore::DeprecationWarning") -@pytest.mark.skipif(IS_PYPY, reason="test segfaults on PyPy") def test_docstring_parameters(): # Test module docstring formatting @@ -154,9 +152,6 @@ def test_tabs(): for importer, modname, ispkg in walk_packages( imblearn.__path__, prefix="imblearn." ): - if IS_PYPY: - continue - # because we don't import mod = importlib.import_module(modname) diff --git a/imblearn/tests/test_pipeline.py b/imblearn/tests/test_pipeline.py index 409dbce41..d89e03a11 100644 --- a/imblearn/tests/test_pipeline.py +++ b/imblearn/tests/test_pipeline.py @@ -272,7 +272,7 @@ def test_pipeline_methods_anova(): X = iris.data y = iris.target # Test with Anova + LogisticRegression - clf = LogisticRegression(solver="lbfgs", multi_class="auto") + clf = LogisticRegression() filter1 = SelectKBest(f_classif, k=2) pipe = Pipeline([("anova", filter1), ("logistic", clf)]) pipe.fit(X, y) @@ -639,7 +639,7 @@ def test_classes_property(): clf = make_pipeline( SelectKBest(k=1), - LogisticRegression(solver="lbfgs", multi_class="auto", random_state=0), + LogisticRegression(), ) with raises(AttributeError): getattr(clf, "classes_") From b31fa5b3c557465b1485dd7a95cfe51d87af2847 Mon Sep 17 00:00:00 2001 From: Guillaume Lemaitre Date: Tue, 28 May 2024 15:58:06 +0200 Subject: [PATCH 2/2] update documentation --- doc/whats_new/v0.12.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/whats_new/v0.12.rst b/doc/whats_new/v0.12.rst index 4a96de92c..fd95a4fb8 100644 --- a/doc/whats_new/v0.12.rst +++ b/doc/whats_new/v0.12.rst @@ -12,7 +12,7 @@ Compatibility ............. - Compatibility with scikit-learn 1.5 - :pr:`1074` by :user:`Guillaume Lemaitre `. + :pr:`1074` and :pr:`1084` by :user:`Guillaume Lemaitre `. Version 0.12.2 ==============