-
Notifications
You must be signed in to change notification settings - Fork 75
/
main.py
48 lines (36 loc) · 1.29 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python
"a more polished example of using hyperband"
"includes displaying best results and saving to a file"
import sys
import cPickle as pickle
from pprint import pprint
from hyperband import Hyperband
#from defs.gb import get_params, try_params
#from defs.rf import get_params, try_params
#from defs.xt import get_params, try_params
#from defs.rf_xt import get_params, try_params
#from defs.sgd import get_params, try_params
#from defs.keras_mlp import get_params, try_params
#from defs.polylearn_fm import get_params, try_params
#from defs.polylearn_pn import get_params, try_params
#from defs.xgb import get_params, try_params
from defs.meta import get_params, try_params
try:
output_file = sys.argv[1]
if not output_file.endswith( '.pkl' ):
output_file += '.pkl'
except IndexError:
output_file = 'results.pkl'
print "Will save results to", output_file
#
hb = Hyperband( get_params, try_params )
results = hb.run( skip_last = 1 )
print "{} total, best:\n".format( len( results ))
for r in sorted( results, key = lambda x: x['loss'] )[:5]:
print "loss: {:.2%} | {} seconds | {:.1f} iterations | run {} ".format(
r['loss'], r['seconds'], r['iterations'], r['counter'] )
pprint( r['params'] )
print
print "saving..."
with open( output_file, 'wb' ) as f:
pickle.dump( results, f )