From 48aa41171b8ca141df1f14341ea0ec2fde745af5 Mon Sep 17 00:00:00 2001 From: Deepanshu Karnwal Date: Wed, 8 Dec 2021 15:56:33 +0530 Subject: [PATCH] [RICAPP-181] Update Prediction message (from QP to TS) with serving cell prediciton Signed-off-by: Deepanshu Karnwal Change-Id: Ia14efb7da90a781733b0eab8098ca7e4fc496f08 --- qp/main.py | 11 ++++++----- qp/qptrain.py | 23 ++++++++++++++++------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/qp/main.py b/qp/main.py index 002b063..1c88a48 100644 --- a/qp/main.py +++ b/qp/main.py @@ -74,15 +74,16 @@ def qp_predict_handler(self, summary, sbuf): logger.warning("predict handler: failed to send message") -def nbcells(ue): +def cells(ue): """ Extract neighbor cell id for a given UE """ db.read_data(meas='liveUE', limit=1, ueid=ue) df = db.data - nbc = df.filter(regex='nbCell').values[0] - return nbc + nbc = df.filter(regex='nbCell').values[0].tolist() + srvc = df.filter(regex='nrCell').values[0].tolist() + return srvc+nbc def predict(payload): @@ -93,8 +94,8 @@ def predict(payload): payload = json.loads(payload) ueid = payload['UEPredictionSet'][0] - nbc = nbcells(ueid) - for cid in nbc: + cell_list = cells(ueid) + for cid in cell_list: mcid = cid.replace('/', '') db.read_data(meas='liveCell', cellid=cid, limit=11) if len(db.data) != 0: diff --git a/qp/qptrain.py b/qp/qptrain.py index 68dcb35..2071ac3 100644 --- a/qp/qptrain.py +++ b/qp/qptrain.py @@ -19,6 +19,10 @@ from statsmodels.tsa.stattools import adfuller import joblib +class DataNotMatchError(Exception): + pass + + class PROCESS(object): def __init__(self, data): @@ -61,17 +65,22 @@ class PROCESS(object): """ Filter throughput parameters, call make_stationary() to check for Stationarity time series """ df = self.data.copy() - df = df[['pdcpBytesDl', 'pdcpBytesUl']] + try: + df = df[['pdcpBytesDl', 'pdcpBytesUl']] + except DataNotMatchError: + print('Parameters pdcpBytesDl, pdcpBytesUl does not exist in provided data') + self.data = None self.data = df.loc[:, (df != 0).any(axis=0)] self.make_stationary() # check for Stationarity and make the Time Series Stationary def valid(self): - df = self.data.copy() - df = df.loc[:, (df != 0).any(axis=0)] - if len(df) != 0 and df.shape[1] == 2: - return True - else: - return False + val = False + if self.data is not None: + df = self.data.copy() + df = df.loc[:, (df != 0).any(axis=0)] + if len(df) != 0 and df.shape[1] == 2: + val = True + return val def train(db, cid): -- 2.16.6