From ec6decfebdb73706d8ef120137b9d404b2d5cfcd Mon Sep 17 00:00:00 2001 From: Evgeny Smyshlyaev Date: Mon, 20 May 2019 15:24:48 +0300 Subject: [PATCH] Anomaly detector: remove last value (#672) --- analytics/analytics/detectors/anomaly_detector.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/analytics/analytics/detectors/anomaly_detector.py b/analytics/analytics/detectors/anomaly_detector.py index ed207dd..8e40212 100644 --- a/analytics/analytics/detectors/anomaly_detector.py +++ b/analytics/analytics/detectors/anomaly_detector.py @@ -62,12 +62,8 @@ class AnomalyDetector(ProcessingDetector): data = dataframe['value'] segments = cache.get('segments') - last_value = None - if cache is not None: - last_value = cache.get('last_value') - time_step = utils.find_interval(dataframe) - smoothed_data = utils.exponential_smoothing(data, cache['alpha'], last_value) + smoothed_data = utils.exponential_smoothing(data, cache['alpha']) # TODO: use class for cache to avoid using string literals upper_bound = smoothed_data + cache['confidence'] @@ -113,8 +109,6 @@ class AnomalyDetector(ProcessingDetector): last_dataframe_time = dataframe.iloc[-1]['timestamp'] last_detection_time = utils.convert_pd_timestamp_to_ms(last_dataframe_time) - # TODO: ['lastValue'] -> .last_value - cache['lastValue'] = smoothed_data.values[-1] return DetectionResult(cache, segments, last_detection_time, time_step) @@ -171,7 +165,7 @@ class AnomalyDetector(ProcessingDetector): segments = cache.get('segments') # TODO: exponential_smoothing should return dataframe with related timestamps - smoothed = utils.exponential_smoothing(dataframe['value'], cache['alpha'], cache.get('lastValue')) + smoothed = utils.exponential_smoothing(dataframe['value'], cache['alpha']) upper_bound = smoothed + cache['confidence'] lower_bound = smoothed - cache['confidence']