|
| 1 | +import click |
| 2 | + |
| 3 | +from ..hyperopt import run_hyperopt |
| 4 | + |
| 5 | +CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help']) |
| 6 | + |
| 7 | + |
| 8 | +@click.command(context_settings=CONTEXT_SETTINGS) |
| 9 | +@click.option('--submission', default='starting_kit', show_default=True, |
| 10 | + help='The kit to hyperopt. It should be located in the ' |
| 11 | + '"submissions" folder of the starting kit.') |
| 12 | +@click.option('--ramp-kit-dir', default='.', show_default=True, |
| 13 | + help='Root directory of the ramp-kit to hyperopt.') |
| 14 | +@click.option('--ramp-data-dir', default='.', show_default=True, |
| 15 | + help='Directory containing the data. This directory should ' |
| 16 | + 'contain a "data" folder.') |
| 17 | +@click.option('--ramp-submission-dir', default='submissions', |
| 18 | + show_default=True, |
| 19 | + help='Directory where the submissions are stored. It is the ' |
| 20 | + 'directory (typically called "submissions" in the ramp-kit) ' |
| 21 | + 'that contains the individual submission subdirectories.') |
| 22 | +@click.option('--engine', default='random', show_default=True, |
| 23 | + help='The name of the hyperopt engine, e.g., "random".') |
| 24 | +@click.option('--n-iter', default=10, show_default=True, |
| 25 | + help='The number of hyperopt iterations, inputted to the ' |
| 26 | + 'engine. The granularity is per cv fold, so if you want to ' |
| 27 | + 'fully test 7 hyperparameter combinations for example with the ' |
| 28 | + 'random engine and you have 8 CV folds, you should enter ' |
| 29 | + '--n-iter 56') |
| 30 | +@click.option('--save-best', is_flag=True, default=True, |
| 31 | + show_default=True, |
| 32 | + help='Specify this flag to create a <submission>_hyperopt ' |
| 33 | + 'in hte "submissions" dir with the best submission.') |
| 34 | +def main(submission, ramp_kit_dir, ramp_data_dir, ramp_submission_dir, |
| 35 | + engine, n_iter, save_best): |
| 36 | + """Hyperopt a submission.""" |
| 37 | + run_hyperopt( |
| 38 | + ramp_kit_dir=ramp_kit_dir, ramp_data_dir=ramp_data_dir, |
| 39 | + ramp_submission_dir=ramp_submission_dir, submission=submission, |
| 40 | + engine_name=engine, n_iter=n_iter, save_best=save_best) |
| 41 | + |
| 42 | + |
| 43 | +def start(): |
| 44 | + main() |
| 45 | + |
| 46 | + |
| 47 | +if __name__ == '__main__': |
| 48 | + start() |
0 commit comments