- If the category of UEID is present in the segment file, it is considered as normal(0)
- otherwise, the sample is considered as anomaly.
- """
- with open("/tmp/ad/ue_seg.json", "r") as json_data:
- segment = json.loads(json_data.read())
- anomaly = []
- for i in df.index:
- if df.loc[i, 'Category'] in segment[str(df.loc[i,'UEID'])]:
- anomaly.append(0)
+
+ def __init__(self, db):
+ db.read_data('train')
+ self.normal = db.data[['rsrp', 'rsrq', 'rssinr', 'throughput', 'prb_usage', 'ue-id']]
+
+ def cause(self, sample):
+ """ Filter normal data for a particular ue-id to compare with a given sample
+ Compare with normal data to find and return degradaton type
+ """
+ normal = self.normal[self.normal['ue-id'] == sample.iloc[0]['ue-id']].drop('ue-id', axis=1)
+ param = self.find(sample, normal.max())
+ return param
+
+ def find(self, sample, Range):
+ """ store if a particular parameter is below threshold and return """
+
+ deg = []
+ if sample.iloc[0]['throughput'] < Range['throughput']*0.5:
+ deg.append('Throughput')
+ if sample.iloc[0]['rsrp'] <= Range['rsrp']-20:
+ deg.append('RSRP')
+ if sample.iloc[0]['rsrq'] <= Range['rsrq']-20:
+ deg.append('RSRQ')
+ if sample.iloc[0]['rssinr'] <= Range['rssinr']-25:
+ deg.append('RSSINR')
+ if sample.iloc[0]['prb_usage'] <= Range['prb_usage']*0.5:
+ deg.append('prb_usage')
+ if len(deg) == 0:
+ deg = False