Log inStart free
LESSON 4.54 · 6 STAGES · 2 CONTROLS · 3 CHECKSPRO · PREVIEW

Grid search vs random search

Watch grid search and random search spend the same trials on one model.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 2 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 4.54 · TUNING BAY41 × 21 FITS · BEST RMSE 0.120
01
Stage 1 of 6 · Validation error
Hyperparameter tuning looks for the lowest validation RMSE. Each cell trains one model with one γ and one λ.
Explain it simply

Each small square is one full training run of the model on the right. It is ridge regression with an RBF kernel. Gamma sets how narrow each bump of the curve is. Lambda sets how hard the weights shrink. Faint squares miss the validation points by little, and strong red squares by a lot.

A map of 41 by 21 cells. The lowest validation error is 0.120. A dashed line marks the good zone.

data pointsvalidation errorgood zonetrialsbest trial, its fit
γ = 10^1.5 · λ = 10^−3.0 · RMSE 0.120map best● training ○ validation | miss10⁰10¹10²10³10⁴10⁻³10⁻²10⁻¹γ (RBF width) →λ ↑validation error mapgood zone ≤ 0.144E = validation RMSE · best 0.120 at γ = 10^1.5, λ = 10^−3.0γ = 10^1.5 · λ = 10^−3.0 · RMSE 0.120map best● training ○ validation | miss10⁰10¹10²10³10⁴10⁻³10⁻²10⁻¹γ (RBF width) →λ ↑validation error mapgood zone ≤ 0.144E = validation RMSE · best 0.120 at γ = 10^1.5, λ = 10^−3.0
Toy: kernel ridge regression · 16 training, 16 validation points · γ, λ on log scales
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
E(γ,λ)=116∑i(y^i−yi)2\sy{e}{grad}{E}(\sy{g}{param}{\gamma}, \sy{l}{param}{\lambda}) = \sqrt{\tfrac{1}{16} \textstyle\sum_i (\sy{yh}{out}{\hat y_i} - \sy{y}{data}{y_i})^2}
E(101.5,10−3.0)=0.120E(10^{1.5}, 10^{-3.0}) = 0.120

The error is the typical miss on the 16 validation points.

Common mix-ups

MYTHA 3 × 3 grid tests 9 values of each knob.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01With 25 trials, does grid search find a lower RMSE than with 9 trials?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 2 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.