Gaussian Processes for Machine Learning
Authors: Carl Edward Rasmussen, Christopher K. I. Williams
Published: 2006
Publisher: MIT Press
Link: Book Website
Summary
This comprehensive textbook establishes Gaussian Processes (GPs) as a principled Bayesian approach to nonparametric regression and classification. It provides the connection between GPs and kernel methods through the covariance function, unifying probabilistic and RKHS perspectives.
Key Contributions
1. GP-Kernel Connection
A Gaussian Process is a distribution over functions:
where:
- is the mean function
- is the covariance (kernel) function
2. Posterior Distribution
Given observations , the posterior at test point is:
where:
3. Marginal Likelihood
The log marginal likelihood for hyperparameter selection:
GP-RKHS Connection
Equivalence
The GP posterior mean equals the RKHS solution:
with .
Different Perspectives
| Aspect | GP View | RKHS View |
|---|---|---|
| Function | Random variable | Fixed unknown |
| Prior | ||
| Inference | Bayesian posterior | Regularized ERM |
| Uncertainty | Full posterior | Point estimate |
Common Kernels
Squared Exponential (RBF)
Properties: Infinitely differentiable, very smooth functions.
Matérn Class
Special cases:
- : Exponential (Ornstein-Uhlenbeck)
- : Once differentiable
- : Twice differentiable
- : Squared exponential
Periodic Kernel
For periodic functions with period .
Implementation
import numpy as np
from scipy.linalg import cholesky, cho_solve
class GaussianProcess:
def __init__(self, kernel, noise_var=1e-6):
self.kernel = kernel
self.noise_var = noise_var
def fit(self, X, y):
self.X_train = X
self.y_train = y
# Compute kernel matrix
K = self.kernel(X, X)
K += self.noise_var * np.eye(len(X))
# Cholesky decomposition for numerical stability
self.L = cholesky(K, lower=True)
self.alpha = cho_solve((self.L, True), y)
def predict(self, X_test, return_var=False):
# Cross-covariance
K_star = self.kernel(X_test, self.X_train)
# Posterior mean
mean = K_star @ self.alpha
if return_var:
# Posterior variance
v = cho_solve((self.L, True), K_star.T) # shape: (n_train, n_test)
K_ss = self.kernel(X_test, X_test)
var = np.diag(K_ss) - np.sum(K_star.T * v, axis=0)
return mean, var
return mean
def log_marginal_likelihood(self):
"""Compute log marginal likelihood for hyperparameter optimization."""
n = len(self.y_train)
# Data fit term
data_fit = -0.5 * self.y_train.T @ self.alpha
# Complexity penalty (log determinant via Cholesky)
complexity = -np.sum(np.log(np.diag(self.L)))
# Normalization
norm = -0.5 * n * np.log(2 * np.pi)
return data_fit + complexity + norm
def rbf_kernel(X1, X2, lengthscale=1.0, variance=1.0):
"""Squared exponential (RBF) kernel."""
sq_dist = np.sum(X1**2, axis=1, keepdims=True) + \
np.sum(X2**2, axis=1) - 2 * X1 @ X2.T
return variance * np.exp(-0.5 * sq_dist / lengthscale**2)
Hyperparameter Optimization
Gradient-Based
Maximize log marginal likelihood:
Automatic Relevance Determination (ARD)
Use separate lengthscale per dimension:
Small indicates relevant dimension.
Scalability
Computational Challenges
- Training: for matrix inversion
- Prediction: for new point
- Memory: for kernel matrix
Sparse GP Methods
- Subset of data: Use inducing points
- FITC/PITC: Structured approximations
- Variational: Inducing point variational inference
Applications
- Bayesian optimization: Surrogate modeling with uncertainty
- Spatial statistics: Kriging for geostatistics
- Time series: Forecasting with uncertainty
- Active learning: Acquisition functions using variance
- Emulation: Surrogate for expensive simulations
Citation
@book{rasmussen2006gaussian,
title={Gaussian Processes for Machine Learning},
author={Rasmussen, Carl Edward and Williams, Christopher KI},
year={2006},
publisher={MIT Press}
}
Further Reading
- Williams, C. K. I. (1998). Computation with infinite neural networks
- Titsias, M. (2009). Variational learning of inducing variables in sparse GPs
- Hensman, J., et al. (2013). Gaussian processes for big data