Operationalizing the learner

master
Steve L. Nyemba 8 years ago
parent cbef913877
commit d6e1b27b9d

@ -139,29 +139,35 @@ def learn():
gReader = factory.instance(type=class_read,args=p) gReader = factory.instance(type=class_read,args=p)
d = gReader.read() d = gReader.read()
if 'learn' in d : if 'learn' in d :
logs = d['learn'] info = d['learn']
del d['learn'] del d['learn']
else : else :
logs = [] info = []
r = [] r = []
if 'id' in request.args: if 'id' in request.args:
id = request.args['id'] id = request.args['id']
d = d[id] d = d[id]
print CONFIG['monitor']['processes']['config'][id] apps = CONFIG['monitor']['processes']['config'][id]
print (apps) #print (apps)
params = {}
for item in info:
id = item['label']
params[id] = item
#apps = list(set(ML.Extract(['label'],d))) #apps = list(set(ML.Extract(['label'],d)))
p = AnomalyDetection() p = AnomalyDetection()
#for row in d : for name in apps :
#xo = ML.Filter('label',app,d) xo = ML.Filter('label',name,d)
_info = params[name]
#info = ML.Filter('label',app,logs) #info = ML.Filter('label',app,logs)
#value = p.predict(xo,info) value = p.predict(xo,_info)
print [row[1] for row in value]
break
#print app,value #print app,value
#if value is not None: #if value is not None:
# r.append(value) # r.append(value)
print r print r
return json.dumps("[]") return json.dumps([])

@ -116,14 +116,16 @@ class AnomalyDetection:
@param info stored information about this @param info stored information about this
""" """
def predict(self,xo,info): def predict(self,xo,info):
xo = ML.Filter(info['extract'],xo)
xo = ML.Extract(info['features'],xo)
if not xo : if not xo :
return None return None
sigma = info['parameters']['cov'] sigma = info['parameters']['cov']
xu = info['parameters']['mean'] xu = info['parameters']['mean']
epsilon = info['performance']['epsilon'] epsilon = info['performance']['epsilon']
return self.getPx(xu,sigma,xo,epsilon) return self.gPx(xu,sigma,xo,epsilon)
""" """
This function computes performance metrics i.e precision, recall and f-score This function computes performance metrics i.e precision, recall and f-score
for details visit https://en.wikipedia.org/wiki/Precision_and_recall for details visit https://en.wikipedia.org/wiki/Precision_and_recall

@ -174,6 +174,7 @@ class ThreadManager:
for id in ThreadManager.Pool : for id in ThreadManager.Pool :
thread = ThreadManager.Pool[id] thread = ThreadManager.Pool[id]
r[id] = thread.isAlive() r[id] = thread.isAlive()
@ -190,4 +191,4 @@ class Factory :
return {"class":ref,"config":config['monitor'][id]["config"]} return {"class":ref,"config":config['monitor'][id]["config"]}
else: else:
return None return None

Loading…
Cancel
Save