Initialisation Choices

A quick demonstration of why random sampling during the pre-phase of Bayesian optimisation is not optimal as it does not achieve the best coverage of the input space.

Alternative pseudo-random sequences such as LHS generally perform better.


In [ ]:
%load_ext autoreload
%autoreload 2

In [ ]:
%matplotlib inline
%config InlineBackend.figure_format = 'svg'
import matplotlib.pyplot as plt
import seaborn as sns; sns.set() # prettify matplotlib

import numpy as np
import sklearn.gaussian_process as gp

In [ ]:
# local modules
import turbo as tb
import turbo.modules as tm
import turbo.plotting as tp
import turbo.gui as tg

In [ ]:
bounds = [
    ('x', 0, 10),
    ('y', -2, 2)
]

In [ ]:
np.random.seed(0)
plt.title('Uniform Random Sampling: 20 samples')
plt.scatter(np.random.rand(1, 20)*10, -2 + 4*np.random.rand(1, 20))
plt.show()

In [ ]:
LHS = tm.LHS_selector(num_total=20)

In [ ]:
np.random.seed(0)
samples = LHS(20, tb.Bounds(bounds))

In [ ]:
plt.title('Latin Hypercube Sampling: 20 samples')
plt.scatter(samples[:,0], samples[:,1])
plt.show()

In [ ]: