diff --git a/analytics/detectors/pattern_detector.py b/analytics/detectors/pattern_detector.py index 38e8474..344b54b 100644 --- a/analytics/detectors/pattern_detector.py +++ b/analytics/detectors/pattern_detector.py @@ -62,7 +62,7 @@ class PatternDetector: segments = self.data_prov.transform_anomalies(segments) # TODO: pass only part of dataframe that has segments - await self.model.fit(dataframe, segments) + self.model.fit(dataframe, segments) self.__save_model() return 0 @@ -77,7 +77,7 @@ class PatternDetector: start_index = max(0, start_index - window_size) dataframe = self.data_prov.get_data_range(start_index) - predicted_indexes = await self.model.predict(dataframe) + predicted_indexes = self.model.predict(dataframe) predicted_indexes = [(x, y) for (x, y) in predicted_indexes if x >= start_index and y >= start_index] predicted_times = self.data_prov.inverse_transform_indexes(predicted_indexes) diff --git a/analytics/models/custom_model.py b/analytics/models/custom_model.py index 8d7a60b..8c8f5a8 100644 --- a/analytics/models/custom_model.py +++ b/analytics/models/custom_model.py @@ -10,8 +10,8 @@ class CustomModel(Model): # It will be saved in filesystem and loaded after server restart self.state = {} - async def fit(self, dataframe, segments): + def fit(self, dataframe, segments): pass - async def predict(self, dataframe): + def predict(self, dataframe): return [] diff --git a/analytics/models/jump_model.py b/analytics/models/jump_model.py index c0007ff..68289ec 100644 --- a/analytics/models/jump_model.py +++ b/analytics/models/jump_model.py @@ -19,7 +19,7 @@ class JumpModel(Model): 'convolve_max': WINDOW_SIZE } - async def fit(self, dataframe, segments): + def fit(self, dataframe, segments): self.segments = segments #self.alpha_finder() data = dataframe['value'] @@ -72,17 +72,17 @@ class JumpModel(Model): else: self.state['convolve_max'] = WINDOW_SIZE # макс метрика свертки равна отступу(WINDOW_SIZE), вау! - async def predict(self, dataframe): + def predict(self, dataframe): data = dataframe['value'] - result = await self.__predict(data) + result = self.__predict(data) result.sort() if len(self.segments) > 0: result = [segment for segment in result if not utils.is_intersect(segment, self.segments)] return result - async def __predict(self, data): + def __predict(self, data): window_size = 24 all_max_flatten_data = data.rolling(window=window_size).mean() all_mins = argrelextrema(np.array(all_max_flatten_data), np.less)[0] diff --git a/analytics/models/model.py b/analytics/models/model.py index 74adfae..b6a8abc 100644 --- a/analytics/models/model.py +++ b/analytics/models/model.py @@ -14,11 +14,11 @@ class Model(ABC): self.segments = [] @abstractmethod - async def fit(self, dataframe: DataFrame, segments: list): + def fit(self, dataframe: DataFrame, segments: list): pass @abstractmethod - async def predict(self, dataframe: DataFrame) -> list: + def predict(self, dataframe: DataFrame) -> list: pass def save(self, model_filename: str): diff --git a/analytics/models/peaks_model.py b/analytics/models/peaks_model.py index 9bcec9c..f65ea3c 100644 --- a/analytics/models/peaks_model.py +++ b/analytics/models/peaks_model.py @@ -10,10 +10,10 @@ class PeaksModel(Model): def __init__(self): super() - async def fit(self, dataset, contamination=0.005): + def fit(self, dataset, contamination=0.005): pass - async def predict(self, dataframe): + def predict(self, dataframe): array = dataframe['value'].as_matrix() window_size = 20 # window = np.ones(101) diff --git a/analytics/models/step_model.py b/analytics/models/step_model.py index 69bd879..d9d78f5 100644 --- a/analytics/models/step_model.py +++ b/analytics/models/step_model.py @@ -19,7 +19,7 @@ class StepModel(Model): 'convolve_max': 570000 } - async def fit(self, dataframe, segments): + def fit(self, dataframe, segments): self.segments = segments data = dataframe['value'] confidences = [] @@ -47,17 +47,17 @@ class StepModel(Model): else: self.state['convolve_max'] = 570000 - async def predict(self, dataframe): + def predict(self, dataframe): data = dataframe['value'] - result = await self.__predict(data) + result = self.__predict(data) result.sort() if len(self.segments) > 0: result = [segment for segment in result if not utils.is_intersect(segment, self.segments)] return result - async def __predict(self, data): + def __predict(self, data): window_size = 24 all_max_flatten_data = data.rolling(window=window_size).mean() all_mins = argrelextrema(np.array(all_max_flatten_data), np.less)[0]