In [ ]:
%load_ext autoreload
%autoreload 2
%matplotlib inline

In [ ]:
import matplotlib.pyplot as plt
import seaborn as sns; sns.set() # prettify matplotlib

import numpy as np
import sklearn.gaussian_process as gp
import GPy

In [ ]:
# local modules
import turbo as tb
import turbo.modules as tm
import turbo.plotting as tp
import turbo.gui.jupyter as tg
from GPyOpt.methods import BayesianOptimization

In [ ]:
# make deterministic
np.random.seed(40)

Function to optimize:


In [ ]:
xmin, xmax = -6, 6
ymin, ymax = -5, 5
x = np.linspace(xmin, xmax, 100)
y = np.linspace(ymin, ymax, 100)
f = lambda x,y: 1.5 * (np.sin(0.5*x)**2 * np.cos(y) + 0.1*x + 0.2*y) + \
    np.random.normal(0, 0.2, size=None if isinstance(x, float) else x.shape)
X, Y = np.meshgrid(x, y)
Z = f(X,Y)
best_z = np.min(Z)

In [ ]:
tp.surface_3D(X,Y,Z)

In [ ]:
domain = [
    {'name': 'x', 'type': 'continuous', 'domain': (xmin, xmax)},
    {'name': 'y', 'type': 'continuous', 'domain': (ymin, ymax)},
]

bo = BayesianOptimization(f=lambda X: f(X[0,0], X[0,1]), domain=domain, maximise=False)
bo.run_optimization(max_iter=30, eps=-1, verbosity=True)

In [ ]:
bo.save_report('GPyOptReport.txt')

In [ ]:
bo.save_evaluations('GPyOptEvaluations.csv')

In [ ]:
bo.get_evaluations()#[1].flatten().tolist()

In [ ]:
bo.plot_convergence()

In [ ]:
np.min(bo.get_evaluations()[1])

In [ ]:
bo.plot_acquisition()

In [ ]: