diff --git a/analytics/detectors/general_detector/__init__.py b/analytics/detectors/general_detector/__init__.py new file mode 100644 index 0000000..f5dd540 --- /dev/null +++ b/analytics/detectors/general_detector/__init__.py @@ -0,0 +1 @@ +from detectors.general_detector.general_detector import GeneralDetector \ No newline at end of file diff --git a/analytics/detectors/general_detector.py b/analytics/detectors/general_detector/general_detector.py similarity index 97% rename from analytics/detectors/general_detector.py rename to analytics/detectors/general_detector/general_detector.py index 2307ab6..bb29d6d 100644 --- a/analytics/detectors/general_detector.py +++ b/analytics/detectors/general_detector/general_detector.py @@ -1,3 +1,4 @@ +from detectors.general_detector.supervised_algorithm import SupervisedAlgorithm import utils from grafana_data_provider import GrafanaDataProvider from data_preprocessor import data_preprocessor @@ -9,6 +10,7 @@ import os.path import json + NANOSECONDS_IN_MS = 1000000 logger = logging.getLogger('analytic_toolset') @@ -120,8 +122,7 @@ class GeneralDetector: return json.load(file) def create_algorithm(self): - from supervised_algorithm import supervised_algorithm - return supervised_algorithm() + return SupervisedAlgorithm() def __save_model(self): logger.info("Save model '%s'" % self.anomaly_name) diff --git a/analytics/supervised_algorithm.py b/analytics/detectors/general_detector/supervised_algorithm.py similarity index 97% rename from analytics/supervised_algorithm.py rename to analytics/detectors/general_detector/supervised_algorithm.py index 8217b80..1d64ca0 100644 --- a/analytics/supervised_algorithm.py +++ b/analytics/detectors/general_detector/supervised_algorithm.py @@ -4,10 +4,8 @@ from sklearn.preprocessing import MinMaxScaler from sklearn.ensemble import IsolationForest import pandas as pd -from sklearn import svm - -class supervised_algorithm(object): +class SupervisedAlgorithm(object): frame_size = 16 good_features = [ #"value__agg_linear_trend__f_agg_\"max\"__chunk_len_5__attr_\"intercept\"",