-
Notifications
You must be signed in to change notification settings - Fork 8
/
bask.coco
37 lines (28 loc) · 955 Bytes
/
bask.coco
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
"""
The bayes-skopt backend. Does black-box optimization with the bask fork of scikit-optimize.
"""
from bask import Optimizer
from bbopt.backends.skopt import (
SkoptBackend,
create_dimensions,
guess_n_initial_points,
)
# Backend:
class BaskBackend(SkoptBackend):
"""The bask backend uses bayes-skopt for black box optimization."""
backend_name = "bayes-skopt"
@override
def setup_backend(self, params, n_initial_points=None, **options):
"""Special method to initialize the backend from params."""
self.params = params
if n_initial_points is None:
n_initial_points = guess_n_initial_points(params)
self.optimizer = Optimizer(
create_dimensions(params),
n_initial_points=n_initial_points,
**options,
)
# Registered names:
BaskBackend.register()
BaskBackend.register_alias("bask")
BaskBackend.register_alg("bask_gaussian_process")