diff --git a/imblearn/ensemble/_easy_ensemble.py b/imblearn/ensemble/_easy_ensemble.py index 29f0095f2..2211f5cc1 100644 --- a/imblearn/ensemble/_easy_ensemble.py +++ b/imblearn/ensemble/_easy_ensemble.py @@ -5,6 +5,7 @@ # License: MIT import copy +import inspect import numbers import numpy as np @@ -13,7 +14,6 @@ from sklearn.ensemble._bagging import _parallel_decision_function from sklearn.ensemble._base import _partition_estimators from sklearn.utils._param_validation import Interval, StrOptions -from sklearn.utils._tags import _safe_tags from sklearn.utils.fixes import parse_version from sklearn.utils.metaestimators import available_if from sklearn.utils.parallel import Parallel, delayed @@ -312,11 +312,16 @@ def decision_function(self, X): # Parallel loop n_jobs, _, starts = _partition_estimators(self.n_estimators, self.n_jobs) + kwargs = {} + if "params" in inspect.signature(_parallel_decision_function).parameters: + kwargs["params"] = {} + all_decisions = Parallel(n_jobs=n_jobs, verbose=self.verbose)( delayed(_parallel_decision_function)( self.estimators_[starts[i] : starts[i + 1]], self.estimators_features_[starts[i] : starts[i + 1]], X, + **kwargs, ) for i in range(n_jobs) ) @@ -343,7 +348,7 @@ def _get_estimator(self): return self.estimator def _more_tags(self): - return {"allow_nan": _safe_tags(self._get_estimator(), "allow_nan")} + return {"allow_nan": get_tags(self._get_estimator()).input_tags.allow_nan} def __sklearn_tags__(self): tags = super().__sklearn_tags__() diff --git a/imblearn/metrics/tests/test_classification.py b/imblearn/metrics/tests/test_classification.py index 26d6be0ad..4dbd18e06 100644 --- a/imblearn/metrics/tests/test_classification.py +++ b/imblearn/metrics/tests/test_classification.py @@ -454,7 +454,7 @@ def test_iba_error_y_score_prob_error(score_loss): y_true, y_pred, _ = make_prediction(binary=True) aps = make_index_balanced_accuracy(alpha=0.5, squared=True)(score_loss) - with pytest.raises(AttributeError): + with pytest.raises((AttributeError, TypeError)): aps(y_true, y_pred) diff --git a/imblearn/over_sampling/_smote/base.py b/imblearn/over_sampling/_smote/base.py index 7a6abbd2d..c008a95e6 100644 --- a/imblearn/over_sampling/_smote/base.py +++ b/imblearn/over_sampling/_smote/base.py @@ -981,6 +981,5 @@ def _more_tags(self): def __sklearn_tags__(self): tags = super().__sklearn_tags__() - tags.input_tags.sparse = False tags.input_tags.string = True return tags diff --git a/imblearn/tests/test_pipeline.py b/imblearn/tests/test_pipeline.py index b9c6f9df3..d017b4e86 100644 --- a/imblearn/tests/test_pipeline.py +++ b/imblearn/tests/test_pipeline.py @@ -39,7 +39,7 @@ from imblearn.pipeline import Pipeline, make_pipeline from imblearn.under_sampling import EditedNearestNeighbours as ENN from imblearn.under_sampling import RandomUnderSampler -from imblearn.utils._sklearn_compat import sklearn_version +from imblearn.utils._sklearn_compat import Tags, sklearn_version from imblearn.utils.estimator_checks import check_param_validation JUNK_FOOD_DOCS = ( @@ -61,6 +61,9 @@ def __init__(self, a=None, b=None): self.a = a self.b = b + def __sklearn_tags__(self): + return Tags() + class NoTrans(NoFit): def fit(self, X, y):