def predict_score(sub, model): save_price_path = '../data/tags_' + sub + '_results' data, target = TrainData.load_model(save_price_path + '_tag', '../model/' + sub + '_train_data.pkl') train_data = data[:-1] predict_data = data[-1] if model == 'KNN': model = knn_classifier(train_data, target) elif model == 'LR': model = logistic_regression_classifier(train_data, target) elif model == 'RF': model = random_forest_classifier(train_data, target) elif model == 'DT': model = decision_tree_classifier(train_data, target) else: model = gradient_boosting_classifier(train_data, target) predicted = model.predict(predict_data) return predicted[0] + 1
def predict_score(sub, m): save_price_path = last_path + '/data/tags_' + sub + '_results' data, target = TrainData.load_model( save_price_path + '_tag', last_path + '/model/' + sub + '_train_data.pkl') train_data = data[:-1] predict_data = data[-1] try: model = joblib.load(last_path + "/model_classifiers/model" + sub + "_LR.pkl") predicted = model.predict(predict_data) except: if m == 'KNN': model = knn_classifier(train_data, target) elif m == 'LR': model = logistic_regression_classifier(train_data, target) elif m == 'RF': model = random_forest_classifier(train_data, target) elif m == 'DT': model = decision_tree_classifier(train_data, target) else: model = gradient_boosting_classifier(train_data, target) predicted = model.predict(predict_data) return predicted[0] + 1