Skip to content
Draft
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
8 changes: 4 additions & 4 deletions aeon/anomaly_detection/series/distance_based/_rockad.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ class ROCKAD(BaseSeriesAnomalyDetector):
>>> detector.fit(X_train)
ROCKAD(...)
>>> detector.predict(X_test)
array([0. , 0.00554713, 0.06990941, 0.22881059, 0.32382585,
0.43652154, 0.43652154, 0.43652154, 0.43652154, 0.43652154,
0.43652154, 0.43652154, 0.43652154, 0.43652154, 0.43652154,
0.52382585, 0.65200875, 0.80313368, 0.85194345, 1. ])
array([0. , 0.0055471, 0.0699094, 0.2288105, 0.3238258,
0.4365215, 0.4365215, 0.4365215, 0.4365215, 0.4365215,
0.4365215, 0.4365215, 0.4365215, 0.4365215, 0.4365215,
0.5238258, 0.6520087, 0.8031336, 0.8519434, 1. ])
"""

_tags = {
Expand Down
4 changes: 3 additions & 1 deletion aeon/classification/dictionary_based/_muse.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from joblib import Parallel, delayed
from scipy.sparse import hstack
from sklearn.linear_model import LogisticRegression, RidgeClassifierCV
from sklearn.multiclass import OneVsRestClassifier
from sklearn.utils import check_random_state

from aeon.classification.base import BaseClassifier
Expand Down Expand Up @@ -271,8 +272,9 @@ def _fit(self, X, y):
class_weight=self.class_weight,
penalty="l2",
random_state=self.random_state,
n_jobs=self.n_jobs,
)
if self.n_classes_ > 2:
self.clf = OneVsRestClassifier(self.clf, n_jobs=self.n_jobs)

self.clf.fit(all_words, y)
self.total_features_count = all_words.shape[-1]
Expand Down
6 changes: 4 additions & 2 deletions aeon/classification/dictionary_based/_weasel.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from numba import set_num_threads
from scipy.sparse import hstack
from sklearn.linear_model import LogisticRegression, RidgeClassifierCV
from sklearn.multiclass import OneVsRestClassifier
from sklearn.utils import check_random_state

from aeon.classification.base import BaseClassifier
Expand Down Expand Up @@ -238,12 +239,12 @@ def _fit(self, X, y):
all_words = np.concatenate(all_words, axis=1)
else:
all_words = hstack(all_words)

# Ridge Classifier does not give probabilities
if not self.support_probabilities:
self.clf = RidgeClassifierCV(
alphas=np.logspace(-3, 3, 10), class_weight=self.class_weight
)
all_words = all_words.astype(np.float64, copy=False)
else:
self.clf = LogisticRegression(
max_iter=5000,
Expand All @@ -252,8 +253,9 @@ def _fit(self, X, y):
class_weight=self.class_weight,
penalty="l2",
random_state=self.random_state,
n_jobs=self.n_jobs,
)
if self.n_classes_ > 2:
self.clf = OneVsRestClassifier(self.clf, n_jobs=self.n_jobs)

self.clf.fit(all_words, y)

Expand Down
3 changes: 1 addition & 2 deletions aeon/classification/dictionary_based/_weasel_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def _fit(self, X, y):
n_jobs=self._n_jobs,
)
words = self.transform.fit_transform(X, y)

words = words.astype(np.float64, copy=False)
# use RidgeClassifierCV for classification
self.clf = RidgeClassifierCV(
alphas=np.logspace(-1, 5, 10), class_weight=self.class_weight
Expand Down Expand Up @@ -426,7 +426,6 @@ def fit_transform(self, X, y=None):
all_words = np.concatenate(sfa_words, axis=1)
else:
all_words = hstack(sfa_words)

self.total_features_count = all_words.shape[1]

return all_words
Expand Down
4 changes: 2 additions & 2 deletions aeon/regression/feature_based/_catch22.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ class Catch22Regressor(BaseRegressor):
>>> reg.fit(X, y)
Catch22Regressor(...)
>>> reg.predict(X)
array([0.63821896, 1.0906666 , 0.64351536, 1.57550709, 0.46036267,
0.79297397, 1.32882497, 1.12603087, 1.51673405, 0.31683308])
array([0.63821896, 1.0906666 , 0.58323551, 1.57550709, 0.48413489,
0.70976176, 1.33206165, 1.09927538, 1.51673405, 0.31683308])
"""

_tags = {
Expand Down
11 changes: 9 additions & 2 deletions aeon/regression/sklearn/_rotation_forest_regressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ class RotationForestRegressor(RegressorMixin, BaseEstimator):
estimators_ : list of shape (n_estimators) of BaseEstimator
The collections of estimators trained in fit.

Notes
-----
Predictions may differ slightly between scikit-learn versions. In particular,
scikit-learn 1.8 fixed decision-tree handling of almost constant features, which
can change the fitted trees used by ``RotationForestRegressor`` and therefore
its output, even when using the same random state.

References
----------
.. [1] Rodriguez, Juan José, Ludmila I. Kuncheva, and Carlos J. Alonso. "Rotation
Expand Down Expand Up @@ -105,7 +112,7 @@ def __init__(
max_group: int = 3,
remove_proportion: float = 0.5,
base_estimator: BaseEstimator | None = None,
pca_solver: str = "auto",
pca_solver: str = "full",
time_limit_in_minutes: float = 0.0,
contract_max_n_estimators: int = 500,
n_jobs: int = 1,
Expand Down Expand Up @@ -330,7 +337,7 @@ def _fit_estimator(
with np.errstate(divide="ignore", invalid="ignore"):
# differences between os occasionally. seems to happen when there
# are low amounts of cases in the fit
pca = PCA(random_state=rng, svd_solver=self.pca_solver).fit(X_t)
pca = PCA(random_state=rng, svd_solver="full").fit(X_t)

if not np.isnan(pca.explained_variance_ratio_).all():
break
Expand Down
31 changes: 15 additions & 16 deletions aeon/regression/sklearn/tests/test_rotation_forest_regressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,22 @@ def test_rotf_output():
rotf.fit(X_train, y_train)

expected = [
0.026,
0.0245,
0.0224,
0.0453,
0.0892,
0.0314,
0.026,
0.0451,
0.0287,
0.04,
0.026,
0.0378,
0.0265,
0.0356,
0.0281,
0.02987,
0.01912,
0.02359,
0.05474,
0.06206,
0.03782,
0.02681,
0.04133,
0.02588,
0.04581,
0.03081,
0.02781,
0.02805,
0.03213,
0.02295,
]

np.testing.assert_array_almost_equal(expected, rotf.predict(X_test[:15]), decimal=4)


Expand Down
16 changes: 5 additions & 11 deletions aeon/testing/expected_results/_write_estimator_results.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
"""Write expected results for estimators to file for usage in tests."""

import os
from copy import deepcopy
from pathlib import Path

from sklearn.utils import check_random_state

import aeon
from aeon.base import ComposableEstimatorMixin
from aeon.base._base import _clone_estimator
from aeon.datasets import (
Expand Down Expand Up @@ -146,14 +145,9 @@ def get_results_string(results, estimator_type):

estimators = all_estimators(type_filter=estimator_type)

base = os.path.dirname(os.path.abspath(aeon.__file__))
write_path = os.path.join(
base,
"testing",
"expected_results",
f"expected_{estimator_type.replace('-', '_')}_results.py",
)
print("\nWriting to: " + write_path + "\n") # noqa: T201
base = Path(__file__).resolve().parent
write_path = base / f"expected_{estimator_type.replace('-', '_')}_results.py"
print(f"\nWriting to: {write_path}\n") # noqa: T201

uv_results = {}
mv_results = {}
Expand Down Expand Up @@ -197,7 +191,7 @@ def get_results_string(results, estimator_type):
deepcopy(multivariate_datasets[estimator_type][1]),
)

with open(write_path, "w") as f:
with open(write_path, "w", encoding="utf-8") as f:
f.write(f'"""Expected results file for {estimator_type} estimators.\n\n')
f.write("This file is automatically generated by\n")
f.write(
Expand Down
64 changes: 32 additions & 32 deletions aeon/testing/expected_results/expected_classifier_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@
[1.0, 0.0],
],
"DrCIFClassifier": [
[0.5, 0.5],
[0.6, 0.4],
[0.6, 0.4],
[1.0, 0.0],
[0.7, 0.3],
[0.7, 0.3],
[0.7, 0.3],
[0.6, 0.4],
[0.0, 1.0],
[0.8, 0.2],
[0.7, 0.3],
Expand Down Expand Up @@ -114,16 +114,16 @@
[1.0, 0.0],
],
"HIVECOTEV2": [
[0.2834, 0.7166],
[0.1732, 0.8268],
[0.8812, 0.1188],
[0.8812, 0.1188],
[0.9031, 0.0969],
[0.6541, 0.3459],
[0.0272, 0.9728],
[0.854, 0.146],
[0.6813, 0.3187],
[0.7571, 0.2429],
[0.2468, 0.7532],
[0.1107, 0.8893],
[0.9521, 0.0479],
[0.9042, 0.0958],
[0.9207, 0.0793],
[0.6007, 0.3993],
[0.0314, 0.9686],
[0.9207, 0.0793],
[0.5842, 0.4158],
[0.8414, 0.1586],
],
"HydraClassifier": [
[1.0, 0.0],
Expand Down Expand Up @@ -283,15 +283,15 @@
],
"RISTClassifier": [
[0.3333, 0.6667],
[0.0, 1.0],
[0.3333, 0.6667],
[0.6667, 0.3333],
[1.0, 0.0],
[1.0, 0.0],
[0.3333, 0.6667],
[0.6667, 0.3333],
[0.0, 1.0],
[0.6667, 0.3333],
[1.0, 0.0],
[0.0, 1.0],
[0.3333, 0.6667],
],
"RSTSF": [
[0.5, 0.5],
Expand Down Expand Up @@ -426,16 +426,16 @@
[0.9, 0.1],
],
"TemporalDictionaryEnsemble": [
[0.2689, 0.7311],
[0.0, 1.0],
[0.3057, 0.6943],
[0.1928, 0.8072],
[1.0, 0.0],
[0.8656, 0.1344],
[0.3638, 0.6362],
[0.4982, 0.5018],
[0.6943, 0.3057],
[0.3855, 0.6145],
[0.8072, 0.1928],
[0.0, 1.0],
[1.0, 0.0],
[0.4033, 0.5967],
[0.8656, 0.1344],
[0.8072, 0.1928],
[0.4985, 0.5015],
[0.8072, 0.1928],
],
"TimeSeriesForestClassifier": [
[0.3, 0.7],
Expand All @@ -462,13 +462,13 @@
[0.3215, 0.6785],
],
"WEASEL_V2": [
[0.0, 1.0],
[0.0, 1.0],
[1.0, 0.0],
[1.0, 0.0],
[1.0, 0.0],
[1.0, 0.0],
[0.0, 1.0],
[1.0, 0.0],
[1.0, 0.0],
[1.0, 0.0],
[1.0, 0.0],
[1.0, 0.0],
[1.0, 0.0],
Expand Down Expand Up @@ -512,9 +512,9 @@
[0.1, 0.2, 0.5, 0.2],
],
"DrCIFClassifier": [
[0.2, 0.8, 0.0, 0.0],
[0.1, 0.9, 0.0, 0.0],
[0.0, 0.0, 1.0, 0.0],
[0.3, 0.6, 0.0, 0.1],
[0.4, 0.5, 0.0, 0.1],
[0.0, 0.0, 0.9, 0.1],
[0.6, 0.3, 0.1, 0.0],
[0.0, 0.0, 0.9, 0.1],
Expand Down Expand Up @@ -552,9 +552,9 @@
[0.0359, 0.0, 0.7432, 0.2209],
[0.9641, 0.0, 0.0359, 0.0],
[0.0, 0.3467, 0.4683, 0.185],
[0.7089, 0.142, 0.0071, 0.142],
[0.7018, 0.1491, 0.0071, 0.142],
[0.0, 0.1148, 0.8852, 0.0],
[0.0142, 0.9858, 0.0, 0.0],
[0.0071, 0.9929, 0.0, 0.0],
[0.3093, 0.142, 0.4698, 0.0789],
[0.1077, 0.0, 0.0071, 0.8852],
[0.0, 0.0, 0.9641, 0.0359],
Expand Down Expand Up @@ -718,10 +718,10 @@
"RISTClassifier": [
[0.0, 1.0, 0.0, 0.0],
[0.0, 0.0, 1.0, 0.0],
[0.3333, 0.0, 0.0, 0.6667],
[0.6667, 0.0, 0.0, 0.3333],
[0.0, 0.0, 0.6667, 0.3333],
[0.6667, 0.3333, 0.0, 0.0],
[0.0, 0.0, 0.6667, 0.3333],
[0.0, 0.0, 0.3333, 0.6667],
[0.6667, 0.0, 0.0, 0.3333],
[0.3333, 0.0, 0.6667, 0.0],
[0.3333, 0.0, 0.0, 0.6667],
Expand Down
Loading
Loading