From charlesreid1

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:

Resources

Scipy talk on Hyperopt: https://youtube.com/watch?v=Mp1xnPfE4PY

Github notebook on optimizing a Keras network with Hyperopt: https://github.com/Vooban/Hyperopt-Keras-CNN-CIFAR-100