From a260f86cb8a387fa147a3569d3c70d4d0f2d1df9 Mon Sep 17 00:00:00 2001 From: rozetko Date: Thu, 21 Jun 2018 14:09:28 +0300 Subject: [PATCH] drops hot fix --- analytics/step_detector.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/analytics/step_detector.py b/analytics/step_detector.py index 3831c67..7fabc63 100644 --- a/analytics/step_detector.py +++ b/analytics/step_detector.py @@ -62,7 +62,31 @@ class StepDetector: if all_max_flatten_data[i] < extrema_list[i]: segments.append(i - 20) - return [(x - 1, x + 1) for x in segments] + return [(x - 1, x + 1) for x in self.__filter_prediction(segments, all_max_flatten_data)] + + def __filter_prediction(self, segments, all_max_flatten_data): + delete_list = [] + for i in range(1, len(segments)): + if segments[i] < segments[i-1] + 500: + delete_list.append(segments[i]) + + for item in delete_list: + segments.remove(item) + + # delete_list = [] + # for i in segments: + # new_data = all_max_flatten_data[i-150:i+50] + # min_value = 100 + # for j in new_data: + # if j < min_value: + # min_value = j + # if all_max_flatten_data[i] > min_value: + # delete_list.append(i) + + # for item in delete_list: + # segments.remove(item) + + return segments def save(self, model_filename): with open(model_filename, 'wb') as file: