Skip to content

Commit

Permalink
Automatic pre-commit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramana-Raja authored and github-actions[bot] committed Mar 4, 2025
1 parent eb3aaa5 commit 60cd10c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
17 changes: 12 additions & 5 deletions aeon/anomaly_detection/_idk.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""IDK2 anomaly detector."""

from typing import Optional

import numpy as np
Expand Down Expand Up @@ -169,22 +170,28 @@ def _idk_fixed_window(self, X, rng):
featuremap_count, [featuremap_count.shape[0] - 1], axis=0
)

return self._compute_idk_score(featuremap_count, psi=self.psi2, t=self.t, rng=rng)
return self._compute_idk_score(
featuremap_count, psi=self.psi2, t=self.t, rng=rng
)

def _idk_square_sliding(self, X, rng):
point_fm_list = self._generate_feature_map(X=X, psi=self.psi1, t=self.t, rng=rng)
point_fm_list = self._generate_feature_map(
X=X, psi=self.psi1, t=self.t, rng=rng
)
point_fm_list = np.insert(point_fm_list, 0, 0, axis=0)
cumsum = np.cumsum(point_fm_list, axis=0)

subsequence_fm_list = (cumsum[self.width :] - cumsum[: -self.width]) / float(
self.width
)

return self._compute_idk_score(X=subsequence_fm_list, psi=self.psi2, t=self.t, rng=rng)
return self._compute_idk_score(
X=subsequence_fm_list, psi=self.psi2, t=self.t, rng=rng
)

def _predict(self, X):
rng = np.random.default_rng(self.random_state)
if self.sliding :
if self.sliding:
sliding_output = self._idk_square_sliding(X, rng)
reversed_output = reverse_windowing(
y=sliding_output,
Expand Down Expand Up @@ -217,4 +224,4 @@ def _get_test_params(cls, parameter_set="default"):
"psi1": 8,
"psi2": 2,
"width": 1,
}
}
2 changes: 1 addition & 1 deletion aeon/anomaly_detection/tests/test_idk.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test_idk_univariate_custom_series():
-0.55382284,
]
)
expected = [0.21 ,0.17 ,0.17 ,0.3 ,0.38 ,0.35 ,0.17 ,0.36 ,0.21 ,0.17]
expected = [0.21, 0.17, 0.17, 0.3, 0.38, 0.35, 0.17, 0.36, 0.21, 0.17]

ad_2 = IDK2(psi1=4, psi2=2, width=1, t=10, random_state=2)
pred2 = ad_2.fit_predict(series1)
Expand Down

0 comments on commit 60cd10c

Please sign in to comment.