X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Fad_model.py;h=4bac6e0156221d37e9fd69c3b2ad33742738ad05;hb=refs%2Fchanges%2F55%2F11455%2F2;hp=6e14fa57085204c51919f84e4936d423c91ce8f6;hpb=5da0637daa11fc09c2980efad7f116ef2a537be8;p=ric-app%2Fad.git diff --git a/src/ad_model.py b/src/ad_model.py index 6e14fa5..4bac6e0 100644 --- a/src/ad_model.py +++ b/src/ad_model.py @@ -91,7 +91,7 @@ class CAUSE(object): def __init__(self): self.normal = None - def cause(self, df, db): + def cause(self, df, db, threshold): """ Filter normal data for a particular ue-id to compare with a given sample Compare with normal data to find and return degradaton type """ @@ -99,11 +99,11 @@ class CAUSE(object): sample.index = range(len(sample)) for i in range(len(sample)): if sample.iloc[i]['Anomaly'] == 1: - query = """select * from "{}" where {} = \'{}\' and timenow()-20s""".format(db.meas, db.ue, sample.iloc[i][db.ue]) + query = """select * from {} where "{}" = \'{}\' and timenow()-20s""".format(db.meas, db.ue, sample.iloc[i][db.ue]) normal = db.query(query) if normal: normal = normal[db.meas][[db.thpt, db.rsrp, db.rsrq]] - deg = self.find(sample.loc[i, :], normal.max(), db) + deg = self.find(sample.loc[i, :], normal.max(), db, threshold) if deg: sample.loc[i, 'Degradation'] = deg if 'Throughput' in deg and ('RSRP' in deg or 'RSRQ' in deg): @@ -112,10 +112,10 @@ class CAUSE(object): sample.loc[i, 'Anomaly'] = 0 return sample[['Anomaly', 'Degradation']].values.tolist() - def find(self, row, l, db): + def find(self, row, l, db, threshold): """ store if a particular parameter is below threshold and return """ deg = [] - if row[db.thpt] < l[db.thpt]*0.5: + if row[db.thpt] < l[db.thpt]*(100 - threshold)*0.01: deg.append('Throughput') if row[db.rsrp] < l[db.rsrp]-15: deg.append('RSRP')