Select inside each outer evaluation fold
The score used to choose a hyperparameter is optimistically biased as a performance estimate. Nested evaluation separates inner selection from outer assessment. Each outer fold chooses its own candidate using only its inner validation scores, then evaluates that choice on the untouched outer partition.
This exercise receives precomputed scores so selection leakage can be tested without a costly training run. Candidate names break exact ties deterministically. The outer result is consulted only after selection; choosing a candidate by its outer score is explicitly the bug the checks expose.
inner={"small":[.7,.8],"large":[.9,.5]}
chosen=min(inner,key=lambda k:(-sum(inner[k])/len(inner[k]),k))
print(chosen)Review the design
Nested evaluation estimates the full selection procedure rather than one fixed configuration. Final deployment still needs a separately chosen configuration, a locked test set when appropriate, and an uncertainty analysis.
Your task
Implement nested_report(folds). Each fold is a dict candidate -> {inner:[scores], outer:score}. Select highest mean inner score, lexical name on ties. Return (chosen_names,mean selected outer score). Validate nonempty folds/candidates/inner scores and finite numbers.
The explanation opens here once every check passes.