MCPcopy
hub / github.com/hyperopt/hyperopt / test_run_basic_search

Function test_run_basic_search

hyperopt/tests/unit/test_atpe_basic.py:9–37  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7
8
9def test_run_basic_search():
10 def objective(args):
11 case, val = args
12 if case == "case 1":
13 return val
14 else:
15 return val ** 2
16
17 # define a search space
18 space = hp.choice(
19 "a",
20 [
21 ("case 1", 1 + hp.lognormal("c1", 0, 1)),
22 ("case 2", hp.uniform("c2", -10, 10)),
23 ],
24 )
25
26 # minimize the objective over the space
27 # NOTE: Max evals should be greater than 10, as the first 10 runs are only the initialization rounds
28 best = fmin(
29 objective,
30 space,
31 algo=atpe.suggest,
32 max_evals=20,
33 rstate=np.random.default_rng(1),
34 )
35
36 assert best["a"] == 1
37 assert space_eval(space, best)[0] == "case 2"

Callers

nothing calls this directly

Calls 2

fminFunction · 0.90
space_evalFunction · 0.90

Tested by

no test coverage detected