Skip to content

Commit c5bbc96

Browse files
committed
Added reference and example code, updated description
1 parent 97c5f25 commit c5bbc96

File tree

1 file changed

+29
-3
lines changed
  • aeon/anomaly_detection/series/distance_based

1 file changed

+29
-3
lines changed

aeon/anomaly_detection/series/distance_based/_rockad.py

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ class ROCKAD(BaseSeriesAnomalyDetector):
1919
"""
2020
ROCKET-based Anomaly Detector (ROCKAD).
2121
22+
Adapted ROCKAD [1]_ version to detect anomalies on time-points.
2223
ROCKAD leverages the ROCKET transformation for feature extraction from
2324
time series data and applies the scikit learn k-nearest neighbors (k-NN)
2425
approach with bootstrap aggregation for robust anomaly detection.
2526
After windowing, the data gets transformed into the ROCKET feature space.
2627
Then the windows are compared based on the feature space by
27-
finding the nearest neighbours.
28+
finding the nearest neighbours. Whole-series based ROCKAD as proposed in
29+
[1]_ can be found at aeon/anomaly_detection/whole_series/_rockad.py
2830
2931
This class supports both univariate and multivariate time series and
3032
provides options for normalizing features, applying power transformations,
@@ -53,6 +55,30 @@ class ROCKAD(BaseSeriesAnomalyDetector):
5355
random_state : int, default=42
5456
Random seed for reproducibility.
5557
58+
References
59+
----------
60+
.. [1] Theissler, A., Wengert, M., Gerschner, F. (2023).
61+
ROCKAD: Transferring ROCKET to Whole Time Series Anomaly Detection.
62+
In: Crémilleux, B., Hess, S., Nijssen, S. (eds) Advances in Intelligent
63+
Data Analysis XXI. IDA 2023. Lecture Notes in Computer Science,
64+
vol 13876. Springer, Cham. https://doi.org/10.1007/978-3-031-30047-9_33
65+
66+
Examples
67+
--------
68+
>>> import numpy as np
69+
>>> from aeon.anomaly_detection.series.distance_based import ROCKAD
70+
>>> rng = np.random.default_rng(seed=42)
71+
>>> X_train = rng.normal(loc=0.0, scale=1.0, size=(1000,))
72+
>>> X_test = rng.normal(loc=0.0, scale=1.0, size=(20,))
73+
>>> X_test[15:20] -= 5
74+
>>> detector = ROCKAD(window_size=15,n_estimators=10,n_kernels=10,n_neighbors=3)
75+
>>> detector.fit(X_train)
76+
>>> detector.predict(X_test)
77+
array([0. 0.00554713 0.06990941 0.2288106 0.32382585 0.43652154
78+
0.43652154 0.43652154 0.43652154 0.43652154 0.43652154 0.43652154
79+
0.43652154 0.43652154 0.43652154 0.52382585 0.65200875 0.80313368
80+
0.85194344 1. ])
81+
5682
Attributes
5783
----------
5884
rocket_transformer_ : Optional[Rocket]
@@ -206,7 +232,7 @@ def _fit_predict(self, X: np.ndarray, y: Optional[np.ndarray] = None) -> np.ndar
206232
point_anomaly_scores = self._inner_predict(_X, padding)
207233
return point_anomaly_scores
208234

209-
def _inner_predict(self, X: np.ndarray, padding: int) -> np.ndarray:
235+
def _inner_predict(self, X: np.ndarray, padding: int) -> np.ndarray:
210236
"""
211237
Predict the anomaly score for each time-point in the input data.
212238
@@ -253,4 +279,4 @@ def _inner_predict(self, X: np.ndarray, padding: int) -> np.ndarray:
253279
point_anomaly_scores.max() - point_anomaly_scores.min()
254280
)
255281

256-
return point_anomaly_scores
282+
return point_anomaly_scores

0 commit comments

Comments
 (0)