Skip to content

Commit 12512a3

Browse files
authored
[WIP] hyperopt (#177)
* hyperopt interface test * Create hyperopt.py module * moving hyperopt * basic hyperparameter class * Fix flake errors * Move hyperopt.py * rename * random engine, file interface working, no stats yet * random engine hooked up, experiment outputs a summary table and the submission with the best hypers * Tests, documentation, fixing the time in the score table, changing --n-iter meaning to count number of hyper combinations times cv folds * adding init to test dir * division by zero * file rename, cleanup * idmax
1 parent b94beb1 commit 12512a3

File tree

18 files changed

+1241
-17
lines changed

18 files changed

+1241
-17
lines changed

rampwf/hyperopt/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from .hyperopt import Hyperparameter, init_hyperopt, run_hyperopt
2+
3+
__all__ = [
4+
'Hyperparameter',
5+
'init_hyperopt',
6+
'run_hyperopt'
7+
]

rampwf/hyperopt/cli/__init__.py

Whitespace-only changes.

rampwf/hyperopt/cli/hyperopt.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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

Comments
 (0)