Skip to content

Commit fd4967b

Browse files
[DOC] Add implementation references (#2748)
* implementation references * better attribution
1 parent 9394df3 commit fd4967b

File tree

11 files changed

+47
-42
lines changed

11 files changed

+47
-42
lines changed

aeon/base/_compose.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
class ComposableEstimatorMixin(ABC):
1313
"""Handles parameter management for estimators composed of named estimators.
1414
15-
Parts (i.e. get_params and set_params) adapted or copied from the scikit-learn
15+
Parts (i.e. get_params and set_params) adapted from the scikit-learn 1.5.0
1616
``_BaseComposition`` class in utils/metaestimators.py.
17+
https://github.com/scikit-learn/scikit-learn/
18+
Copyright (c) 2007-2024 The scikit-learn developers, BSD-3
1719
"""
1820

1921
# Attribute name containing an iterable of processed (str, estimator) tuples

aeon/classification/dictionary_based/_redcomets.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ class REDCOMETS(BaseClassifier):
6666
6767
Notes
6868
-----
69-
Adapted from the implementation at https://github.com/zy18811/RED-CoMETS
69+
Adapted from the implementation at https://github.com/zy18811/RED-CoMETS by
70+
the code owner.
7071
7172
References
7273
----------

aeon/clustering/_kernel_k_means.py

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def _kdtw_lk(x, y, local_kernel):
6464
return cost_matrix[x_timepoints - 1, y_timepoints - 1]
6565

6666

67-
def kdtw(x, y, sigma=1.0, epsilon=1e-3):
67+
def _kdtw(x, y, sigma=1.0, epsilon=1e-3):
6868
"""
6969
Callable kernel function for KernelKMeans.
7070
@@ -81,6 +81,12 @@ def kdtw(x, y, sigma=1.0, epsilon=1e-3):
8181
A small constant added for numerical stability to avoid zero values in the
8282
local kernel matrix.
8383
84+
Notes
85+
-----
86+
Inspired by the original implementation
87+
https://github.com/pfmarteau/KDTW/tree/master
88+
Copyright (c) 2020 Pierre-François Marteau, MIT License
89+
8490
Returns
8591
-------
8692
similarity : float
@@ -92,35 +98,6 @@ def kdtw(x, y, sigma=1.0, epsilon=1e-3):
9298
return _kdtw_lk(x, y, local_kernel)
9399

94100

95-
def factory_kdtw_kernel(channels: int):
96-
"""
97-
Return a kdtw kernel callable function that flattened samples to (T, channels).
98-
99-
Parameters
100-
----------
101-
channels: int
102-
Number of channels per timepoint.
103-
104-
Returns
105-
-------
106-
kdtw_kernel : callable
107-
A callable kernel function that computes the KDTW similarity between two
108-
time series samples. The function signature is the same as the kdtw
109-
function.
110-
"""
111-
112-
def kdtw_kernel(x, y, sigma=1.0, epsilon=1e-3):
113-
if x.ndim == 1:
114-
T = x.size // channels
115-
x = x.reshape(T, channels)
116-
if y.ndim == 1:
117-
T = y.size // channels
118-
y = y.reshape(T, channels)
119-
return kdtw(x, y, sigma=sigma, epsilon=epsilon)
120-
121-
return kdtw_kernel
122-
123-
124101
class TimeSeriesKernelKMeans(BaseClusterer):
125102
"""Kernel K Means [1]_: wrapper of the ``tslearn`` implementation.
126103
@@ -255,7 +232,18 @@ def _fit(self, X, y=None):
255232
verbose = 1
256233

257234
if self.kernel == "kdtw":
258-
self.kernel = factory_kdtw_kernel(channels=X.shape[1])
235+
n_channels = X.shape[1]
236+
237+
def kdtw_kernel(x, y, sigma=1.0, epsilon=1e-3):
238+
if x.ndim == 1:
239+
T = x.size // n_channels
240+
x = x.reshape(T, n_channels)
241+
if y.ndim == 1:
242+
T = y.size // n_channels
243+
y = y.reshape(T, n_channels)
244+
return _kdtw(x, y, sigma=sigma, epsilon=epsilon)
245+
246+
self.kernel = kdtw_kernel
259247

260248
self._tslearn_kernel_k_means = TsLearnKernelKMeans(
261249
n_clusters=self.n_clusters,

aeon/distances/elastic/_bounding_matrix.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,14 @@ def create_bounding_matrix(
6363
def _itakura_parallelogram(x_size: int, y_size: int, max_slope_percent: float):
6464
"""Itakura parallelogram bounding matrix.
6565
66-
This code was adapted from pyts. This link to the original code:
66+
This code was adapted from the tslearn and pyts functions.
67+
68+
pyts code:
6769
https://pyts.readthedocs.io/en/latest/_modules/pyts/metrics/dtw.html#itakura_parallelogram
70+
Copyright (c) 2018, Johann Faouzi and pyts contributors, BSD-3
71+
tslearn code (line 974):
72+
https://github.com/tslearn-team/tslearn/blob/main/tslearn/metrics/dtw_variants.py
73+
Copyright (c) 2017, Romain Tavenard, BSD-2
6874
"""
6975
one_percent = min(x_size, y_size) / 100
7076
max_slope = math.floor((max_slope_percent * one_percent) * 100)

aeon/regression/deep_learning/_lite_time.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ class LITETimeRegressor(BaseRegressor):
105105
-----
106106
Adapted from the implementation from Ismail-Fawaz et. al
107107
https://github.com/MSD-IRIMAS/LITE
108+
by the code owner.
108109
109110
References
110111
----------
@@ -388,6 +389,7 @@ class IndividualLITERegressor(BaseDeepRegressor):
388389
-----
389390
Adapted from the implementation from Ismail-Fawaz et. al
390391
https://github.com/MSD-IRIMAS/LITE
392+
by the code owner.
391393
392394
References
393395
----------

aeon/segmentation/_ggs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
Based on the work from [1]_.
2424
2525
- source code adapted based on: https://github.com/cvxgrp/GGS
26+
Copyright (c) 2018, Stanford University Convex Optimization Group, BSD-2
2627
- paper available at: https://stanford.edu/~boyd/papers/pdf/ggs.pdf
2728
2829
References

aeon/transformations/collection/convolution_based/_minirocket.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class MiniRocket(BaseCollectionTransformer):
5555
Notes
5656
-----
5757
Directly adapted from the original implementation
58-
https://github.com/angus924/minirocket.
58+
https://github.com/angus924/minirocket with owner permission.
5959
6060
Examples
6161
--------

aeon/transformations/series/_bkfilter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ class BKFilter(BaseSeriesTransformer):
3434
3535
Notes
3636
-----
37-
Adapted from statsmodels implementation
37+
Adapted from statsmodels 0.14.4 implementation
3838
https://github.com/statsmodels/statsmodels/blob/main/statsmodels/tsa/filters/bk_filter.py
39+
Copyright (c) 2009-2018 statsmodels Developers, BSD-3
3940
4041
References
4142
----------

aeon/utils/show_versions.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
"""Utility methods to print system info for debugging.
2-
3-
Adapted from the sklearn show_versions function.
4-
"""
1+
"""Utility methods to print system info for debugging."""
52

63
__maintainer__ = ["MatthewMiddlehurst"]
74
__all__ = ["show_versions"]
@@ -37,6 +34,12 @@ def show_versions(as_str: bool = False) -> Union[str, None]:
3734
str or None
3835
The output string if `as_str` is True, otherwise None.
3936
37+
Notes
38+
-----
39+
Adapted from the scikit-learn 1.5.0 show_versions function.
40+
https://github.com/scikit-learn/scikit-learn/
41+
Copyright (c) 2007-2024 The scikit-learn developers, BSD-3
42+
4043
Examples
4144
--------
4245
>>> from aeon.utils import show_versions

aeon/visualisation/results/_critical_difference.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ def plot_critical_difference(
8888
overall performance in general, and such comparisons should be seen as exploratory
8989
analysis rather than designed experiments to test an a priori hypothesis.
9090
91-
Parts of the code are adapted from here:
92-
https://github.com/hfawaz/cd-diagram
91+
Parts of the code are adapted from https://github.com/hfawaz/cd-diagram
92+
with permission from the owner.
9393
9494
Parameters
9595
----------

0 commit comments

Comments
 (0)