from hyperopt import hp, fmin, rand space = hp.choice('a', [-1, hp.uniform('b', 0, 1)]) best = fmin(fn=lambda x: x, space=space, algo=rand.suggest, max_evals=100) print best # put the configuration space in a local var # so that we can work on it. print space from hyperopt import pyll # The "navigation" approach to finding an internal # search space node: randint_node_nav = space.pos_args[0].pos_args[1] print "by navigation:" print randint_node_nav # The "search" approach to finding an internal # search space node: randint_nodes = [node for node in pyll.dfs(space) if node.name == 'randint'] randint_node_srch, = randint_nodes print "by search:" print randint_node_srch assert randint_node_nav == randint_node_srch space_with_fixed_a = pyll.clone(space, memo={randint_node_nav: pyll.as_apply(1)}) print space_with_fixed_a best = fmin(fn=lambda x: x, space=space_with_fixed_a, algo=rand.suggest, max_evals=100) print best from hyperopt import tpe best = fmin(fn=lambda x: x, space=space_with_fixed_a, algo=tpe.suggest, max_evals=100) print best space_with_no_a = pyll.clone(space, memo={space.pos_args[0]: pyll.as_apply(1)}) best = fmin(fn=lambda x: x, space=space_with_no_a, algo=tpe.suggest, max_evals=100) print best