MCPcopy
hub / github.com/hyperopt/hyperopt / space_eval

Function space_eval

hyperopt/fmin.py:601–619  ·  view source on GitHub ↗

Compute a point in a search space from a hyperparameter assignment. Parameters: ----------- space - a pyll graph involving hp nodes (see `pyll_utils`). hp_assignment - a dictionary mapping hp node labels to values.

(space, hp_assignment)

Source from the content-addressed store, hash-verified

599
600
601def space_eval(space, hp_assignment):
602 """Compute a point in a search space from a hyperparameter assignment.
603
604 Parameters:
605 -----------
606 space - a pyll graph involving hp nodes (see `pyll_utils`).
607
608 hp_assignment - a dictionary mapping hp node labels to values.
609 """
610 space = pyll.as_apply(space)
611 nodes = pyll.toposort(space)
612 memo = {}
613 for node in nodes:
614 if node.name == "hyperopt_param":
615 label = node.arg["label"].eval()
616 if label in hp_assignment:
617 memo[node] = hp_assignment[label]
618 rval = pyll.rec_eval(space, memo=memo)
619 return rval
620
621
622# -- flake8 doesn't like blank last line

Callers 3

test_space_evalFunction · 0.90
test_run_basic_searchFunction · 0.90
fminFunction · 0.85

Calls 1

evalMethod · 0.45

Tested by 2

test_space_evalFunction · 0.72
test_run_basic_searchFunction · 0.72