Skip to content

Commit

Permalink
Merge branch 'main' into aedcnn-clusterer
Browse files Browse the repository at this point in the history
  • Loading branch information
aadya940 authored Nov 11, 2024
2 parents 9ce2e7e + c267ab8 commit 688c129
Show file tree
Hide file tree
Showing 131 changed files with 8,173 additions and 4,292 deletions.
4 changes: 2 additions & 2 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -2357,10 +2357,10 @@
]
},
{
"login": "codelionx",
"login": "SebastianSchmidl",
"name": "Sebastian Schmidl",
"avatar_url": "https://avatars.githubusercontent.com/u/10573700?v=4",
"profile": "https://github.com/codelionx",
"profile": "https://github.com/SebastianSchmidl",
"contributions": [
"bug",
"code",
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ body:
Please run the following code snippet and paste the output here.
```python
from aeon.utils import show_versions; show_versions()
from aeon import show_versions; show_versions()
```
placeholder: |
<details>
Expand Down
4 changes: 2 additions & 2 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Only users with write access to the repository will be automatically added as
# reviewers and contacted.

aeon/anomaly_detection/ @CodeLionX @MatthewMiddlehurst
aeon/anomaly_detection/ @SebastianSchmidl @MatthewMiddlehurst

aeon/benchmarking/ @TonyBagnall @MatthewMiddlehurst @hadifawaz1999 @dguijo

Expand All @@ -17,7 +17,7 @@ aeon/distances/ @chrisholder @TonyBagnall

aeon/networks/ @hadifawaz1999

aeon/performance_metrics/anomaly_detection/ @codelionx @MatthewMiddlehurst
aeon/performance_metrics/anomaly_detection/ @SebastianSchmidl @MatthewMiddlehurst

aeon/regression/ @MatthewMiddlehurst @TonyBagnall @dguijo
aeon/regression/deep_learning @hadifawaz1999 @MatthewMiddlehurst @TonyBagnall @dguijo
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<td align="center" valign="top" width="12.5%"><a href="https://github.com/dasgupsa"><img src="https://avatars2.githubusercontent.com/u/10398956?v=4?s=80" width="80px;" alt="Saurabh Dasgupta"/><br /><sub><b>Saurabh Dasgupta</b></sub></a><br /><a href="https://github.com/aeon-toolkit/aeon/commits?author=dasgupsa" title="Code">💻</a></td>
<td align="center" valign="top" width="12.5%"><a href="https://github.com/SebasKoel"><img src="https://avatars3.githubusercontent.com/u/66252156?v=4?s=80" width="80px;" alt="Sebastiaan Koel"/><br /><sub><b>Sebastiaan Koel</b></sub></a><br /><a href="https://github.com/aeon-toolkit/aeon/commits?author=SebasKoel" title="Code">💻</a> <a href="https://github.com/aeon-toolkit/aeon/commits?author=SebasKoel" title="Documentation">📖</a></td>
<td align="center" valign="top" width="12.5%"><a href="https://github.com/shagn"><img src="https://avatars.githubusercontent.com/u/16029092?v=4?s=80" width="80px;" alt="Sebastian Hagn"/><br /><sub><b>Sebastian Hagn</b></sub></a><br /><a href="https://github.com/aeon-toolkit/aeon/commits?author=shagn" title="Documentation">📖</a></td>
<td align="center" valign="top" width="12.5%"><a href="https://github.com/codelionx"><img src="https://avatars.githubusercontent.com/u/10573700?v=4?s=80" width="80px;" alt="Sebastian Schmidl"/><br /><sub><b>Sebastian Schmidl</b></sub></a><br /><a href="https://github.com/aeon-toolkit/aeon/issues?q=author%3Acodelionx" title="Bug reports">🐛</a> <a href="https://github.com/aeon-toolkit/aeon/commits?author=codelionx" title="Code">💻</a> <a href="https://github.com/aeon-toolkit/aeon/commits?author=codelionx" title="Documentation">📖</a> <a href="#research-codelionx" title="Research">🔬</a> <a href="https://github.com/aeon-toolkit/aeon/commits?author=codelionx" title="Tests">⚠️</a> <a href="https://github.com/aeon-toolkit/aeon/pulls?q=is%3Apr+reviewed-by%3Acodelionx" title="Reviewed Pull Requests">👀</a> <a href="#data-codelionx" title="Data">🔣</a></td>
<td align="center" valign="top" width="12.5%"><a href="https://github.com/SebastianSchmidl"><img src="https://avatars.githubusercontent.com/u/10573700?v=4?s=80" width="80px;" alt="Sebastian Schmidl"/><br /><sub><b>Sebastian Schmidl</b></sub></a><br /><a href="https://github.com/aeon-toolkit/aeon/issues?q=author%3ASebastianSchmidl" title="Bug reports">🐛</a> <a href="https://github.com/aeon-toolkit/aeon/commits?author=SebastianSchmidl" title="Code">💻</a> <a href="https://github.com/aeon-toolkit/aeon/commits?author=SebastianSchmidl" title="Documentation">📖</a> <a href="#research-SebastianSchmidl" title="Research">🔬</a> <a href="https://github.com/aeon-toolkit/aeon/commits?author=SebastianSchmidl" title="Tests">⚠️</a> <a href="https://github.com/aeon-toolkit/aeon/pulls?q=is%3Apr+reviewed-by%3ASebastianSchmidl" title="Reviewed Pull Requests">👀</a> <a href="#data-SebastianSchmidl" title="Data">🔣</a></td>
<td align="center" valign="top" width="12.5%"><a href="https://github.com/Sharathchenna"><img src="https://avatars.githubusercontent.com/u/50939688?v=4?s=80" width="80px;" alt="Sharathchenna"/><br /><sub><b>Sharathchenna</b></sub></a><br /><a href="https://github.com/aeon-toolkit/aeon/commits?author=Sharathchenna" title="Code">💻</a></td>
<td align="center" valign="top" width="12.5%"><a href="https://github.com/AurumnPegasus"><img src="https://avatars.githubusercontent.com/u/54315149?v=4?s=80" width="80px;" alt="Shivansh Subramanian"/><br /><sub><b>Shivansh Subramanian</b></sub></a><br /><a href="https://github.com/aeon-toolkit/aeon/commits?author=AurumnPegasus" title="Documentation">📖</a> <a href="https://github.com/aeon-toolkit/aeon/commits?author=AurumnPegasus" title="Code">💻</a></td>
<td align="center" valign="top" width="12.5%"><a href="https://www.linkedin.com/in/solomon-botchway-a1383821b/"><img src="https://avatars.githubusercontent.com/u/62394255?v=4?s=80" width="80px;" alt="Solomon Botchway"/><br /><sub><b>Solomon Botchway</b></sub></a><br /><a href="#maintenance-snnbotchway" title="Maintenance">🚧</a></td>
Expand Down
2 changes: 1 addition & 1 deletion aeon/anomaly_detection/_dwt_mlead.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""DWT-MLEAD anomaly detector."""

__maintainer__ = ["CodeLionX"]
__maintainer__ = ["SebastianSchmidl"]
__all__ = ["DWT_MLEAD"]

import warnings
Expand Down
2 changes: 1 addition & 1 deletion aeon/anomaly_detection/_kmeans.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""k-Means anomaly detector."""

__maintainer__ = ["CodeLionX"]
__maintainer__ = ["SebastianSchmidl"]
__all__ = ["KMeansAD"]

from typing import Optional
Expand Down
2 changes: 1 addition & 1 deletion aeon/anomaly_detection/_pyodadapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

__maintainer__ = ["CodeLionX"]
__maintainer__ = ["SebastianSchmidl"]
__all__ = ["PyODAdapter"]

from typing import TYPE_CHECKING, Any
Expand Down
2 changes: 1 addition & 1 deletion aeon/anomaly_detection/_stomp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

__maintainer__ = ["CodeLionX"]
__maintainer__ = ["SebastianSchmidl"]
__all__ = ["STOMP"]

import numpy as np
Expand Down
14 changes: 8 additions & 6 deletions aeon/anomaly_detection/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,20 @@
import pytest
from numpy.testing import assert_almost_equal

from aeon.testing.data_generation._legacy import make_series
from aeon.testing.data_generation import (
make_example_1d_numpy,
make_example_2d_numpy_series,
)
from aeon.testing.mock_estimators._mock_anomaly_detectors import (
MockAnomalyDetector,
MockAnomalyDetectorRequiresFit,
MockAnomalyDetectorRequiresY,
)

test_series = make_series(n_timepoints=10, return_numpy=True)
test_series_2d = make_series(n_timepoints=10, n_columns=2, return_numpy=True).T
test_series_pd = make_series(n_timepoints=10)
test_series_pd_2d = make_series(n_timepoints=10, n_columns=2).T

test_series = make_example_1d_numpy(n_timepoints=10)
test_series_2d = make_example_2d_numpy_series(n_timepoints=10, n_channels=2)
test_series_pd = pd.Series(test_series)
test_series_pd_2d = pd.DataFrame(test_series_2d)
test_y = np.array([0, 0, 0, 1, 1, 0, 0, 0, 1, 1])


Expand Down
29 changes: 25 additions & 4 deletions aeon/anomaly_detection/tests/test_dwt_mlead.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,46 @@
"""Tests for the DWT_MLEAD class."""

__maintainer__ = ["CodeLionX"]
__maintainer__ = ["SebastianSchmidl"]

import numpy as np
import pytest
from sklearn.utils import check_random_state

from aeon.anomaly_detection import DWT_MLEAD
from aeon.testing.data_generation._legacy import make_series


def test_dwt_mlead_output():
"""Test DWT_MLEAD output."""
series = make_series(n_timepoints=100, return_numpy=True, random_state=42)
rng = check_random_state(seed=42)
series = rng.normal(size=(100,))
series[50:58] -= 5

ad = DWT_MLEAD(start_level=2)
pred = ad.predict(series)

assert pred.shape == (100,)
assert pred.dtype == np.float64
assert 50 <= np.argmax(pred) <= 58
assert 45 <= np.argmax(pred) <= 60


def test_dwt_mlead_incorrect_input():
"""Test DWT_MLEAD with incorrect input."""
rng = check_random_state(seed=42)
series = rng.normal(size=(100,))
with pytest.raises(ValueError, match="start_level must be >= 0"):
ad = DWT_MLEAD(start_level=-1)
ad.predict(series)
with pytest.raises(
ValueError, match="quantile_boundary_type must be 'percentile' or 'monte-carlo'"
):
ad = DWT_MLEAD(quantile_boundary_type="Arsenal")
ad.predict(series)
with pytest.raises(ValueError, match="epsilon must be in"):
ad = DWT_MLEAD(quantile_epsilon=-1.0)
ad.predict(series)
with pytest.raises(ValueError):
ad = DWT_MLEAD(start_level=100)
ad.predict(series)


def test_dwt_mlead_monte_carlo_unimplemented():
Expand Down
36 changes: 18 additions & 18 deletions aeon/anomaly_detection/tests/test_iforest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import numpy as np
import pytest
from sklearn.utils import check_random_state

from aeon.anomaly_detection import IsolationForest
from aeon.testing.data_generation._legacy import make_series
from aeon.utils.validation._dependencies import _check_soft_dependencies


Expand All @@ -14,7 +14,8 @@
)
def test_iforest_default():
"""Test IsolationForest."""
series = make_series(n_timepoints=80, return_numpy=True, random_state=0)
rng = check_random_state(0)
series = rng.normal(size=(80,))
series[50:58] -= 2

iforest = IsolationForest(window_size=10, stride=1, random_state=0)
Expand All @@ -31,9 +32,8 @@ def test_iforest_default():
)
def test_iforest_multivariate():
"""Test IsolationForest multivariate."""
series = make_series(
n_timepoints=80, n_columns=2, return_numpy=True, random_state=0
)
rng = check_random_state(0)
series = rng.normal(size=(80, 2))
series[50:58, 0] -= 2

iforest = IsolationForest(window_size=10, stride=1, random_state=0)
Expand All @@ -50,7 +50,8 @@ def test_iforest_multivariate():
)
def test_iforest_no_window_univariate():
"""Test IsolationForest without windows univariate."""
series = make_series(n_timepoints=80, return_numpy=True, random_state=0)
rng = check_random_state(0)
series = rng.normal(size=(80,))
series[50:58] -= 2
iforest = IsolationForest(window_size=1, stride=1, random_state=0)
pred = iforest.fit_predict(series, axis=0)
Expand All @@ -66,7 +67,9 @@ def test_iforest_no_window_univariate():
)
def test_iforest_stride():
"""Test IsolationForest with stride."""
series = make_series(n_timepoints=80, return_numpy=True, random_state=0)
rng = check_random_state(0)
series = rng.normal(size=(80,))

series[50:58] -= 2

iforest = IsolationForest(window_size=10, stride=2, random_state=0)
Expand All @@ -83,9 +86,8 @@ def test_iforest_stride():
)
def test_iforest_multivariate_stride():
"""Test IsolationForest multivariate with stride."""
series = make_series(
n_timepoints=80, n_columns=2, return_numpy=True, random_state=0
)
rng = check_random_state(0)
series = rng.normal(size=(80, 2))
series[50:58, 0] -= 2

iforest = IsolationForest(window_size=10, stride=2, random_state=0)
Expand All @@ -102,9 +104,10 @@ def test_iforest_multivariate_stride():
)
def test_iforest_semi_supervised_univariate():
"""Test IsolationForest semi-supervised univariate."""
series = make_series(n_timepoints=80, return_numpy=True, random_state=0)
rng = check_random_state(0)
series = rng.normal(size=(80,))
series[50:58] -= 2
train_series = make_series(n_timepoints=100, return_numpy=True, random_state=0)
train_series = rng.normal(size=(80,))

iforest = IsolationForest(window_size=10, stride=1, random_state=0)
iforest.fit(train_series, axis=0)
Expand All @@ -121,13 +124,10 @@ def test_iforest_semi_supervised_univariate():
)
def test_iforest_semi_supervised_multivariate():
"""Test IsolationForest semi-supervised multivariate."""
series = make_series(
n_timepoints=80, n_columns=2, return_numpy=True, random_state=0
)
rng = check_random_state(0)
series = rng.normal(size=(80, 2))
series[50:58, 0] -= 2
train_series = make_series(
n_timepoints=100, n_columns=2, return_numpy=True, random_state=0
)
train_series = rng.normal(size=(80, 2))

iforest = IsolationForest(window_size=10, stride=1, random_state=0)
iforest.fit(train_series, axis=0)
Expand Down
29 changes: 23 additions & 6 deletions aeon/anomaly_detection/tests/test_kmeans.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
"""Tests for the KMeansAD class."""

__maintainer__ = ["CodeLionX"]
__maintainer__ = ["SebastianSchmidl"]

import numpy as np
import pytest
from sklearn.utils import check_random_state

from aeon.anomaly_detection import KMeansAD
from aeon.testing.data_generation._legacy import make_series


def test_kmeansad_univariate():
"""Test KMeansAD univariate output."""
series = make_series(n_timepoints=100, return_numpy=True, random_state=42)
rng = check_random_state(seed=2)
series = rng.normal(size=(100,))
series[50:58] -= 5

ad = KMeansAD(n_clusters=2, window_size=10)
Expand All @@ -23,9 +25,8 @@ def test_kmeansad_univariate():

def test_kmeansad_multivariate():
"""Test KMeansAD multivariate output."""
series = make_series(
n_timepoints=100, n_columns=3, return_numpy=True, random_state=42
)
rng = check_random_state(seed=2)
series = rng.normal(size=(100, 3))
series[50:58, 0] -= 5
series[87:90, 1] += 0.1

Expand All @@ -35,3 +36,19 @@ def test_kmeansad_multivariate():
assert pred.shape == (100,)
assert pred.dtype == np.float64
assert 50 <= np.argmax(pred) <= 58


def test_kmeansad_incorrect_input():
"""Test KMeansAD univariate output."""
rng = check_random_state(seed=2)
series = rng.normal(size=(100,))

with pytest.raises(ValueError, match="The window size must be at least 1"):
ad = KMeansAD(window_size=0)
ad.fit_predict(series)
with pytest.raises(ValueError, match="The stride must be at least 1"):
ad = KMeansAD(stride=0)
ad.fit_predict(series)
with pytest.raises(ValueError, match="The number of clusters must be at least 1"):
ad = KMeansAD(n_clusters=0)
ad.fit_predict(series)
Loading

0 comments on commit 688c129

Please sign in to comment.