Search budgets and nested cross-validation
Fix the objective and the budget before you search, record every trial, define what a "resource" is, and score the whole tuning recipe with nested cross-validation when you can't spare a separate test set.
You will be able to
- Separate learned parameters from hyperparameters and design choices
- Match a search strategy to its assumptions and say what it must record
- Check whether cheap rungs rank candidates the way full training does
- Read nested cross-validation's outer score and the optimism of the inner scores
Learned, chosen, or searched?
ReadCoefficients, network weights, covariance estimates and fitted imputation values are learned: the fitting procedure sets them from data. Width, penalty strength, learning rate, dropout, context length, number of clusters and the stopping rule are hyperparameters or design choices: you, or a search, set them.
Fine-tuning changes learned parameters with a new objective. Trying settings until a result looks good is something else, and it leaves a selection history that the final number has to account for.
Fix the budget first
ReadBefore launching a search, write down the primary development objective and the budget. Then:
- search penalties and learning rates on a log scale;
- list categorical choices explicitly;
- let a conditional setting exist only when its parent option is on;
- record every trial, including failed and pruned ones.
A result chosen from 500 configurations has a different history from one prespecified fit. Both can be honest, if the history is reported.
Strategies and what they assume
Read| Strategy | Good for | Assumes | Record |
|---|---|---|---|
| Grid | A few meaningful values | Few dimensions | The full grid and the tie rule |
| Random | A strong baseline | Sensible ranges | Each range and the seed |
| Bayesian (TPE) | Expensive fits | A smooth, stable objective | Space, surrogate, startup trials |
| HyperbandHyperband and ASHASearches that try many settings on a small budget and give more budget only to the best, rung by rung. ASHA does it in parallel. | Many settings, cheap early signal | Early scores predict late ones | Resource, brackets, rules |
| ASHA | The same, in parallel | As Hyperband; slow starters can be cut | Grace period, reduction factor |
Random search is a hard baseline to beat when only a few settings matter. A framework doesn't make the search space sound.
What is a "resource"?
ReadHyperband and ASHA spend a small resource on many candidates and more on the survivors. Define the resource. An epoch means different amounts of work on different dataset sizes, and a step differs with batch size or sequence length. Shorter clips, smaller images or fewer neighbors can change the task, not only the cost.
So check whether the cheap ranking holds at full size, give slow-converging settings a grace period, and report settings that improved late.
The best score flatters itself
ExplorePick the best of many scores measured on the same rows and you pick partly for luck. That selection-induced optimismSelection-induced optimismThe best of many scores, read on the rows used to choose it, overstates how the chosen setting does on rows it never saw. grows with the number of candidates and shrinks with more data. The winner's curse below shows the same filter on studies: keep only the significant ones, and the surviving estimates run high.
BExplorable · The winner's curse
Why do significant results from small studies overstate the effect?
Among the significant studies, how many times larger than the truth is the average reported effect?
Commit your prediction above to see the result
Make your prediction to see the result.
Nested cross-validation
ExploreNested cross-validationNested cross-validationTuning inside inner folds while outer folds score the whole tuning recipe on untouched rows. scores the whole tuning recipe. Outer folds hold rows out; inside each outer training part, inner folds run the full search and pick settings; the chosen model is then scored once on its outer fold. The outer scores estimate how the recipe does on rows it never saw.
DExplorable · Cross-validation folds
Which rows should be held out so the score predicts real performance?
Each scheme has a tempting shortcut: training error, plain random folds, or the best score from a search. Will the shortcut here look better than the true error on new data?
Scheme
Commit your prediction above to see the result
Make your prediction to see the result.
Averaging the inner scores of the winning settings is not nested cross-validation: those are the optimistic numbers the outer folds exist to correct. Different outer folds may choose different settings, and that spread is information too.
Tuning and nested CV in Predict
In the appIn Tune, choose Random search, Bayesian (TPE), Grid search, Sobol search, Hyperband or ASHA (successive halving), edit each hyperparameter's range in Search space, and set a time limit. Tuning defaults are unchanged, and tuning selects on pooled out-of-fold scores.
Hyperband and ASHA grow the Share of training rows rung by rung; the rung table ("Did the cheap rungs rank candidates right?") reports how well the smaller share's ranking held at the larger one.
Nested cross-validation is a Validation choice, off by default. Its run page shows each outer fold's chosen settings and outer score, the "Best inner score (what tuning alone reports)" and the Optimism of the inner scores, and flags "An unstable choice" when outer folds disagree.
Check: search and nesting
CheckpointCheck yourself
Which of these is a learned parameter rather than a hyperparameter?
Show the answer
Answer: c
The fitting procedure sets coefficients from data. λ, the cluster count and the learning rate are chosen, by hand or by a search.
Check yourself
You search a penalty between 0.0001 and 10. How should candidates be spread?
Show the answer
Answer: b
On a raw scale almost every draw lands near 10. Penalties and learning rates act multiplicatively, so a log scale covers them fairly.
Check yourself
A search tried 200 settings, 14 crashed. What belongs in the report?
Show the answer
Answer: c
The size of the search and its failures are part of the result. A winner from 200 tries carries more selection optimism than a single planned fit.
Check yourself
ASHA's rung table says the smaller share's ranking didn't hold at the larger share. What follows?
Show the answer
Answer: b
Successive halving works only when early scores predict late ones. When they don't, it discards settings that would have won.
Check yourself
What do nested cross-validation's outer scores estimate?
Show the answer
Answer: b
The search runs inside each outer training part, so every outer score comes from rows the search never used.
Check yourself
Nested CV reports a best inner score well above the outer score. How do you read that?
Show the answer
Answer: a
The inner score is the best of many on the same rows. The outer score is measured on rows the search never saw.
Check yourself
Each outer fold picked a very different penalty, yet the outer scores are similar. What does that suggest?
Show the answer
Answer: b
When different choices give similar outer scores, the recipe is robust to the setting even though the "best" value is unstable.
Recap
Recap- Learned parameters come from fitting; hyperparameters come from you or a search, and leave a history.
- Fix the objective and budget first; search penalties on a log scale; record every trial, failures included.
- Define the resource for Hyperband and ASHA, and check that cheap rankings hold.
- Nested CV scores the recipe on outer folds; the best inner score is the optimistic one.
Concepts in this lesson