Gaussian processes, scoring rules and calibration
Before this lesson: linear algebra lesson 07 (positive definite matrices and the Cholesky factor) and lesson 06 (Theorem 1 there: Gaussian conditioning; the Kalman update is the same formula). From lesson 01: the differential . From the probability track: the multivariate Gaussian. Helpful: kernel methods (for example kernel ridge regression), and time series lesson 10 for a first look at probabilistic forecasts. Time: about 100 minutes, plus the notebook.
Why this matters #
- Emulators of expensive simulators. A climate or ocean model run can cost thousands of node-hours. A GP trained on a few hundred runs is a cheap emulator: it predicts the model output for new parameter values, with an error bar. Emulators are used to calibrate model parameters (for example in the Calibrate–Emulate–Sample method, Cleary et al. 2021).
- Geostatistics and seismology. Kriging, the classic method to interpolate a field from scattered stations, is GP regression. Ground-motion models treat the residuals of nearby sites as a spatially correlated Gaussian field (Jayaram and Baker 2009); shake maps condition this field on the recorded stations.
- Bayesian optimisation. The next experiment or hyperparameter setting is chosen from the GP mean and variance.
- Honest uncertainty everywhere. Every probabilistic forecast must be checked. The CRPS, the PIT histogram and the spread–skill ratio score ensemble weather forecasts and diffusion models such as GenCast. Lesson 16 uses them to evaluate ML weather models.
1. Predict first #
2. The picture #
One data point #
Start with the smallest case. We observe one value at the input , and we want to predict the function at a test input . The model is
where is the unknown function and is measurement noise. A kernel gives the prior covariance of two function values: . So the pair is a 2D Gaussian vector with mean zero and covariance
The noise adds only to the variance of : it does not change . Conditioning a 2D Gaussian (Theorem 1 of lesson 06) gives
Read it in three steps.
- The mean copies a fraction of . The fraction is large when is close to (large covariance ) and when the noise is small.
- The variance drops from the prior value for the same two reasons.
- Far from , : the mean goes back to 0 and the variance goes back to the prior variance. Far from the data, the GP knows only what the prior says.
This is the same formula as the scalar Kalman update of lesson 06, with the forecast replaced by the prior and the gain .
A distribution over functions #
A GP does this for all inputs at once. Pick any finite set of inputs . Under a GP prior, the values are jointly Gaussian, with mean 0 and covariance matrix . Draw one sample of this Gaussian vector on a fine grid and connect the points: you get one random function. The most common kernel is the RBF (squared exponential) kernel
- The length scale is the distance over which function values stay strongly correlated. A small gives functions that wiggle fast; a large gives slow, smooth functions.
- The signal variance is the prior variance of . It sets the typical size of the function: about 95 % of prior function values lie in .
- The noise variance is the variance of the measurement error.
Click "Clear points" first to see the prior: three random functions (thin orange) and the 95 % band . Move and watch how fast the samples wiggle. Then click to add data points (aqua). Notice three things: the posterior mean (thick orange) passes near the points, the band is narrow near the data and opens up to the prior band in gaps, and the band does not depend on the values, only on where the points are (drag a point up and down). Switch the band to "new y" to add the noise variance .
You draw prior samples from a GP with an RBF kernel, . You change to . What happens to the samples?
sets the distance over which values stay correlated. With , two points 1 apart have correlation , so the function hardly changes over that distance. The size of the samples is set by alone: for every . The prior already contains , so it matters before any data.
Scoring a forecast with one number #
Now turn the question around: the forecast is given, and the outcome arrives. How good was the forecast? A probabilistic forecast of a number is a cumulative distribution function (CDF) . The observation is a single number. As a CDF, it is the step function : 0 to the left of and 1 from on. The continuous ranked probability score (CRPS) is the area of the squared gap between the two curves:
Lower is better. The gap is small when rises steeply (a sharp forecast) and when it rises at (a forecast centred on the outcome).
Move the three sliders. Top: the forecast CDF (orange), the step of the observation (aqua) and the squared gap (magenta), whose area is the CRPS. Make very small: the CDF becomes a step at and the CRPS becomes . Bottom: suppose the observations come from the truth . The orange curve is the average CRPS of your forecast over many observations, as a function of . Set : the curve is lowest at , the true spread, and it reaches the blue line , the score of the honest forecast. No other forecast does better on average.
A point forecast says "the temperature will be exactly " (a CDF that jumps from 0 to 1 at ). The observation is exactly . What is the CRPS?
The forecast CDF and the observation CDF are the same step at , so the gap is zero everywhere and the area is 0. In general a point forecast has CRPS , the absolute error. The CRPS needs only a CDF (or samples), not a density; this is why it can score ensembles and point forecasts. The value is the expected CRPS of the honest forecast for data from , not the score of a perfect hit.
3. Definitions and main results #
Gaussian processes and kernels #
A Gaussian process is a collection of random variables , one for each input , such that every finite subset is jointly Gaussian, with and . In this lesson : centre the outputs first (subtract their mean), or the prior pulls predictions to 0.
A function is a valid kernel when every matrix (the Gram matrix) is symmetric positive semidefinite. Only then is it a possible covariance. With (or for vector inputs), two standard kernels are
The kernel sets the smoothness of the functions. RBF samples are infinitely differentiable. The second kernel belongs to the Matérn family with smoothness parameter : a Matérn- process is times mean-square differentiable exactly when . So Matérn-5/2 samples are twice differentiable. Matérn-1/2 is the exponential kernel (the Ornstein–Uhlenbeck process), whose samples are continuous but nowhere differentiable. Physical fields are often rougher than RBF assumes, so Matérn-5/2 is a common default (Rasmussen and Williams, §4.2.1).
Notation. Training inputs , outputs , test inputs .
| Symbol | Meaning | Size |
|---|---|---|
| prior covariance of | ||
| covariance of the data | ||
| covariance between and | ||
| prior covariance of |
Theorem 1 (the GP posterior) #
Write for the posterior mean and for the posterior covariance.
Proof.
- Under the prior, , and the noise is independent of .
- So is jointly Gaussian with mean zero, , (the noise is independent of , so it adds nothing here), and .
- Gaussian conditioning: for a zero-mean Gaussian vector , (the covariance is a Schur complement; linear algebra lesson 07).
- Put and .
Three remarks.
- The mean is a weighted sum of kernels. with . This is kernel ridge regression with ridge parameter . It is also the Tikhonov / MAP solution of lesson 04, written with kernels.
- The covariance does not depend on , only on where the data are.
- versus . Theorem 1 is about the function value . A new measurement has one more independent noise term, so its variance is .
Computing it: one Cholesky factor does everything #
is symmetric positive definite: its smallest eigenvalue is at least . So it has a Cholesky factor: with lower triangular and . Rasmussen and Williams (Algorithm 2.1) compute everything from :
- . About flops: the only cubic step.
- . Two triangular solves, each. ( means "solve ".)
- Mean: .
- , then . This works because .
- , because .
Why not and ?
- Forming costs about three times more than the factor, and its rounding errors are larger. You never need the inverse itself, only products with it.
- is the product of eigenvalues. With many points, most of them are close to
, so the product underflows to in float64. Section 5 shows this at
, where but
detreturns 0. The sum of logs has no problem. - When is tiny and is long, is nearly singular and the factorisation can fail. Then add a small jitter (for example ) to the diagonal, and work in float64.
The cost is time and memory. At the factor needs about flops and needs 0.8 GB in float64. Larger problems need approximations (section 6).
You need the posterior mean and the log marginal likelihood for points. What is the best way to compute them?
The Cholesky factor costs flops, is backward stable for positive definite matrices, and gives both the solves and the log-determinant. The explicit inverse costs more and is less accurate, and det underflows to 0 for large , so its log is . An eigendecomposition also works but costs several times more. Gradient descent converges slowly when is ill-conditioned.
Theorem 2 (the log marginal likelihood) #
The kernel has hyperparameters . To choose them, look at the probability of the data under the model, with integrated out: the marginal likelihood (or evidence) .
Proof.
- and are independent.
- A sum of independent Gaussian vectors is Gaussian, and the covariances add: . (This does the integral in one line.)
- Take the log of the Gaussian density .
With the factor: .
The two terms pull in opposite directions.
- A short length scale lets the GP follow every data point. The data-fit term is then close to 0 (good). But such a model could produce many different data sets: is close to , its determinant is large, and the complexity penalty is large.
- A long length scale gives a simple model with a small (the values are strongly correlated, so the model "expects" only smooth data sets). But it fits wiggly data badly.
The maximum lies in between. The marginal likelihood prefers the simplest model that explains the data: an automatic Occam's razor. Choosing by maximising it is called type-II maximum likelihood (or empirical Bayes).
Move the length scale (the yellow line) along the evidence curve. The orange curve is the log marginal likelihood, the sum of the data fit (aqua), the complexity penalty (magenta) and a constant. The data fit rises as gets shorter; the penalty falls. For these 10 points and there are two local maxima: (a wiggly fit that explains almost every bump) and (a smooth fit that calls the bumps noise). Look at the fit below for each. Now raise to 0.5: one maximum remains.
Two local maxima are common. Rasmussen and Williams (§5.4.1, Fig. 5.5) show 7 data points with a "wiggly, low noise" optimum and a "smooth, high noise" optimum. The objective is not concave, so restart the optimiser from several initial values.
Theorem 3 (the gradient of the evidence) #
To maximise with a gradient method, we need its derivatives. For any hyperparameter ,
Proof.
- Differentiate : , so .
- Jacobi's formula (lesson 01): .
- Data-fit term: by step 1, .
- Complexity term: by step 2, .
- Add steps 3 and 4, and divide by .
Cost. Get from the factor once (). Then each hyperparameter costs only , because needs no matrix product.
Use log hyperparameters. Optimise . Every value is then positive without constraints, and a step changes a value by a factor, not by an amount. The chain rule gives . For the RBF kernel, with the matrix of squared distances and the elementwise product:
The Matérn-5/2 derivative
Write , so . Then , and . So
The derivative in is itself, as for every kernel of the form . Check such formulas against finite differences (the notebook does this for the RBF kernel).
Proper scoring rules #
Now the second half: how to judge a probabilistic forecast. A scoring rule gives a number to the forecast when the outcome happens. Here it is negatively oriented: lower is better. If the outcome is really drawn from a distribution , the expected score is .
Definition. is proper if for all and . It is strictly proper if, in addition, equality holds only for .
In words: if you believe , the best thing to report is itself. No hedging (making the forecast wider or narrower than you believe) can improve your expected score.
- The log score (the negative log-likelihood) is strictly proper. It needs a density, and it punishes a too-narrow forecast very hard when the outcome falls in its tail.
- The squared error of the forecast mean, , is proper but not strictly proper. Its expected value is the same for every with the right mean, whatever its spread. So it cannot reward a correct spread.
- The CRPS has two equal forms (Gneiting and Raftery 2007, eqs. 20–21):
The second form (the kernel form) needs only samples of . So it scores an ensemble directly (lesson 16). Its first term rewards being close to ; its second term rewards spread, so a forecast cannot win by being narrow alone.
The Gaussian CRPS. For , with and the standard normal density and CDF,
The CRPS has the units of . For a point forecast () it becomes , the absolute error: the CRPS generalises the absolute error to probabilistic forecasts.
Where the Gaussian formula comes from
Use the kernel form. For , , and the mean of for is . With and the symmetry , , this gives . For the second term, , so , and half of it is . Subtract.
Theorem 4 (the CRPS is strictly proper) #
If , and and have finite first moments, then
The second term does not depend on . The first term is never negative and is zero only for . So the honest forecast is the unique best one.
Why it is true, in one picture. Fix one point . Whether the outcome falls left or right of is a coin toss: heads () with probability . The forecast says "heads with probability ". The squared error of a probability for a coin toss (the Brier score) is smallest on average when the stated probability is the true one. The CRPS adds up these Brier scores over all thresholds .
Proof of Theorem 4
- Fix . Then is a Bernoulli variable with .
- Since : .
- Integrate over and swap the integral and the expectation. Both integrands are nonnegative, so this is allowed (Tonelli's theorem).
- The first term is . It is only when for almost every , and two right-continuous CDFs that agree almost everywhere agree everywhere. So is the unique minimiser: the CRPS is strictly proper.
Propriety is a statement about the expected score. On a single observation, a wrong forecast can score better than the right one; section 4 shows such a case. Always average a score over many cases before you compare forecasts.
Calibration and sharpness #
A proper score gives one number. To see what is wrong with a forecast, look at calibration.
- PIT. The probability integral transform of an observation is : the forecast
probability that the outcome is below the value that happened. If really comes from the
continuous distribution , then is uniform on . A forecasting system is
probabilistically calibrated when its PIT values, over many forecasts, are uniform. Draw them
as a histogram:
- flat: calibrated;
- U shape: too many outcomes in the tails, so the forecasts are too narrow (overconfident, under-dispersed);
- hump in the middle: the forecasts are too wide (underconfident, over-dispersed);
- slope: a bias; the outcomes fall more often on one side.
- Coverage. The central interval at level contains exactly when . So coverage at 50 %, 80 % and 95 % checks the PIT distribution at three places. One level is not enough: a Gaussian forecast for heavy-tailed data can cover 95 % correctly and still be wrong at 50 %.
- Sampling error. Observed coverage on independent test cases has standard error : for and . Test cases that share one weather situation or one sample path are correlated, so the effective is smaller.
- Sharpness is how concentrated the forecasts are, for example the mean predictive standard deviation. It depends on the forecasts alone, not on the outcomes.
The rule of Gneiting, Balabdaoui and Raftery (2007) is: maximise sharpness subject to calibration. A proper score such as the CRPS rewards both at once.
Choose a forecaster. The truth is a predictable part plus noise of variance 1. The forecaster issues ; the correct choice is , . Left: the PIT histogram (orange) against the flat ideal. Right: the observed coverage of the central intervals against the nominal level; the magenta segments show the gap from the diagonal. Try "too narrow" (U shape, coverage below the diagonal) and "too wide" (a hump). Then try "climatology": its histogram is flat too, but it is less sharp, and its mean CRPS is about instead of .
The PIT histogram of a forecast system on 5000 held-out cases is U-shaped: high bars near 0 and 1, low bars in the middle. What is wrong?
A PIT value near 0 or 1 means the outcome fell in a tail of the forecast. Too many of these means the forecast distributions are too narrow (overconfident). A too-wide forecast gives the opposite shape, a hump in the middle; a bias gives a slope. A GP that reports the band of for new measurements gives exactly this U shape.
A forecaster issues the climatological distribution (the long-term distribution of the variable) every day. Is this forecast calibrated?
Over many days, the outcomes are draws from the climatological distribution, so is uniform. The forecast is calibrated but useless for any single day: it is as wide as possible. This is why calibration alone is not enough, and why we also need sharpness or a proper score. With the numbers in the next paragraph, climatology has expected CRPS and the informed forecast .
Answers to section 1.
- The prior: mean , and variance for (plus for a new measurement). With , for every data point, so the data have no effect. This is why you centre (or add a mean function).
- No. Both are calibrated, so coverage cannot separate them, but B is sharper, and a proper score can see this. In the example of Gneiting, Balabdaoui and Raftery, with . B knows and issues . A issues the climatology . For a calibrated Gaussian forecast the expected CRPS is (Theorem 4 with ). So B scores and A scores on average. (The paper's simulation, Table 5, reports 0.56 and 0.78.)
- Fewer. The band of leaves out the noise variance , so it is too narrow for new measurements. Section 4 computes 82 % instead of 95 % at one test point; section 5 finds 40 % on held-out data with many training points.
4. Worked example #
Two training points with outputs . RBF kernel with and ; noise . Test input .
Step 1: the matrix . and . Add the noise to the diagonal:
Step 2: the Cholesky factor. , , :
Step 3: by two triangular solves.
- Forward, : ; .
- Backward, : ; .
Step 4: the posterior at . With one test point, is a vector: .
- Mean: .
- : ; .
- .
- For a new measurement: , standard deviation .
Step 5: the evidence.
- Data fit: .
- Complexity: . It is positive here because .
- Constant: .
- Total: .
Step 6: one gradient. , so Theorem 3 gives . The same formula gives for and for ; section 5 and the notebook check all three against finite differences. All three are negative: at this , the evidence would grow with a smaller signal variance, a shorter length scale and less noise.
Step 7: score one observation. Suppose is measured at .
- Correct forecast : , CRPS .
- Latent-only forecast (it forgets ): , CRPS .
The wrong forecast wins on this one observation. The log score agrees: for the wrong one against for the correct one. This is not a contradiction: propriety is about the expected score. If the correct forecast is the truth, the latent-only 95 % interval contains with probability , not . Over many test points this shows up, as the next section shows.
5. In code #
NumPy and SciPy check the worked example. The notebook for this lesson has these cells, the scikit-learn cross-check and the exercises.
import numpy as np
from scipy.linalg import cho_solve, solve_triangular
from scipy.stats import norm
def rbf(a, b, sf2=1.0, ell=1.0):
return sf2 * np.exp(-(a[:, None] - b[None, :]) ** 2 / (2 * ell**2))
# (a) The worked example with one Cholesky factor
X, y, xs, sn2 = np.array([0.0, 1.0]), np.array([1.0, 0.0]), np.array([0.5]), 0.1
K = rbf(X, X) + sn2 * np.eye(2)
L = np.linalg.cholesky(K) # K = L L^T
alpha = cho_solve((L, True), y) # K^{-1} y by two triangular solves
ks = rbf(X, xs)
v = solve_triangular(L, ks, lower=True)
mean = ks.T @ alpha
var_f = rbf(xs, xs) - v.T @ v
print(alpha.round(4), mean.round(4), var_f.round(4), (var_f + sn2).round(4))
# [ 1.3062 -0.7202] [0.5171] [[0.0873]] [[0.1873]]
# (b) The log marginal likelihood: data fit, complexity, constant
fit = -0.5 * y @ alpha
comp = -np.sum(np.log(np.diag(L))) # -1/2 log det K
const = -len(y) / 2 * np.log(2 * np.pi)
print(round(fit, 4), round(comp, 4), round(fit + comp + const, 4))
# -0.6531 0.0859 -2.4051
# (c) The CRPS of the two forecasts for y* = 0.8
def crps_gauss(mu, s, y):
z = (y - mu) / s
return s * (z * (2 * norm.cdf(z) - 1) + 2 * norm.pdf(z) - 1 / np.sqrt(np.pi))
sd_y, sd_f = np.sqrt(var_f + sn2).item(), np.sqrt(var_f).item()
print(round(crps_gauss(mean.item(), sd_y, 0.8), 4), round(crps_gauss(mean.item(), sd_f, 0.8), 4))
# 0.1724 0.1695
scikit-learn gives the same numbers and the gradient. Its kernel.theta holds
, the log hyperparameters of Theorem 3. The last lines
show why must come from a factor:
from sklearn.gaussian_process import GaussianProcessRegressor
from sklearn.gaussian_process.kernels import ConstantKernel as C, RBF, WhiteKernel
kernel = C(1.0) * RBF(1.0) + WhiteKernel(0.1)
gp = GaussianProcessRegressor(kernel, optimizer=None).fit(X[:, None], y)
print(gp.log_marginal_likelihood_value_) # -2.4051
th, h = kernel.theta, 1e-6
_, grad = gp.log_marginal_likelihood(th, eval_gradient=True)
fd = [(gp.log_marginal_likelihood(th + h * e) - gp.log_marginal_likelihood(th - h * e)) / (2 * h)
for e in np.eye(3)]
print(grad, np.array(fd)) # [-0.3275 -0.1338 -0.0194] twice
rng = np.random.default_rng(0)
Kb = kernel(np.sort(rng.uniform(0, 10, 400))[:, None])
print(np.linalg.det(Kb), np.linalg.slogdet(Kb)[1]) # 0.0 and about -860
Calibration on held-out data. Data come from the model itself (, ,
): four independent functions, each with 150 training and 1000 test points. The
GP uses the true hyperparameters. PIT values come from norm.cdf; coverage at level is the
fraction with :
rng = np.random.default_rng(1)
z_y, z_f = [], []
for _ in range(4):
Xa = rng.uniform(0, 10, 1150)[:, None]
Kf = (C(1.0) * RBF(1.0))(Xa)
ya = np.linalg.cholesky(Kf + 1e-8 * np.eye(1150)) @ rng.standard_normal(1150)
ya += 0.3 * rng.standard_normal(1150)
gp = GaussianProcessRegressor(C(1.0) * RBF(1.0) + WhiteKernel(0.09), optimizer=None)
gp.fit(Xa[:150], ya[:150])
mu, sd_y = gp.predict(Xa[150:], return_std=True) # sd for new measurements y_*
sd_f = np.sqrt(sd_y**2 - 0.09) # sd of f_* only: the wrong one for y_*
z_y.append((ya[150:] - mu) / sd_y)
z_f.append((ya[150:] - mu) / sd_f)
for name, z in [("y_* (with sn2)", z_y), ("f_* only ", z_f)]:
pit = norm.cdf(np.concatenate(z)) # uniform on (0, 1) if calibrated
cover = [np.mean(np.abs(pit - 0.5) <= p / 2) for p in (0.5, 0.8, 0.95)]
print(name, np.round(cover, 3), np.histogram(pit, bins=5, range=(0, 1))[0])
# y_* (with sn2) [0.504 0.812 0.953] [799 831 783 809 778] flat: calibrated
# f_* only [0.147 0.28 0.404] [1659 256 213 250 1622] U-shaped: far too narrow
With 150 points on the variance of is much smaller than , so the latent-only "95 % interval" covers only 40 % of new measurements.
6. Where it shows up #
- Machine learning.
- Bayesian optimisation picks the next hyperparameter setting or experiment from the GP mean and variance (for example with the expected-improvement rule).
- Kernel ridge regression is the GP mean.
- Infinitely wide neural networks are GPs (Neal 1996; the NNGP and NTK limits).
- Deep ensembles and MC dropout are judged with the same PIT, coverage and proper-score tools.
- ML for science.
- Emulators of expensive simulators: GP surrogates for the calibration of climate-model parameters and for history matching; the Calibrate–Emulate–Sample method (Cleary et al. 2021).
- Geostatistics: kriging is GP regression, used for mineral deposits, soil properties and rainfall maps.
- Seismology: ground-motion models treat the within-event residuals at nearby sites as a spatially correlated Gaussian field, often with an exponential (Matérn-1/2) correlation (Jayaram and Baker 2009). Conditioning this field on the recorded stations gives shake maps and regional risk estimates.
- Weather: ensemble and diffusion forecasts (GenCast) are compared by the CRPS and the spread–skill ratio; WeatherBench 2 reports both (lesson 16).
- Data assimilation: the Kalman update is the same Gaussian conditioning as Theorem 1, and background-error covariances are kernels (lesson 06).
- Large data. Exact GPs cost time and memory. Beyond about points, use inducing points (sparse variational GPs), structured kernels, or conjugate gradients on GPUs (GPyTorch). Standardise inputs and outputs, and keep the factorisation in float64.
7. Common mistakes #
- Intervals for new measurements from the variance of . Add for . Without it the intervals are far too narrow (40 % coverage in section 5).
- Forming or . Use the Cholesky factor:
cho_solve,solve_triangularand . - Not centring . The zero-mean prior pulls predictions to 0 away from the data.
- Raw hyperparameters and one start. Optimise log hyperparameters, and restart from several points: the evidence can have several local maxima.
- Calibration at one level, on training data, or without an error bar. Check several levels (or the PIT histogram) on held-out data, with in mind.
- Coverage as the only metric. Climatology has perfect coverage and no skill. Report a proper score as well.
- Judging from one observation. Propriety holds in expectation (section 4).
- Sign conventions. Gneiting and Raftery write scores as rewards (higher is better); their CRPS is the negative of the one here.
8. Check yourself #
- One training point , ; RBF kernel with , ; .
Give the posterior mean and variance of at and at .
Answer
At : mean , variance . At : , mean , variance . - Why compute with , and not ?
Answer
It reuses the one factor (one triangular solve per column, no inverse). Also, is symmetric positive semidefinite by construction, so stays symmetric and its diagonal is at most the prior variance. Forming costs more and is less accurate. - Derive for the RBF kernel. Why is its diagonal zero?
Answer
, so : the matrix . On the diagonal : the prior variance does not depend on , and neither does the noise term. - Show from the kernel form that the CRPS of a point forecast at is .
Answer
For a point mass at , , so and . - On 400 independent held-out points, your 95 % intervals cover 0.91. Is this consistent with
calibration?
Answer
The standard error is , and is about 3.7 standard errors. Not consistent: the intervals are too narrow (overconfident). If the test points are correlated, the effective is smaller and the evidence is weaker. - Why is the squared error of the forecast mean not enough to judge a probabilistic forecast?
Answer
Its expected value depends only on the mean of . Two forecasts with the same mean and very different spreads get the same expected score, so it is proper but not strictly proper. The CRPS and the log score also reward the right spread.
Give the GP posterior mean and covariance of .
Mean , covariance , with .
What is the predictive variance of a new measurement , compared with that of ?
: one more independent noise term.
How do you get from the Cholesky factor ?
, because .
Write the GP log marginal likelihood and name its terms.
(data fit) (complexity penalty) (constant).
What is the gradient of the log marginal likelihood in a hyperparameter ?
with .
What does the length scale of an RBF kernel control?
The distance over which function values stay strongly correlated: small gives fast wiggles, large smooth functions. The size of the function is set by .
When is a scoring rule proper?
When the expected score under the true distribution is minimised by reporting : for all . Strictly proper: only attains the minimum.
Give the CRPS of a Gaussian forecast .
with .
What is the PIT value of an observation, and how is it distributed for a calibrated forecast?
, the forecast CDF at the observed value. It is uniform on .
When does the central interval at level contain the observation, in terms of the PIT value ?
Exactly when .
9. Interview angle #
- "What does an exact GP cost, and how do you scale it?" — time and memory for the Cholesky factor. For large : inducing points (sparse variational GPs), structured kernels, or iterative solvers (conjugate gradients) on GPUs.
- "Why maximise the marginal likelihood and not the training fit?" — The complexity penalty guards against overfitting (Occam's razor). It can still fail: local optima, very few points, a wrong kernel, or many hyperparameters with little data.
- "Is the negative log-likelihood a proper score? Why use the CRPS?" — Both are strictly proper. The CRPS needs no density (it works on ensembles), has the units of , reduces to the absolute error for a point forecast, and is less sensitive to a single outlier.
- "Your 95 % intervals cover 95 %. Is your model calibrated?" — Not proven. Check other levels or the PIT histogram, check by subgroup (lead time, region, input range), and check sharpness with a proper score.
- "GP or neural surrogate?" — A GP is data-efficient and its variance grows away from the data. A neural surrogate scales to large and to field outputs, but its uncertainty must be checked and often recalibrated.
10. Practice #
The notebook for this lesson runs in Colab and in the browser. It has five exercises, each with a check cell and a folded solution:
- Write the GP posterior with one Cholesky factor, and check it against scikit-learn.
- Compute the log marginal likelihood stably for points, where
detunderflows. - Write the gradient in the log hyperparameters, and check it against finite differences.
- Write the Gaussian CRPS in closed form, and check it against the integral of the squared gap and against the kernel form with samples.
- Measure coverage at 50, 80 and 95 % on held-out data, for intervals of and of .
11. Watch and read #
- Rasmussen and Williams, Gaussian Processes for Machine Learning (free PDF): §2.2 (the function-space view, eqs. 2.22–2.26; Algorithm 2.1), §4.2.1 (the Matérn class), §5.4.1 (the marginal likelihood, its three terms and two local optima), App. A.4 (Cholesky).
- Gneiting and Raftery, Strictly Proper Scoring Rules, Prediction, and Estimation, JASA 2007: §2.1 (proper and strictly proper), §4.2 (the CRPS and its Gaussian closed form).
- Gneiting, Balabdaoui and Raftery, Probabilistic Forecasts, Calibration and Sharpness, JRSS-B 2007: §2 (modes of calibration, the climatological forecaster, the sharpness principle), §3.1 (PIT histograms).
- The scikit-learn user guide on Gaussian processes and GPyTorch for large-scale GPs.
Runs in your browser with nothing to install. The notebook repeats the key demos and has exercises with checks; solutions are inside, folded.
No Google account needed: Python runs inside your browser. The first start downloads about 40 MB; your changes are saved in this browser only.