Skip to content

Commit 97c5f25

Browse files
committed
move predict_proba logic into inner_predict for code consistency
1 parent 7508ffd commit 97c5f25

File tree

1 file changed

+12
-18
lines changed
  • aeon/anomaly_detection/series/distance_based

1 file changed

+12
-18
lines changed

aeon/anomaly_detection/series/distance_based/_rockad.py

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -206,23 +206,9 @@ def _fit_predict(self, X: np.ndarray, y: Optional[np.ndarray] = None) -> np.ndar
206206
point_anomaly_scores = self._inner_predict(_X, padding)
207207
return point_anomaly_scores
208208

209-
def _inner_predict(self, X: np.ndarray, padding: int) -> np.ndarray:
210-
211-
anomaly_scores = self._predict_proba(X)
212-
213-
point_anomaly_scores = reverse_windowing(
214-
anomaly_scores, self.window_size, np.nanmean, self.stride, padding
215-
)
216-
217-
point_anomaly_scores = (point_anomaly_scores - point_anomaly_scores.min()) / (
218-
point_anomaly_scores.max() - point_anomaly_scores.min()
219-
)
220-
221-
return point_anomaly_scores
222-
223-
def _predict_proba(self, X):
209+
def _inner_predict(self, X: np.ndarray, padding: int) -> np.ndarray:
224210
"""
225-
Predicts the probability of anomalies for the input data.
211+
Predict the anomaly score for each time-point in the input data.
226212
227213
Parameters
228214
----------
@@ -257,6 +243,14 @@ def _predict_proba(self, X):
257243
y_scores[:, idx] = scores
258244

259245
# Average the scores to get the final score for each time series
260-
y_scores = y_scores.mean(axis=1)
246+
anomaly_scores = y_scores.mean(axis=1)
247+
248+
point_anomaly_scores = reverse_windowing(
249+
anomaly_scores, self.window_size, np.nanmean, self.stride, padding
250+
)
251+
252+
point_anomaly_scores = (point_anomaly_scores - point_anomaly_scores.min()) / (
253+
point_anomaly_scores.max() - point_anomaly_scores.min()
254+
)
261255

262-
return y_scores
256+
return point_anomaly_scores

0 commit comments

Comments
 (0)