Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MNT] Raise version bound for scikit-learn 1.6 #2486

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions aeon/base/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,18 @@ def __sklearn_is_fitted__(self):
"""Check fitted status and return a Boolean value."""
return self.is_fitted

def __sklearn_tags__(self):
"""Return sklearn style tags for the estimator."""
aeon_tags = self.get_tags()
sklearn_tags = super().__sklearn_tags__()
sklearn_tags.non_deterministic = aeon_tags.get("non_deterministic", False)
sklearn_tags.target_tags.one_d_labels = True
sklearn_tags.input_tags.three_d_array = True
sklearn_tags.input_tags.allow_nan = aeon_tags.get(
"capability:missing_values", False
)
return sklearn_tags

def _validate_data(self, **kwargs):
"""Sklearn data validation."""
raise NotImplementedError(
Expand Down
4 changes: 2 additions & 2 deletions aeon/classification/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class name: BaseClassifier

import numpy as np
import pandas as pd
from sklearn.base import ClassifierMixin
from sklearn.metrics import get_scorer, get_scorer_names
from sklearn.model_selection import cross_val_predict

Expand All @@ -35,7 +36,7 @@ class name: BaseClassifier
from aeon.utils.validation.labels import check_classification_y


class BaseClassifier(BaseCollectionEstimator):
class BaseClassifier(ClassifierMixin, BaseCollectionEstimator):
"""
Abstract base class for time series classifiers.

Expand Down Expand Up @@ -66,7 +67,6 @@ def __init__(self):
self.classes_ = [] # classes seen in y, unique labels
self.n_classes_ = -1 # number of unique classes in y
self._class_dictionary = {}
self._estimator_type = "classifier"

super().__init__()

Expand Down
25 changes: 2 additions & 23 deletions aeon/clustering/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
from typing import final

import numpy as np
from sklearn.base import ClusterMixin

from aeon.base import BaseCollectionEstimator


class BaseClusterer(BaseCollectionEstimator):
class BaseClusterer(ClusterMixin, BaseCollectionEstimator):
"""Abstract base class for time series clusterers.

Parameters
Expand All @@ -26,10 +27,6 @@ class BaseClusterer(BaseCollectionEstimator):

@abstractmethod
def __init__(self):
# required for compatibility with some sklearn interfaces e.g.
# CalibratedClassifierCV
self._estimator_type = "clusterer"

super().__init__()

@final
Expand Down Expand Up @@ -132,24 +129,6 @@ def fit_predict(self, X, y=None) -> np.ndarray:
to return.
y: ignored, exists for API consistency reasons.

Returns
-------
np.ndarray (1d array of shape (n_cases,))
Index of the cluster each time series in X belongs to.
"""
return self._fit_predict(X, y)

def _fit_predict(self, X, y=None) -> np.ndarray:
"""Fit predict using base methods.

Parameters
----------
X : np.ndarray (2d or 3d array of shape (n_cases, n_timepoints) or shape
(n_cases, n_channels, n_timepoints)).
Time series instances to train clusterer and then have indexes each belong
to return.
y: ignored, exists for API consistency reasons.

Returns
-------
np.ndarray (1d array of shape (n_cases,))
Expand Down
6 changes: 2 additions & 4 deletions aeon/regression/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class name: BaseRegressor

import numpy as np
import pandas as pd
from sklearn.base import RegressorMixin
from sklearn.metrics import get_scorer, get_scorer_names
from sklearn.model_selection import cross_val_predict
from sklearn.utils.multiclass import type_of_target
Expand All @@ -33,7 +34,7 @@ class name: BaseRegressor
from aeon.base._base import _clone_estimator


class BaseRegressor(BaseCollectionEstimator):
class BaseRegressor(RegressorMixin, BaseCollectionEstimator):
"""Abstract base class for time series regressors.

The base regressor specifies the methods and method signatures that all
Expand All @@ -54,9 +55,6 @@ class BaseRegressor(BaseCollectionEstimator):

@abstractmethod
def __init__(self):
# required for compatibility with some sklearn interfaces
self._estimator_type = "regressor"

super().__init__()

@final
Expand Down
2 changes: 2 additions & 0 deletions aeon/visualisation/estimator/_shapelets.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,8 @@ def _get_shp_importance(self, class_id):
# classification for the given class_id
if isinstance(classifier, LinearClassifierMixin):
coefs = classifier.coef_
if coefs.ndim == 1:
coefs = coefs[np.newaxis, :]
n_classes = coefs.shape[0]
if n_classes == 1:
if isinstance(self.estimator, RDSTClassifier):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ dependencies = [
"numpy>=1.21.0,<2.1.0",
"packaging>=20.0",
"pandas>=2.0.0,<2.3.0",
"scikit-learn>=1.0.0,<1.6.0",
"scikit-learn>=1.0.0,<1.7.0",
"scipy>=1.9.0,<1.15.0",
"typing-extensions>=4.6.0",
]
Expand Down
Loading