Exemplo n.º 1
0
def train_svm_model(feature_frame_train, target_col_name, train_data, y_train,
                    plots_path, models_path):
    train_data_copy = train_data.copy()
    model_file_path = str(models_path + 'model_svm.sav')
    build_svm_model(train_data_copy, target_col_name, model_file_path)
    # Make predictions on the train data and check the model metrics
    y_pred_train, y_pred_prob_train = predict(model_file_path,
                                              feature_frame_train)
    # Compute confusion matrix on train data
    calc_perf_metrics_for_model('svm', y_train, y_pred_train, target_col_name,
                                plots_path, 'train')
    do_roc_analysis(y_train, y_pred_prob_train, 'svm', plots_path, 'train')
Exemplo n.º 2
0
def train_gbm_model(feature_frame_train, target_col_name, train_data, y_train,
                    plots_path, models_path):
    train_data_copy = train_data.copy()
    model_file_path = str(models_path + 'model_gbm.sav')
    build_gbm_model(train_data_copy, target_col_name, model_file_path)
    # Make predictions on the train data and check the model metrics
    y_pred_train, y_pred_prob_train = predict(model_file_path,
                                              feature_frame_train)
    logging.info("describe y_pred_train :: " + str(unique(y_pred_train)))
    # Compute confusion matrix on train data
    calc_perf_metrics_for_model('gbm', y_train, y_pred_train, target_col_name,
                                plots_path, 'train')
    do_roc_analysis(y_train, y_pred_prob_train, 'gbm', plots_path, 'train')