コード例 #1
0
def save_output(regs, X_df):
    revenue_preds = []
    for reg, models in regs:
        X_w_pred_df = append_pred(models, X_df.copy())
        revenue_pred = reg.predict(X_w_pred_df)
        revenue_preds.append(revenue_pred)
    revenue_pred = np.sum(revenue_preds, axis=0) / len(revenue_preds)

    pred_df = X_df.copy()
    pred_df["pred_revenue"] = revenue_pred
    predict_df = data.to_label(pred_df)
    fill_label(predict_df, "data/test_nolabel.csv")
    print("*Saved prediction Ouput")
コード例 #2
0
    eval_reg.fit(X_train, y_train)

    print("-" * 10, "regression report", "-" * 10)
    report = regression_report(y_test, eval_reg.predict(X_test),
                               X_test.shape[1])
    print(report)

    print("-" * 10, "evaluation of label", "-" * 10)
    label_df = data.get_true_label(
        columns=["adr", "revenue", "is_canceled", "label"])
    pred_label_df = data.predict_label(eval_reg, X_test_df)

    print("[ label evaluation ]")
    report_label = evaluate_by_label(pred_label_df, label_df, target="label")
    print(report_label)
    print("[ revenue_per_day evaluation ]")
    report_revenue = evaluate_by_label(pred_label_df,
                                       label_df,
                                       target="revenue")
    print(report_revenue)

    #%% training with all data
    X_df, y_df = data.processing(["revenue"])
    reg = HistGradientBoostingRegressor(random_state=1129)
    reg.fit(X_df.to_numpy(), y_df["revenue"].to_numpy())

    #%% fill predict label to csv
    test_X_df = data.processing_test_data("data/test.csv")
    predict_df = data.predict_label(reg, test_X_df)
    fill_label(predict_df, "data/test_nolabel.csv")