Hyperopt: Difference between revisions
From charlesreid1
(→Usage) |
(→Usage) |
||
| Line 33: | Line 33: | ||
Random search over a space | Random search over a space | ||
Start by defining a distribution space | |||
Create a score over the space - you need some way to score the results (your function of interest) | |||
Then, call fmin to minimize the function over your distribution space | |||
Specify max_evals to tell it how many random points to try | |||
===Example=== | ===Example=== | ||
Revision as of 21:17, 17 October 2017
Hyperopt is a hyperparameter optimization library.
Origin of the work was in searching through parameter spaces/sampling probability distributions of parameters.
Installing
Hyperopt relies on an older version of the networkx library. If you see this:
$ python myhyper.py
Traceback (most recent call last):
File "myhyper.py", line 14, in <module>
bestr = fmin(f, space, algo=rand.suggest, max_evals=100)
File "/usr/local/lib/python3.6/site-packages/hyperopt/fmin.py", line 314, in fmin
pass_expr_memo_ctrl=pass_expr_memo_ctrl)
File "/usr/local/lib/python3.6/site-packages/hyperopt/base.py", line 786, in __init__
pyll.toposort(self.expr)
File "/usr/local/lib/python3.6/site-packages/hyperopt/pyll/base.py", line 715, in toposort
assert order[-1] == expr
TypeError: 'generator' object is not subscriptable
Do this:
$ pip install networkx==1.11
Also see this Github issue: https://github.com/hyperopt/hyperopt/issues/325
Usage
Random search over a space
Start by defining a distribution space
Create a score over the space - you need some way to score the results (your function of interest)
Then, call fmin to minimize the function over your distribution space
Specify max_evals to tell it how many random points to try
Example
Simple example to optimize a 2D quadratic function: $ x^2 + y^2 $