Models learn their parameters from data, but someone has to choose the settings around the learning. Explore a real map of validation error, then send grid search, random search and Bayesian optimisation across it.
The model here is kernel ridge regression with a Gaussian kernel. Its parameters (one weight per training point) are learned from the data. Two hyperparameters are set from outside: the kernel width γ (large γ means a wiggly, local fit) and the ridge penalty λ (large λ means a smoother, more cautious fit). Click a cell on the map to see the curve that setting produces.
Grid search tries evenly spaced settings. Random search tries randomly chosen ones. Bayesian optimisation fits a cheap statistical model of the landscape to the results so far and picks the next setting where improvement looks most promising. All three strategies get exactly the same number of evaluations (the budget is always a square, k², so a k×k grid fits exactly). Bayesian optimisation counts its 5 random starting evaluations inside that total. The chart shows the best error each strategy has found after each evaluation, for your current budget and random draw.
To compare strategies fairly, repeat the search many times and average. This button runs 20 independent searches of random search and Bayesian optimisation at budgets 9, 16, 25 and 36 (the same budget for every strategy in each column, with Bayesian’s 5 random starts counted inside it) on the current landscape and range, and compares them with a grid of the same size. It takes a moment.
Picking the best of many settings by cross-validation error selects partly for luck. The error of the winning setting on fresh test data is often worse than its cross-validation error (not always, since the test sample is also noisy). The more settings you compare, the larger this effect can be. The same applies to the lowest-CV cell of the whole map: it is the best observed score among 961 settings, and quoting its CV score would be optimistic too. A final test set that was never used for tuning gives an honest check. Also note that a CV estimate from only 30 points can fall below the noise variance σ² by sampling variability: σ² is the minimum expected test MSE under this data-generating process, not a bound on every estimate.
Numbers below update live from the current landscape, search and selected cell.
Symbols: μ* is the best objective value observed so far, μ(θ) is the surrogate’s predicted mean at setting θ, s(θ) is its predictive standard deviation (not the noise σ), and Φ and φ are the standard normal CDF and density. This is the form for minimisation under a Gaussian predictive distribution. Expected improvement (EI) balances settings that look good with settings that are still uncertain. Here the surrogate models log10 of the CV error, standardised to mean 0 and sd 1 over the results so far, so μ*, μ, s and EI are all in standardised log units, not raw MSE. The panel below also shows the back-transformed predicted CV error.
Give every strategy exactly 16 evaluations (Bayesian: 5 random starts plus 11 guided) and compare what each finds with the lowest-CV cell of the map.
Noisy data and a larger budget of 64 random trials, chosen on purpose to stress selection. Compare the winner’s cross-validation error with its error on fresh test data.
Restrict the search to λ ≥ 1 (strong regularisation only). How much worse is the best setting any strategy can find?