- Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathduplicate_point.py
20 lines (16 loc) · 952 Bytes
/
duplicate_point.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
importnumpyasnp
frombayes_optimportBayesianOptimization
frombayes_optimportacquisition
deff(x):
returnnp.exp(-(x-2) **2) +np.exp(-(x-6) **2/10) +1/ (x**2+1)
if__name__=='__main__':
acq=acquisition.UpperConfidenceBound(kappa=5) # kappa determines explore/Exploitation ratio
optimizer=BayesianOptimization(f=None, pbounds={'x': (-2, 2)}, verbose=2, random_state=1,
allow_duplicate_points=True)
optimizer.set_gp_params(normalize_y=True, alpha=2.5e-3, n_restarts_optimizer=20) # tuning of the gaussian parameters...
forpointinrange(20):
next_point_to_probe=optimizer.suggest()
NextPointValues=np.array(list(next_point_to_probe.values()))
mean,std=optimizer._gp.predict(NextPointValues.reshape(1, -1),return_std=True)
target=f(**next_point_to_probe)
optimizer.register(params=next_point_to_probe, target=target)