diff --git a/analytics/anomaly_model.py b/analytics/anomaly_model.py index a42de7f..f2f38d8 100644 --- a/analytics/anomaly_model.py +++ b/analytics/anomaly_model.py @@ -76,7 +76,7 @@ class AnomalyModel: self.model = self.create_algorithm() self.model.fit(train_augmented, confidence) if len(anomalies) > 0: - last_dataframe_time = dataframe.iloc[- 1]['timestamp'] + last_dataframe_time = dataframe.iloc[-1]['timestamp'] last_prediction_time = int(last_dataframe_time.timestamp() * 1000) else: last_prediction_time = 0 diff --git a/analytics/step_detector.py b/analytics/step_detector.py index 90d761a..d2ce685 100644 --- a/analytics/step_detector.py +++ b/analytics/step_detector.py @@ -138,7 +138,7 @@ class StepDetector: self.__optimize_threshold(data, self.window_size, segments, contamination) def __optimize_threshold(self, data, window_size, segments, contamination): - step_size = 3 + step_size = window_size // 2 pattern = np.concatenate([[-1] * step_size, [1] * step_size]) corr_res = np.correlate(data, pattern, mode='same') / window_size corr_res = np.concatenate((np.zeros(step_size), corr_res, np.zeros(step_size)))