def F_model(self, row, data, dummy_dict, Var, category_key): df = data.iloc[row] C_var = [9, 10, 11, 12] C_tar = Var[5] df = df[[Var[i] for i in C_var]] test = [] for k in C_var: test.extend(test_dummy(df[Var[k]], dummy_dict[Var[k]])) test = np.array(test).reshape(1, -1) model = pickle.load(open("./Model/F_model.pickle", "rb")) return model.predict(test)[0]
def G_model(self, row, data, dummy_dict, Var, category_key): ex = data.iloc[row] var = [0, 1, 2, 5, 7, 9, 10, 11, 13, 14, 15] tar = Var[6] test = list(ex[[Var[i] for i in [2, 5]]].values) key = [i for i in var if i in category_key] for k in key: test.extend(test_dummy(ex[Var[k]], dummy_dict[Var[k]])) test = np.array(test).reshape(1, -1) model = pickle.load(open("./Model/G_model.pickle", "rb")) return model.predict(test)[0]
def K_model(self, row, data, dummy_dict, Var, category_key): ex = data.iloc[row] var = [0, 2, 3, 4, 5, 6, 7, 8, 13, 14, 15] tar = Var[10] test = list(ex[Var[2:7]].values) key = [i for i in var if i in category_key] for k in key: test.extend(test_dummy(ex[Var[k]], dummy_dict[Var[k]])) test = np.array(test).reshape(1, -1) model = pickle.load(open("./Model/K_model.pickle", "rb")) pred = model.predict(test) return dummy_dict[tar][pred][0]
def E_model(self, row, data, dummy_dict, Var, category_key): ex = data.iloc[row] var = [1, 7, 9, 10, 11, 12, 14, 15] tar = Var[4] test = list(ex[Var[2:4] + Var[5:7]].values) key = [i for i in var if i in category_key] for k in key: test.extend(test_dummy(ex[Var[k]], dummy_dict[Var[k]])) test = np.array(test).reshape(1, -1) model = pickle.load(open("./Model/E_model.pickle", "rb")) pred = model.predict(data=test) return pred[0]
def P_model(self, row, data, dummy_dict, Var, category_key): ex = data.iloc[row] var = [1, 4, 5, 6, 7, 8, 9, 10, 11] tar = Var[15] test = list(ex[Var[4:7]].values) key = [i for i in var if i in category_key] for k in key: test.extend(test_dummy(ex[Var[k]], dummy_dict[Var[k]])) test = np.array(test).reshape(1, -1) model = pickle.load(open("./Model/P_model.pickle", "rb")) pred = np.argmax(model.predict(X=test), 1) return dummy_dict[tar][pred][0]