Browse Source

good analytics type names

pull/1/head
Alexey Velikiy 6 years ago
parent
commit
862e1edb7c
  1. 4
      analytics/detectors/pattern_detection_model.py
  2. 1
      analytics/detectors/peaks_detector.py
  3. 7
      analytics/detectors/step_detector.py
  4. 8
      analytics/worker.py

4
analytics/detectors/pattern_detection_model.py

@ -97,9 +97,9 @@ class PatternDetectionModel:
self.data_prov.synchronize() self.data_prov.synchronize()
def __create_model(self, pattern): def __create_model(self, pattern):
if pattern == "peaks": if pattern == "peak":
return PeaksDetector() return PeaksDetector()
if pattern == "jumps" or pattern == "drops": if pattern == "jump" or pattern == "drop":
return StepDetector(pattern) return StepDetector(pattern)
raise ValueError('Unknown pattern "%s"' % pattern) raise ValueError('Unknown pattern "%s"' % pattern)

1
analytics/detectors/peaks_detector.py

@ -4,7 +4,6 @@ from scipy import signal
import numpy as np import numpy as np
class PeaksDetector: class PeaksDetector:
def __init__(self): def __init__(self):
pass pass

7
analytics/detectors/step_detector.py

@ -1,9 +1,12 @@
import numpy as np
import pickle
import scipy.signal import scipy.signal
from scipy.fftpack import fft from scipy.fftpack import fft
from scipy.signal import argrelextrema from scipy.signal import argrelextrema
import numpy as np
import pickle
def is_intersect(target_segment, segments): def is_intersect(target_segment, segments):
for segment in segments: for segment in segments:
start = max(segment['start'], target_segment[0]) start = max(segment['start'], target_segment[0])

8
analytics/worker.py

@ -75,7 +75,7 @@ class Worker(object):
last_prediction_time = model.learn(segments) last_prediction_time = model.learn(segments)
# TODO: we should not do predict before labeling in all models, not just in drops # TODO: we should not do predict before labeling in all models, not just in drops
if pattern == 'drops' and len(segments) == 0: if pattern == 'drop' and len(segments) == 0:
# TODO: move result to a class which renders to json for messaging to analytics # TODO: move result to a class which renders to json for messaging to analytics
result = { result = {
'status': 'success', 'status': 'success',
@ -101,12 +101,12 @@ class Worker(object):
'lastPredictionTime': last_prediction_time 'lastPredictionTime': last_prediction_time
} }
def get_model(self, analytic_unit_id, pattern): def get_model(self, analytic_unit_id, pattern_type):
if analytic_unit_id not in self.models_cache: if analytic_unit_id not in self.models_cache:
if pattern.find('general') != -1: if pattern_type == 'general':
model = GeneralDetector(analytic_unit_id) model = GeneralDetector(analytic_unit_id)
else: else:
model = PatternDetectionModel(analytic_unit_id, pattern) model = PatternDetectionModel(analytic_unit_id, pattern_type)
self.models_cache[analytic_unit_id] = model self.models_cache[analytic_unit_id] = model
return self.models_cache[analytic_unit_id] return self.models_cache[analytic_unit_id]

Loading…
Cancel
Save