X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=qp%2Fqptrain.py;fp=qp%2Fqptrain.py;h=2071ac35859e11b11be901b29e7c95d6ef1476fd;hb=48aa41171b8ca141df1f14341ea0ec2fde745af5;hp=68dcb35912ef4608d4d31da6c366cd5260988e20;hpb=0b9e340cd4f951d66e029c5f80af281cc2b732d4;p=ric-app%2Fqp.git 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):