A Gaussian process is a prior over functions defined by a kernel: any finite set of function values is jointly Gaussian. Draw functions from the prior (Figure 6.4), condition on noisy data to get a predictive mean and an uncertainty band that grows away from the data (Figure 6.8), see how the length scale and the noise level change the fit (Figure 6.5), let the marginal likelihood choose the hyperparameters, and watch automatic relevance determination switch off an irrelevant input (Figures 6.9 and 6.10).
Data: sin(2πx) plus noise of sd 0.3 at equally spaced inputs on [0, 1] (the first N of ten, as in Figure 6.8 where the right-most three are left out), generated with a seeded generator. Inputs on [0, 1] are half the width of the book’s [−1, 1], so a given θ1 here corresponds to θ1/4 there. ARD data: x1 ~ N(0, 0.352), x2 = x1 + noise, x3 independent, N = 100. Optimiser: Newton (one input scale and noise) or L-BFGS (ARD).
code/ch06_kernel_methods.py (functions gp_predict, gp_log_marginal, gp_fit, classes GaussKernel and ExpKernel; Figures 6.4 to 6.10) and code/checks_ch06.py (predictive against direct conditioning, gradient of the marginal likelihood by finite differences).