From f27f5561ddab2c3163cc20f3297f53f2f53b3884 Mon Sep 17 00:00:00 2001 From: rozetko Date: Tue, 29 May 2018 20:31:49 +0300 Subject: [PATCH] 151 fix error on second learning (#5) --- README.md | 5 +++++ analytics/anomaly_model.py | 10 ++++------ analytics/data_preprocessor.py | 3 +-- analytics/data_provider.py | 4 ++-- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 1654637..5b8fa1e 100644 --- a/README.md +++ b/README.md @@ -66,3 +66,8 @@ export HASTIC_PORT= cd ./hastic-server/server npm start ``` + +#### Known bugs & issues + +- If you add labeled segments while learning - it fails +- Dataset doesn't get updated after 1st learning diff --git a/analytics/anomaly_model.py b/analytics/anomaly_model.py index 30cf7b3..a42de7f 100644 --- a/analytics/anomaly_model.py +++ b/analytics/anomaly_model.py @@ -64,14 +64,12 @@ class AnomalyModel: if len(anomalies) > 0: confidence = 0.0 min_time, max_time = self.anomalies_box(anomalies) - start_index = dataframe[dataframe['timestamp'] >= min_time].index[0] - stop_index = dataframe[dataframe['timestamp'] > max_time].index[0] - start_index, stop_index = self.preprocessor.expand_indexes(start_index, stop_index) - dataframe = dataframe[start_index:stop_index] + dataframe = dataframe[dataframe['timestamp'] <= max_time] + dataframe = dataframe[dataframe['timestamp'] >= min_time] train_augmented = self.preprocessor.get_augmented_data( - start_index, - stop_index, + dataframe.index[0], + dataframe.index[-1], anomalies ) diff --git a/analytics/data_preprocessor.py b/analytics/data_preprocessor.py index 6fac01a..9728c56 100644 --- a/analytics/data_preprocessor.py +++ b/analytics/data_preprocessor.py @@ -83,8 +83,7 @@ class data_preprocessor: anomaly_index = current_index rows = dataframe[anomaly_index] - indexes = np.floor_divide(rows.index, self.frame_size) - # indexes = np.unique(rows.index) + indexes = np.unique(rows.index) return indexes def inverse_transform_anomalies(self, prediction): diff --git a/analytics/data_provider.py b/analytics/data_provider.py index 167aee3..bc47465 100644 --- a/analytics/data_provider.py +++ b/analytics/data_provider.py @@ -28,7 +28,7 @@ class DataProvider: if after_time is None or after_time <= last_chunk_time: chunk = self.__load_chunk(chunk_index) if after_time is not None: - chunk = chunk[chunk['timestamp'] > after_time] + chunk = chunk[chunk['timestamp'] >= after_time] result = pd.concat([result, chunk]) return result @@ -36,7 +36,7 @@ class DataProvider: for chunk_index, last_chunk_time in self.chunk_last_times.items(): if after_time < last_chunk_time: chunk = self.__load_chunk(chunk_index) - chunk = chunk[chunk['timestamp'] > after_time] + chunk = chunk[chunk['timestamp'] >= after_time] return chunk.index[0] return self.size()