|
|
@ -3,6 +3,7 @@
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
from __future__ import division
|
|
|
|
from __future__ import division
|
|
|
|
import numpy as np
|
|
|
|
import numpy as np
|
|
|
|
|
|
|
|
from sklearn import linear_model
|
|
|
|
from threading import Thread,RLock
|
|
|
|
from threading import Thread,RLock
|
|
|
|
from utils.transport import *
|
|
|
|
from utils.transport import *
|
|
|
|
from utils.ml import AnomalyDetection,ML
|
|
|
|
from utils.ml import AnomalyDetection,ML
|
|
|
@ -13,10 +14,17 @@ class BaseLearner(Thread):
|
|
|
|
Thread.__init__(self)
|
|
|
|
Thread.__init__(self)
|
|
|
|
path = PARAMS['path']
|
|
|
|
path = PARAMS['path']
|
|
|
|
self.name = self.__class__.__name__.lower()
|
|
|
|
self.name = self.__class__.__name__.lower()
|
|
|
|
|
|
|
|
self.rclass= None
|
|
|
|
|
|
|
|
self.wclass= None
|
|
|
|
|
|
|
|
self.rw_args=None
|
|
|
|
if os.path.exists(path) :
|
|
|
|
if os.path.exists(path) :
|
|
|
|
f = open(path)
|
|
|
|
f = open(path)
|
|
|
|
self.config = json.loads(f.read())
|
|
|
|
self.config = json.loads(f.read())
|
|
|
|
f.close()
|
|
|
|
f.close()
|
|
|
|
|
|
|
|
self.rclass = self.config['store']['class']['read']
|
|
|
|
|
|
|
|
self.wclass = self.config['store']['class']['write']
|
|
|
|
|
|
|
|
self.rw_args = self.config['store']['args']
|
|
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self.config = None
|
|
|
|
self.config = None
|
|
|
|
self.lock = lock
|
|
|
|
self.lock = lock
|
|
|
@ -98,7 +106,7 @@ class Anomalies(BaseLearner) :
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
class Regression(BaseLearner):
|
|
|
|
class Regression(BaseLearner):
|
|
|
|
def __init__(self,lock):
|
|
|
|
def __init__(self,lock):
|
|
|
|
BaseLearner.__init__(self)
|
|
|
|
BaseLearner.__init__(self,lock)
|
|
|
|
self.folders = self.config['folders']
|
|
|
|
self.folders = self.config['folders']
|
|
|
|
self.id = self.config['id']
|
|
|
|
self.id = self.config['id']
|
|
|
|
def run(self):
|
|
|
|
def run(self):
|
|
|
@ -109,7 +117,12 @@ class Regression(BaseLearner):
|
|
|
|
data = ML.Filter('id',self.id,data['folders'])
|
|
|
|
data = ML.Filter('id',self.id,data['folders'])
|
|
|
|
xo = ML.Extract(['date'],data)
|
|
|
|
xo = ML.Extract(['date'],data)
|
|
|
|
yo = ML.Extract(['count'],data)
|
|
|
|
yo = ML.Extract(['count'],data)
|
|
|
|
numpy.linalg.lstsq(xo, yo, rcond=-1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
# print np.var(xo,yo)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|