ML bug fix, @TODO: apply regression on folders and have report generated

master
Steve L. Nyemba 8 years ago
parent 99f43359ed
commit c298bde870

@ -26,6 +26,7 @@ class ICollector(Thread) :
self.lock = RLock()
self.factory = DataSourceFactory()
self.init()
self.name = 'data-collector@'+self.id
def init(self):
@ -78,12 +79,13 @@ class ICollector(Thread) :
label = thread.getName()
row = {}
if label == 'folders':
row[id] = data
row = [ dict({"id":self.id}, **_row) for _row in data]
else:
label = id
row = data
self.lock.acquire()
store = self.factory.instance(type=write_class,args=read_args)
store.write(label=label,row=row)
self.lock.release()
if 'MONITOR_CONFIG_PATH' in os.environ :

@ -41,6 +41,7 @@ class Anomalies(Thread) :
pass
def stop(self):
self.quit = True
def run(self):
DELAY = self.config['delay'] * 60
reader = self.factory.instance(type=self.rclass,args=self.rw_args)
@ -52,15 +53,16 @@ class Anomalies(Thread) :
while self.quit == False :
print ' *** ',self.name, ' ' , str(datetime.today())
for app in self.apps:
print '\t',str(datetime.today()),' ** ',app
print '\t',app,str(datetime.today()),' ** ',app
logs = ML.Filter('label',app,rdata)
if logs :
handler = AnomalyDetection()
value = handler.learn(logs,'label',app,features,yo)
print value
if value is not None:
value = dict(value,**{"features":features})
r[id][app] = value
value = dict({"id":self.id},**value)
#r[id][app] = value
self.lock.acquire()
writer = self.factory.instance(type=self.wclass,args=self.rw_args)
writer.write(label='learn',row=value)

@ -209,6 +209,7 @@ class AnomalyDetection:
sigma = info['parameters']['cov']
xu = info['parameters']['mean']
epsilon = info['performance']['epsilon']
return self.gPx(xu,sigma,xo,epsilon)
"""
This function computes performance metrics i.e precision, recall and f-score
@ -228,7 +229,8 @@ class AnomalyDetection:
tn += 1 if (test[i][1] == labels[i] and test[i][1] == 0) else 0
precision = tp / (tp + fp) if tp + fp > 0 else 1
recall = tp / (tp + fn) if tp + fp > 0 else 1
fscore = (2 * precision * recall)/ (precision + recall)
fscore = (2 * precision * recall)/ ((precision + recall) if (precision + recall) > 0 else 1)
return {"precision":precision,"recall":recall,"fscore":fscore}
"""

Loading…
Cancel
Save