Skip to content

[DOC] Add implementation references #2748

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

Merged
merged 2 commits into from
Apr 20, 2025
Merged
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
4 changes: 3 additions & 1 deletion aeon/base/_compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
class ComposableEstimatorMixin(ABC):
"""Handles parameter management for estimators composed of named estimators.

Parts (i.e. get_params and set_params) adapted or copied from the scikit-learn
Parts (i.e. get_params and set_params) adapted from the scikit-learn 1.5.0
``_BaseComposition`` class in utils/metaestimators.py.
https://github.com/scikit-learn/scikit-learn/
Copyright (c) 2007-2024 The scikit-learn developers, BSD-3
"""

# Attribute name containing an iterable of processed (str, estimator) tuples
Expand Down
3 changes: 2 additions & 1 deletion aeon/classification/dictionary_based/_redcomets.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ class REDCOMETS(BaseClassifier):

Notes
-----
Adapted from the implementation at https://github.com/zy18811/RED-CoMETS
Adapted from the implementation at https://github.com/zy18811/RED-CoMETS by
the code owner.

References
----------
Expand Down
50 changes: 19 additions & 31 deletions aeon/clustering/_kernel_k_means.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def _kdtw_lk(x, y, local_kernel):
return cost_matrix[x_timepoints - 1, y_timepoints - 1]


def kdtw(x, y, sigma=1.0, epsilon=1e-3):
def _kdtw(x, y, sigma=1.0, epsilon=1e-3):
"""
Callable kernel function for KernelKMeans.

Expand All @@ -81,6 +81,12 @@ def kdtw(x, y, sigma=1.0, epsilon=1e-3):
A small constant added for numerical stability to avoid zero values in the
local kernel matrix.

Notes
-----
Inspired by the original implementation
https://github.com/pfmarteau/KDTW/tree/master
Copyright (c) 2020 Pierre-François Marteau, MIT License

Returns
-------
similarity : float
Expand All @@ -92,35 +98,6 @@ def kdtw(x, y, sigma=1.0, epsilon=1e-3):
return _kdtw_lk(x, y, local_kernel)


def factory_kdtw_kernel(channels: int):
"""
Return a kdtw kernel callable function that flattened samples to (T, channels).

Parameters
----------
channels: int
Number of channels per timepoint.

Returns
-------
kdtw_kernel : callable
A callable kernel function that computes the KDTW similarity between two
time series samples. The function signature is the same as the kdtw
function.
"""

def kdtw_kernel(x, y, sigma=1.0, epsilon=1e-3):
if x.ndim == 1:
T = x.size // channels
x = x.reshape(T, channels)
if y.ndim == 1:
T = y.size // channels
y = y.reshape(T, channels)
return kdtw(x, y, sigma=sigma, epsilon=epsilon)

return kdtw_kernel


class TimeSeriesKernelKMeans(BaseClusterer):
"""Kernel K Means [1]_: wrapper of the ``tslearn`` implementation.

Expand Down Expand Up @@ -255,7 +232,18 @@ def _fit(self, X, y=None):
verbose = 1

if self.kernel == "kdtw":
self.kernel = factory_kdtw_kernel(channels=X.shape[1])
n_channels = X.shape[1]

def kdtw_kernel(x, y, sigma=1.0, epsilon=1e-3):
if x.ndim == 1:
T = x.size // n_channels
x = x.reshape(T, n_channels)
if y.ndim == 1:
T = y.size // n_channels
y = y.reshape(T, n_channels)
return _kdtw(x, y, sigma=sigma, epsilon=epsilon)

self.kernel = kdtw_kernel

self._tslearn_kernel_k_means = TsLearnKernelKMeans(
n_clusters=self.n_clusters,
Expand Down
8 changes: 7 additions & 1 deletion aeon/distances/elastic/_bounding_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,14 @@ def create_bounding_matrix(
def _itakura_parallelogram(x_size: int, y_size: int, max_slope_percent: float):
"""Itakura parallelogram bounding matrix.

This code was adapted from pyts. This link to the original code:
This code was adapted from the tslearn and pyts functions.

pyts code:
https://pyts.readthedocs.io/en/latest/_modules/pyts/metrics/dtw.html#itakura_parallelogram
Copyright (c) 2018, Johann Faouzi and pyts contributors, BSD-3
tslearn code (line 974):
https://github.com/tslearn-team/tslearn/blob/main/tslearn/metrics/dtw_variants.py
Copyright (c) 2017, Romain Tavenard, BSD-2
"""
one_percent = min(x_size, y_size) / 100
max_slope = math.floor((max_slope_percent * one_percent) * 100)
Expand Down
2 changes: 2 additions & 0 deletions aeon/regression/deep_learning/_lite_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class LITETimeRegressor(BaseRegressor):
-----
Adapted from the implementation from Ismail-Fawaz et. al
https://github.com/MSD-IRIMAS/LITE
by the code owner.

References
----------
Expand Down Expand Up @@ -388,6 +389,7 @@ class IndividualLITERegressor(BaseDeepRegressor):
-----
Adapted from the implementation from Ismail-Fawaz et. al
https://github.com/MSD-IRIMAS/LITE
by the code owner.

References
----------
Expand Down
1 change: 1 addition & 0 deletions aeon/segmentation/_ggs.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
Based on the work from [1]_.

- source code adapted based on: https://github.com/cvxgrp/GGS
Copyright (c) 2018, Stanford University Convex Optimization Group, BSD-2
- paper available at: https://stanford.edu/~boyd/papers/pdf/ggs.pdf

References
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class MiniRocket(BaseCollectionTransformer):
Notes
-----
Directly adapted from the original implementation
https://github.com/angus924/minirocket.
https://github.com/angus924/minirocket with owner permission.

Examples
--------
Expand Down
3 changes: 2 additions & 1 deletion aeon/transformations/series/_bkfilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ class BKFilter(BaseSeriesTransformer):

Notes
-----
Adapted from statsmodels implementation
Adapted from statsmodels 0.14.4 implementation
https://github.com/statsmodels/statsmodels/blob/main/statsmodels/tsa/filters/bk_filter.py
Copyright (c) 2009-2018 statsmodels Developers, BSD-3

References
----------
Expand Down
11 changes: 7 additions & 4 deletions aeon/utils/show_versions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
"""Utility methods to print system info for debugging.

Adapted from the sklearn show_versions function.
"""
"""Utility methods to print system info for debugging."""

__maintainer__ = ["MatthewMiddlehurst"]
__all__ = ["show_versions"]
Expand Down Expand Up @@ -37,6 +34,12 @@ def show_versions(as_str: bool = False) -> Union[str, None]:
str or None
The output string if `as_str` is True, otherwise None.

Notes
-----
Adapted from the scikit-learn 1.5.0 show_versions function.
https://github.com/scikit-learn/scikit-learn/
Copyright (c) 2007-2024 The scikit-learn developers, BSD-3

Examples
--------
>>> from aeon.utils import show_versions
Expand Down
4 changes: 2 additions & 2 deletions aeon/visualisation/results/_critical_difference.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ def plot_critical_difference(
overall performance in general, and such comparisons should be seen as exploratory
analysis rather than designed experiments to test an a priori hypothesis.

Parts of the code are adapted from here:
https://github.com/hfawaz/cd-diagram
Parts of the code are adapted from https://github.com/hfawaz/cd-diagram
with permission from the owner.

Parameters
----------
Expand Down
1 change: 1 addition & 0 deletions docs/_sphinxext/sphinx_remove_toctrees.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

https://github.com/mne-tools/mne-lsl
https://github.com/mne-tools/mne-lsl/blob/main/doc/_sphinxext/sphinx_remove_toctrees.py
Copyright © 2023-2024, authors of MNE-LSL, BSD-3
"""

from pathlib import Path
Expand Down