|
@@ -157,33 +157,6 @@ class MultiAutoRegOD(CollectiveBaseDetector): |
|
|
self._process_decision_scores() |
|
|
self._process_decision_scores() |
|
|
return self |
|
|
return self |
|
|
|
|
|
|
|
|
def predict(self, X): # pragma: no cover |
|
|
|
|
|
"""Predict if a particular sample is an outlier or not. |
|
|
|
|
|
|
|
|
|
|
|
Parameters |
|
|
|
|
|
---------- |
|
|
|
|
|
X : numpy array of shape (n_samples, n_features) |
|
|
|
|
|
The input samples. |
|
|
|
|
|
|
|
|
|
|
|
Returns |
|
|
|
|
|
------- |
|
|
|
|
|
outlier_labels : numpy array of shape (n_samples,) |
|
|
|
|
|
For each observation, tells whether or not |
|
|
|
|
|
it should be considered as an outlier according to the |
|
|
|
|
|
fitted model. 0 stands for inliers and 1 for outliers. |
|
|
|
|
|
""" |
|
|
|
|
|
|
|
|
|
|
|
check_is_fitted(self, ['decision_scores_', 'threshold_', 'labels_']) |
|
|
|
|
|
|
|
|
|
|
|
pred_score, X_left_inds, X_right_inds = self.decision_function(X) |
|
|
|
|
|
|
|
|
|
|
|
pred_score = np.concatenate((np.zeros((self.window_size,)), pred_score)) |
|
|
|
|
|
X_left_inds = np.concatenate((np.zeros((self.window_size,)), X_left_inds)) |
|
|
|
|
|
X_right_inds = np.concatenate((np.zeros((self.window_size,)), X_right_inds)) |
|
|
|
|
|
|
|
|
|
|
|
return (pred_score > self.threshold_).astype( |
|
|
|
|
|
'int').ravel(), X_left_inds.ravel(), X_right_inds.ravel() |
|
|
|
|
|
|
|
|
|
|
|
def decision_function(self, X: np.array): |
|
|
def decision_function(self, X: np.array): |
|
|
"""Predict raw anomaly scores of X using the fitted detector. |
|
|
"""Predict raw anomaly scores of X using the fitted detector. |
|
|
|
|
|
|
|
@@ -221,6 +194,12 @@ class MultiAutoRegOD(CollectiveBaseDetector): |
|
|
decison_mat_scaled = self._score_scalar.transform(decison_mat) |
|
|
decison_mat_scaled = self._score_scalar.transform(decison_mat) |
|
|
decision_scores = self._score_combination(decison_mat_scaled) |
|
|
decision_scores = self._score_combination(decison_mat_scaled) |
|
|
|
|
|
|
|
|
|
|
|
# print(decision_scores.shape, X_left_inds.shape, X_right_inds.shape) |
|
|
|
|
|
decision_scores = np.concatenate((np.zeros((self.window_size,)), decision_scores)) |
|
|
|
|
|
X_left_inds = np.concatenate(((-self.window_size)*np.ones((self.window_size,)).astype(np.int), X_left_inds)) |
|
|
|
|
|
X_right_inds = np.concatenate((np.zeros((self.window_size,)).astype(np.int), X_right_inds)) |
|
|
|
|
|
# print(decision_scores.shape, X_left_inds.shape, X_right_inds.shape) |
|
|
|
|
|
|
|
|
return decision_scores, X_left_inds, X_right_inds |
|
|
return decision_scores, X_left_inds, X_right_inds |
|
|
|
|
|
|
|
|
|
|
|
|
|
|