Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into mm/docs2
Browse files Browse the repository at this point in the history
# Conflicts:
#	examples/pydata/Amsterdam-2023/Lets_do_the_time_warp_again.ipynb
  • Loading branch information
MatthewMiddlehurst committed Nov 26, 2024
2 parents 7c40473 + f4d2daa commit f563a0a
Show file tree
Hide file tree
Showing 90 changed files with 3,097 additions and 839 deletions.
2 changes: 2 additions & 0 deletions .github/utilities/run_examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ excluded=()
if [ "$1" = true ]; then
excluded+=(
"examples/datasets/load_data_from_web.ipynb"
"examples/benchmarking/published_results.ipynb"
"examples/benchmarking/reference_results.ipynb"
"examples/benchmarking/bakeoff_results.ipynb"
"examples/benchmarking/regression.ipynb"
Expand All @@ -21,6 +22,7 @@ if [ "$1" = true ]; then
"examples/classification/interval_based.ipynb"
"examples/classification/shapelet_based.ipynb"
"examples/classification/convolution_based.ipynb"
"examples/similarity_search/code_speed.ipynb"

)
fi
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/periodic_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,31 @@ jobs:
# Save cache with the current date (ENV set in numba_cache action)
key: numba-run-notebook-examples-${{ runner.os }}-3.10-${{ env.CURRENT_DATE }}

test-core-imports:
runs-on: ubuntu-22.04

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Install aeon and dependencies
uses: nick-fields/retry@v3
with:
timeout_minutes: 30
max_attempts: 3
command: python -m pip install .

- name: Show dependencies
run: python -m pip list

- name: Run import test
run: python aeon/testing/tests/test_core_imports.py

test-no-soft-deps:
runs-on: ubuntu-22.04

Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/pr_core_dep_import.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: PR module imports

on:
push:
branches:
- main
pull_request:
branches:
- main
paths:
- "aeon/**"
- ".github/workflows/**"
- "pyproject.toml"

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
test-core-imports:
runs-on: ubuntu-22.04

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Install aeon and dependencies
uses: nick-fields/retry@v3
with:
timeout_minutes: 30
max_attempts: 3
command: python -m pip install .

- name: Show dependencies
run: python -m pip list

- name: Run import test
run: python aeon/testing/tests/test_core_imports.py
2 changes: 1 addition & 1 deletion .github/workflows/pr_pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
run: python -m pip list

- name: Run tests
run: python -m pytest -n logical -k 'not TestAll'
run: python -m pytest -n logical

pytest:
runs-on: ${{ matrix.os }}
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ python:
- docs

build:
os: ubuntu-20.04
os: ubuntu-22.04
tools:
python: "3.10"

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ The following modules are still considered experimental, and the [deprecation po
does not apply:

- `anomaly_detection`
- `forecasting`
- `segmentation`
- `similarity_search`
- `visualisation`
Expand Down
2 changes: 1 addition & 1 deletion aeon/base/tests/test_base_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
UNEQUAL_LENGTH_MULTIVARIATE_CLASSIFICATION,
UNEQUAL_LENGTH_UNIVARIATE_CLASSIFICATION,
)
from aeon.utils import COLLECTIONS_DATA_TYPES
from aeon.utils.data_types import COLLECTIONS_DATA_TYPES
from aeon.utils.validation import get_type


Expand Down
6 changes: 3 additions & 3 deletions aeon/classification/distance_based/_proximity_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def _get_best_splitter(self, X, y):
dist = distance(
X[j],
splitter[0][labels[k]],
metric=measure,
measure=measure,
**splitter[1][measure],
)
if dist < min_dist:
Expand Down Expand Up @@ -320,7 +320,7 @@ def _build_tree(self, X, y, depth, node_id, parent_target_value=None):
dist = distance(
X[i],
splitter[0][labels[j]],
metric=measure,
measure=measure,
**splitter[1][measure],
)
if dist < min_dist:
Expand Down Expand Up @@ -404,7 +404,7 @@ def _classify(self, treenode, x):
dist = distance(
x,
treenode.splitter[0][branches[i]],
metric=measure,
measure=measure,
**treenode.splitter[1][measure],
)
if dist < min_dist:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def _fit(self, X, y):
y : array-like, shape = (n_cases)
The class labels.
"""
self.metric_ = get_distance_function(metric=self.distance)
self.metric_ = get_distance_function(measure=self.distance)
self.X_ = X
self.classes_, self.y_ = np.unique(y, return_inverse=True)
return self
Expand Down
2 changes: 1 addition & 1 deletion aeon/classification/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
EQUAL_LENGTH_UNIVARIATE_CLASSIFICATION,
UNEQUAL_LENGTH_UNIVARIATE_CLASSIFICATION,
)
from aeon.utils import COLLECTIONS_DATA_TYPES
from aeon.utils.data_types import COLLECTIONS_DATA_TYPES

__maintainer__ = []

Expand Down
6 changes: 3 additions & 3 deletions aeon/clustering/_clara.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class TimeSeriesCLARA(BaseClusterer):
If a np.ndarray provided it must be of shape (n_clusters,) and contain
the indexes of the time series to use as centroids.
distance : str or Callable, default='msm'
Distance metric to compute similarity between time series. A list of valid
Distance measure to compute similarity between time series. A list of valid
strings for metrics can be found in the documentation for
:func:`aeon.distances.get_distance_function`. If a callable is passed it must be
a function that takes two 2d numpy arrays as input and returns a float.
Expand Down Expand Up @@ -73,7 +73,7 @@ class TimeSeriesCLARA(BaseClusterer):
If `None`, the random number generator is the `RandomState` instance used
by `np.random`.
distance_params : dict, default=None
Dictionary containing kwargs for the distance metric being used.
Dictionary containing kwargs for the distance measure being used.
Attributes
----------
Expand Down Expand Up @@ -189,7 +189,7 @@ def _fit(self, X: np.ndarray, y=None):
curr_centers = pam.cluster_centers_
if isinstance(pam.distance, str):
pairwise_matrix = pairwise_distance(
X, curr_centers, metric=self.distance, **pam._distance_params
X, curr_centers, measure=self.distance, **pam._distance_params
)
else:
pairwise_matrix = pairwise_distance(
Expand Down
6 changes: 3 additions & 3 deletions aeon/clustering/_clarans.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ class TimeSeriesCLARANS(TimeSeriesKMedoids):
If a np.ndarray provided it must be of shape (n_clusters,) and contain
the indexes of the time series to use as centroids.
distance : str or Callable, default='msm'
Distance metric to compute similarity between time series. A list of valid
strings for metrics can be found in the documentation for
Distance measure to compute similarity between time series. A list of valid
strings for measures can be found in the documentation for
:func:`aeon.distances.get_distance_function`. If a callable is passed it must be
a function that takes two 2d numpy arrays as input and returns a float.
max_neighbours : int, default=None,
Expand All @@ -62,7 +62,7 @@ class TimeSeriesCLARANS(TimeSeriesKMedoids):
random_state : int or np.random.RandomState instance or None, default=None
Determines random number generation for centroid initialization.
distance_params : dict, default=None
Dictionary containing kwargs for the distance metric being used.
Dictionary containing kwargs for the distance measure being used.
Attributes
----------
Expand Down
8 changes: 4 additions & 4 deletions aeon/clustering/_elastic_som.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ class ElasticSOM(BaseClusterer):
n_clusters : int, default=8
The number of clusters to form as well as the number of centroids to generate.
distance : str or Callable, default='dtw'
Distance metric to compute similarity between time series. A list of valid
strings for metrics can be found in the documentation for
Distance measure to compute similarity between time series. A list of valid
strings for measures can be found in the documentation for
:func:`aeon.distances.get_distance_function`. If a callable is passed it must be
a function that takes two 2d numpy arrays as input and returns a float.
init : str or np.ndarray, default='random'
Expand Down Expand Up @@ -224,7 +224,7 @@ def _find_bmu(self, x, weights):
pairwise_matrix = pairwise_distance(
x,
weights,
metric=self.distance,
measure=self.distance,
**self._distance_params,
)
return pairwise_matrix.argmin(axis=1)
Expand Down Expand Up @@ -366,7 +366,7 @@ def _kmeans_plus_plus_center_initializer(self, X: np.ndarray):

for _ in range(1, self.n_clusters):
pw_dist = pairwise_distance(
X, X[indexes], metric=self.distance, **self._distance_params
X, X[indexes], measure=self.distance, **self._distance_params
)
min_distances = pw_dist.min(axis=1)
probabilities = min_distances / min_distances.sum()
Expand Down
14 changes: 7 additions & 7 deletions aeon/clustering/_k_means.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ class TimeSeriesKMeans(BaseClusterer):
n_timepoints)
and contains the time series to use as centroids.
distance : str or Callable, default='msm'
Distance metric to compute similarity between time series. A list of valid
strings for metrics can be found in the documentation for
Distance measure to compute similarity between time series. A list of valid
strings for measures can be found in the documentation for
:func:`aeon.distances.get_distance_function`. If a callable is passed it must be
a function that takes two 2d numpy arrays as input and returns a float.
n_init : int, default=10
Expand Down Expand Up @@ -236,7 +236,7 @@ def _fit_one_init(self, X: np.ndarray) -> tuple:
prev_labels = None
for i in range(self.max_iter):
curr_pw = pairwise_distance(
X, cluster_centres, metric=self.distance, **self._distance_params
X, cluster_centres, measure=self.distance, **self._distance_params
)
curr_labels = curr_pw.argmin(axis=1)
curr_inertia = curr_pw.min(axis=1).sum()
Expand Down Expand Up @@ -273,13 +273,13 @@ def _fit_one_init(self, X: np.ndarray) -> tuple:
def _predict(self, X: np.ndarray, y=None) -> np.ndarray:
if isinstance(self.distance, str):
pairwise_matrix = pairwise_distance(
X, self.cluster_centers_, metric=self.distance, **self._distance_params
X, self.cluster_centers_, measure=self.distance, **self._distance_params
)
else:
pairwise_matrix = pairwise_distance(
X,
self.cluster_centers_,
metric=self.distance,
measure=self.distance,
**self._distance_params,
)
return pairwise_matrix.argmin(axis=1)
Expand Down Expand Up @@ -346,7 +346,7 @@ def _kmeans_plus_plus_center_initializer(self, X: np.ndarray):

for _ in range(1, self.n_clusters):
pw_dist = pairwise_distance(
X, X[indexes], metric=self.distance, **self._distance_params
X, X[indexes], measure=self.distance, **self._distance_params
)
min_distances = pw_dist.min(axis=1)
probabilities = min_distances / min_distances.sum()
Expand Down Expand Up @@ -381,7 +381,7 @@ def _handle_empty_cluster(
index_furthest_from_centre = curr_pw.min(axis=1).argmax()
cluster_centres[current_empty_cluster_index] = X[index_furthest_from_centre]
curr_pw = pairwise_distance(
X, cluster_centres, metric=self.distance, **self._distance_params
X, cluster_centres, measure=self.distance, **self._distance_params
)
curr_labels = curr_pw.argmin(axis=1)
curr_inertia = curr_pw.min(axis=1).sum()
Expand Down
12 changes: 6 additions & 6 deletions aeon/clustering/_k_medoids.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ class TimeSeriesKMedoids(BaseClusterer):
If a np.ndarray provided it must be of shape (n_clusters,) and contain
the indexes of the time series to use as centroids.
distance : str or Callable, default='msm'
Distance metric to compute similarity between time series. A list of valid
strings for metrics can be found in the documentation for
Distance measure to compute similarity between time series. A list of valid
strings for measures can be found in the documentation for
:func:`aeon.distances.get_distance_function`. If a callable is passed it must be
a function that takes two 2d numpy arrays as input and returns a float.
method : str, default='pam'
Expand Down Expand Up @@ -88,7 +88,7 @@ class TimeSeriesKMedoids(BaseClusterer):
If `None`, the random number generator is the `RandomState` instance used
by `np.random`.
distance_params: dict, default=None
Dictionary containing kwargs for the distance metric being used.
Dictionary containing kwargs for the distance measure being used.
Attributes
----------
Expand Down Expand Up @@ -211,7 +211,7 @@ def _fit(self, X: np.ndarray, y=None):
def _predict(self, X: np.ndarray, y=None) -> np.ndarray:
if isinstance(self.distance, str):
pairwise_matrix = pairwise_distance(
X, self.cluster_centers_, metric=self.distance, **self._distance_params
X, self.cluster_centers_, measure=self.distance, **self._distance_params
)
else:
pairwise_matrix = pairwise_distance(
Expand Down Expand Up @@ -456,7 +456,7 @@ def _check_params(self, X: np.ndarray) -> None:
f"n_clusters ({self.n_clusters}) cannot be larger than "
f"n_cases ({X.shape[0]})"
)
self._distance_callable = get_distance_function(metric=self.distance)
self._distance_callable = get_distance_function(measure=self.distance)
self._distance_cache = np.full((X.shape[0], X.shape[0]), np.inf)

if self.method == "alternate":
Expand Down Expand Up @@ -486,7 +486,7 @@ def _kmedoids_plus_plus_center_initializer(self, X: np.ndarray):

for _ in range(1, self.n_clusters):
pw_dist = pairwise_distance(
X, X[indexes], metric=self.distance, **self._distance_params
X, X[indexes], measure=self.distance, **self._distance_params
)
min_distances = pw_dist.min(axis=1)
probabilities = min_distances / min_distances.sum()
Expand Down
2 changes: 1 addition & 1 deletion aeon/clustering/averaging/_ba_petitjean.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def petitjean_barycenter_average(
random_state: int or None, default=None
Random state to use for the barycenter averaging.
**kwargs
Keyword arguments to pass to the distance metric.
Keyword arguments to pass to the distance measure.
Returns
-------
Expand Down
2 changes: 1 addition & 1 deletion aeon/clustering/averaging/_ba_subgradient.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def subgradient_barycenter_average(
random_state: int or None, default=None
Random state to use for the barycenter averaging.
**kwargs
Keyword arguments to pass to the distance metric.
Keyword arguments to pass to the distance measure.
Returns
-------
Expand Down
4 changes: 2 additions & 2 deletions aeon/clustering/averaging/_ba_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def _medoids(
return X

if precomputed_pairwise_distance is None:
precomputed_pairwise_distance = pairwise_distance(X, metric=distance, **kwargs)
precomputed_pairwise_distance = pairwise_distance(X, measure=distance, **kwargs)

x_size = X.shape[0]
distance_matrix = np.zeros((x_size, x_size))
Expand Down Expand Up @@ -155,6 +155,6 @@ def _get_alignment_path(
elif distance == "adtw":
return adtw_alignment_path(ts, center, window=window, warp_penalty=warp_penalty)
else:
# When numba version > 0.57 add more informative error with what metric
# When numba version > 0.57 add more informative error with what measure
# was passed.
raise ValueError("Distance parameter invalid")
2 changes: 1 addition & 1 deletion aeon/clustering/averaging/_barycenter_averaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def elastic_barycenter_average(
random_state: int or None, default=None
Random state to use for the barycenter averaging.
**kwargs
Keyword arguments to pass to the distance metric.
Keyword arguments to pass to the distance measure.
Returns
-------
Expand Down
Loading

0 comments on commit f563a0a

Please sign in to comment.