-
Notifications
You must be signed in to change notification settings - Fork 0
/
minimal_example.py
60 lines (51 loc) · 1.85 KB
/
minimal_example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from pbmohpo.benchmark import Benchmark
from pbmohpo.decision_makers.decision_maker import DecisionMaker
from pbmohpo.optimizers.eubo import EUBO, qEUBO
from pbmohpo.optimizers.random_search import RandomSearch
from pbmohpo.optimizers.utility_bayesian_optimization import UtilityBayesianOptimization
from pbmohpo.problems.yahpo import YAHPO
from pbmohpo.utils import visualize_archives
prob = YAHPO(
"iaml_rpart",
instance="1067",
objective_names=["auc", "nf"],
fix_hps={"trainsize": 1},
objective_scaling_factors={"auc": 1, "nf": 21},
seed=0,
)
dm = DecisionMaker(objective_names=prob.get_objective_names(), seed=0)
print("Decision Maker Preference Scores:")
print(dm.preferences)
opt = UtilityBayesianOptimization(prob.get_config_space())
bench = Benchmark(
prob, opt, dm, eval_budget=100, dm_budget=100, eval_batch_size=2, dm_batch_size=1
)
print("Running Utility BO")
bench.run()
opt2 = RandomSearch(prob.get_config_space())
bench2 = Benchmark(
prob, opt2, dm, eval_budget=100, dm_budget=100, eval_batch_size=2, dm_batch_size=1
)
print("Running RS")
bench2.run()
opt3 = EUBO(prob.get_config_space())
bench3 = Benchmark(
prob, opt3, dm, eval_budget=100, dm_budget=100, eval_batch_size=2, dm_batch_size=1
)
print("Running EUBO")
bench3.run()
opt4 = qEUBO(prob.get_config_space())
bench4 = Benchmark(
prob, opt4, dm, eval_budget=100, dm_budget=100, eval_batch_size=2, dm_batch_size=1
)
print("Running qEUBO")
bench4.run()
print("Best Configuration:")
print(bench.archive.evaluations[bench.archive.incumbents[0]])
print(bench2.archive.evaluations[bench2.archive.incumbents[0]])
print(bench3.archive.evaluations[bench3.archive.incumbents[0]])
print(bench4.archive.evaluations[bench4.archive.incumbents[0]])
visualize_archives(
[bench.archive, bench2.archive, bench3.archive, bench4.archive],
legend_elements=["BO", "RS", "EUBO", "qEUBO"],
)