Exemplo n.º 1
0
def get_test_df(parameters={}):
    from kaggle.competitions import nflrush

    env = nflrush.make_env()

    test_df_list = []
    for (test_df, sample_prediction_df) in env.iter_test():
        test_df_list.append(test_df)
        env.predict(sample_prediction_df)

    test_df = pd.concat(test_df_list)

    return test_df
Exemplo n.º 2
0
def infer(model, base_probas=None, transformer=None, parameters={}):
    from kaggle.competitions import nflrush

    env = nflrush.make_env()
    for (test_df, sample_prediction_df) in env.iter_test():
        test_df = preprocess(test_df)
        if transformer is not None:
            test_df = transformer.transform(test_df)
        sample_prediction_df.iloc[0, :] = _predict_cdf(test_df, model, base_probas, parameters)
        env.predict(sample_prediction_df)

    env.write_submission_file()

    return sample_prediction_df
Exemplo n.º 3
0
def predict(x_te):
    model_num = len(models)
    for k, m in enumerate(models):
        if k == 0:
            y_pred = m.predict(x_te, batch_size=1024)
        else:
            y_pred += m.predict(x_te, batch_size=1024)

    y_pred = y_pred / model_num

    return y_pred


if TRAIN_OFFLINE == False:
    from kaggle.competitions import nflrush
    env = nflrush.make_env()
    iter_test = env.iter_test()

    for (test_df, sample_prediction_df) in tqdm(iter_test):
        basetable = create_features(test_df, deploy=True)
        basetable.drop(['GameId', 'PlayId'], axis=1, inplace=True)
        scaled_basetable = scaler.transform(basetable)

        y_pred = predict(scaled_basetable)
        y_pred = np.clip(np.cumsum(y_pred, axis=1), 0, 1).tolist()[0]

        preds_df = pd.DataFrame(data=[y_pred],
                                columns=sample_prediction_df.columns)
        env.predict(preds_df)

    env.write_submission_file()