Skip to content

Commit 468f925

Browse files
committed
iter
1 parent 8903b00 commit 468f925

File tree

5 files changed

+30
-19
lines changed

5 files changed

+30
-19
lines changed

imblearn/ensemble/_weight_boosting.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import copy
22
import numbers
3+
import warnings
34
from copy import deepcopy
45

56
import numpy as np
@@ -68,9 +69,6 @@ class RUSBoostClassifier(_ParamsValidationMixin, AdaBoostClassifier):
6869
6970
.. deprecated:: 0.12
7071
`algorithm` is deprecated in 0.12 and will be removed 0.14.
71-
Depending on the `scikit-learn` version, the "SAMME.R" algorithm might not
72-
be available. Refer to the documentation of
73-
:class:`~sklearn.ensemble.AdaBoostClassifier` for more information.
7472
7573
{sampling_strategy}
7674
@@ -403,6 +401,12 @@ def _boost_discrete(self, iboost, X, y, sample_weight, random_state):
403401
return sample_weight, estimator_weight, estimator_error
404402

405403
def _boost(self, iboost, X, y, sample_weight, random_state):
404+
if self.algorithm != "deprecated":
405+
warnings.warn(
406+
"`algorithm` parameter is deprecated in 0.12 and will be removed in "
407+
"0.14. In the future, the SAMME algorithm will always be used.",
408+
FutureWarning,
409+
)
406410
if self.algorithm == "SAMME.R":
407411
return self._boost_real(iboost, X, y, sample_weight, random_state)
408412

imblearn/ensemble/tests/test_weight_boosting.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def imbalanced_dataset():
2424

2525

2626
@pytest.mark.parametrize("algorithm", ["SAMME", "SAMME.R"])
27-
@pytest.mark.filterwarnings("ignore:The SAMME.R algorithm (the default) is")
27+
@pytest.mark.filterwarnings("ignore:`algorithm` parameter is deprecated in 0.12")
2828
def test_rusboost(imbalanced_dataset, algorithm):
2929
X, y = imbalanced_dataset
3030
X_train, X_test, y_train, y_test = train_test_split(
@@ -70,7 +70,7 @@ def test_rusboost(imbalanced_dataset, algorithm):
7070

7171

7272
@pytest.mark.parametrize("algorithm", ["SAMME", "SAMME.R"])
73-
@pytest.mark.filterwarnings("ignore:The SAMME.R algorithm (the default) is")
73+
@pytest.mark.filterwarnings("ignore:`algorithm` parameter is deprecated in 0.12")
7474
def test_rusboost_sample_weight(imbalanced_dataset, algorithm):
7575
X, y = imbalanced_dataset
7676
sample_weight = np.ones_like(y)
@@ -88,3 +88,13 @@ def test_rusboost_sample_weight(imbalanced_dataset, algorithm):
8888

8989
with pytest.raises(AssertionError):
9090
assert_array_equal(y_pred_no_sample_weight, y_pred_sample_weight)
91+
92+
93+
@pytest.mark.parametrize("algorithm", ["SAMME", "SAMME.R"])
94+
def test_rusboost_algorithm_future_warning(imbalanced_dataset, algorithm):
95+
X, y = imbalanced_dataset
96+
rusboost = RUSBoostClassifier(algorithm=algorithm, random_state=0)
97+
98+
warning_msg = "`algorithm` parameter is deprecated in 0.12"
99+
with pytest.warns(FutureWarning, match=warning_msg):
100+
rusboost.fit(X, y)

imblearn/pipeline.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ class Pipeline(_ParamsValidationMixin, pipeline.Pipeline):
9595
n_features_in_ : int
9696
Number of features seen during first step `fit` method.
9797
98+
feature_names_in_ : ndarray of shape (`n_features_in_`,)
99+
Names of features seen during :term:`fit`. Only defined if the
100+
underlying estimator exposes such an attribute when fit.
101+
98102
See Also
99103
--------
100104
make_pipeline : Helper function to make pipeline.

imblearn/utils/_tags.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
if sklearn_version >= parse_version("1.6"):
1010
from sklearn.utils._tags import (
11+
Tags,
1112
TargetTags,
1213
TransformerTags,
1314
ClassifierTags,
@@ -33,7 +34,7 @@ class SamplerTags:
3334
sample_indices: bool = False
3435

3536
@dataclass(**_dataclass_args())
36-
class Tags:
37+
class Tags(Tags):
3738
"""Tags for the estimator.
3839
3940
See :ref:`estimator_tags` for more information.
@@ -86,15 +87,4 @@ class Tags:
8687
The input data(X) tags.
8788
"""
8889

89-
estimator_type: str | None
90-
target_tags: TargetTags
91-
transformer_tags: TransformerTags | None
92-
classifier_tags: ClassifierTags | None
93-
regressor_tags: RegressorTags | None
94-
sampler_tags: SamplerTags | None
95-
array_api_support: bool = False
96-
no_validation: bool = False
97-
non_deterministic: bool = False
98-
requires_fit: bool = True
99-
_skip_test: bool = False
100-
input_tags: InputTags = field(default_factory=InputTags)
90+
sampler_tags: SamplerTags | None = None

imblearn/utils/_test_common/instance_generator.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@
5454
dict(estimator=DecisionTreeClassifier(random_state=42), random_state=42),
5555
],
5656
Pipeline: dict(
57-
steps=[("sampler", RandomUnderSampler()), ("logistic", LogisticRegression())]
57+
steps=[
58+
("sampler", RandomUnderSampler(random_state=0)),
59+
("logistic", LogisticRegression()),
60+
]
5861
),
5962
# over-sampling
6063
ADASYN: dict(random_state=42),

0 commit comments

Comments
 (0)