Exemple #1
0
def run_custom_model():
    for year in ("2016", "2017"):
        cfg = Configuration(random_forest.Model(), load_climbset(year),
                            CategoricalPreprocessor())
        cfg.run()
        Configuration.report_headings()
        print(cfg.report())
Exemple #2
0
def search():
    parameter_args = ParameterSpace().product()
    hyper_parameter_combinations = [
        Parameters(*args) for args in parameter_args
    ]

    print(f"Generated {len(hyper_parameter_combinations)} sets of parameters")
    train_func = partial(train_model, climbset=load_climbset("2016"))
    results = list(map(train_func, hyper_parameter_combinations))
    pprint(results)
Exemple #3
0
def generate_all_valid_configurations():
    configs = []
    for year in ("2016", "2017"):
        # XGBoost
        configs.append(
            Configuration(xgboost_model.Model(), load_climbset(year),
                          FlandersPreprocessor()))
        # Random forest flanders proprocessor
        configs.append(
            Configuration(random_forest.Model(), load_climbset(year),
                          FlandersPreprocessor()))

        # Loop through categorical grade preprocessors
        for preprocessor in (
                CategoricalPreprocessor(),
                SplitPreprocessor(4),
                HalfGradePreprocessor(),
        ):
            # LSTM
            configs.append(
                Configuration(
                    keras_lstm_grade.Model(),
                    load_climbset(year),
                    preprocessor,
                    HoldListPreprocessor(),
                ))
            # MLP
            configs.append(
                Configuration(keras_mlp.Model(), load_climbset(year),
                              preprocessor))
            # Random forest
            configs.append(
                Configuration(random_forest.Model(), load_climbset(year),
                              preprocessor))

    print(f"Generated {len(configs)} configruations.")
    return configs
Exemple #4
0
def main(year):
    num_climbs = 500

    # Load climbset
    climbset = load_climbset(year)

    # Sample generators
    lstm = keras_lstm_gen.Model()
    sampling_parameters = params.Parameters()
    sample = lstm.sample(climbset, num_climbs, sampling_parameters)

    # Save to file
    file_data = {"original": climbset, "lstm": sample}

    print(f"Saving {len(file_data)} climbsets")
    pickle.dump(file_data,
                open(local_file_path(__file__, f"{year}.pickle"), "wb"))
def prep_no_grade():
    output_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                               "input.txt")
    with open(output_path, "w") as handle:
        handle.write(load_climbset().no_grade_string())
    return output_path