Skip to content

Commit

Permalink
MAINT update tests and import for sklearn 1.4.1 (#1072)
Browse files Browse the repository at this point in the history
  • Loading branch information
glemaitre committed Mar 31, 2024
1 parent 4c63b3c commit 5570b40
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion examples/applications/porto_seguro_keras_under_sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def wrapper(*args, **kwds):
# mini-batches.
import tensorflow
from sklearn.metrics import roc_auc_score
from sklearn.utils import parse_version
from sklearn.utils.fixes import parse_version

tf_version = parse_version(tensorflow.__version__)

Expand Down
2 changes: 1 addition & 1 deletion imblearn/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from contextlib import contextmanager as contextmanager

import sklearn
from sklearn.utils import parse_version
from sklearn.utils.fixes import parse_version

sklearn_version = parse_version(sklearn.__version__)

Expand Down
2 changes: 1 addition & 1 deletion imblearn/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from sklearn.base import _OneToOneFeatureMixin as OneToOneFeatureMixin

from sklearn.preprocessing import label_binarize
from sklearn.utils import parse_version
from sklearn.utils.fixes import parse_version
from sklearn.utils.multiclass import check_classification_targets

from .utils import check_sampling_strategy, check_target_type
Expand Down
2 changes: 1 addition & 1 deletion imblearn/ensemble/_bagging.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from sklearn.ensemble._base import _partition_estimators
from sklearn.exceptions import NotFittedError
from sklearn.tree import DecisionTreeClassifier
from sklearn.utils import parse_version
from sklearn.utils.fixes import parse_version
from sklearn.utils.validation import check_is_fitted

try:
Expand Down
2 changes: 1 addition & 1 deletion imblearn/ensemble/_easy_ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
from sklearn.ensemble._bagging import _parallel_decision_function
from sklearn.ensemble._base import _partition_estimators
from sklearn.exceptions import NotFittedError
from sklearn.utils import parse_version
from sklearn.utils._tags import _safe_tags
from sklearn.utils.fixes import parse_version
from sklearn.utils.validation import check_is_fitted

try:
Expand Down
3 changes: 2 additions & 1 deletion imblearn/ensemble/_forest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
)
from sklearn.exceptions import DataConversionWarning
from sklearn.tree import DecisionTreeClassifier
from sklearn.utils import _safe_indexing, check_random_state, parse_version
from sklearn.utils import _safe_indexing, check_random_state
from sklearn.utils.fixes import parse_version
from sklearn.utils.multiclass import type_of_target
from sklearn.utils.validation import _check_sample_weight

Expand Down
3 changes: 2 additions & 1 deletion imblearn/ensemble/_weight_boosting.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
from sklearn.ensemble import AdaBoostClassifier
from sklearn.ensemble._base import _set_random_states
from sklearn.tree import DecisionTreeClassifier
from sklearn.utils import _safe_indexing, parse_version
from sklearn.utils import _safe_indexing
from sklearn.utils.fixes import parse_version
from sklearn.utils.validation import has_fit_parameter

from ..base import _ParamsValidationMixin
Expand Down
6 changes: 3 additions & 3 deletions imblearn/keras/tests/test_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def test_balanced_batch_generator_class(data, sampler, sample_weight):
batch_size=10,
random_state=42,
)
model.fit_generator(generator=training_generator, epochs=10)
model.fit(training_generator, epochs=10)


@pytest.mark.parametrize("keep_sparse", [True, False])
Expand Down Expand Up @@ -122,8 +122,8 @@ def test_balanced_batch_generator_function(data, sampler, sample_weight):
batch_size=10,
random_state=42,
)
model.fit_generator(
generator=training_generator,
model.fit(
training_generator,
steps_per_epoch=steps_per_epoch,
epochs=10,
)
Expand Down
4 changes: 2 additions & 2 deletions imblearn/tests/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ def test_fit_predict_on_pipeline_without_fit_predict():
scaler = StandardScaler()
pca = PCA(svd_solver="full")
pipe = Pipeline([("scaler", scaler), ("pca", pca)])
error_regex = "'PCA' object has no attribute 'fit_predict'"
error_regex = "has no attribute 'fit_predict'"
with raises(AttributeError, match=error_regex):
getattr(pipe, "fit_predict")

Expand Down Expand Up @@ -1219,7 +1219,7 @@ def test_score_samples_on_pipeline_without_score_samples():
pipe.fit(X, y)
with pytest.raises(
AttributeError,
match="'LogisticRegression' object has no attribute 'score_samples'",
match="has no attribute 'score_samples'",
):
pipe.score_samples(X)

Expand Down
2 changes: 1 addition & 1 deletion imblearn/utils/_available_if.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from types import MethodType

import sklearn
from sklearn.utils import parse_version
from sklearn.utils.fixes import parse_version

sklearn_version = parse_version(sklearn.__version__)

Expand Down

0 comments on commit 5570b40

Please sign in to comment.