TL;DRSplit data into train, validation, and test sets — and never let test leak.
The training set fits the model; the validation set tunes hyperparameters and picks models; the test set is touched once, at the end, to estimate real-world performance. Mixing them causes leakage — optimistic scores that collapse in production. The cardinal rule: the test set is sacred. Tuning on it is the most common way people fool themselves.
Key points
Train fits · validation tunes · test judges
Touch test only once, at the very end
Leakage → fake-good scores
The test set is sacred
Common mistakes
Tuning on the test set (leakage)
Preprocessing fit on all data before splitting
Peeking at test repeatedly
Try it: Assign roles: which set tunes hyperparameters, which estimates real performance?
Example code
<!doctype html><html><head><meta charset="utf-8"></head>
<body style="background:#06040d;color:#e6e0ff;font-family:monospace;padding:20px"><pre>train → fit the model
val → tune & select
test → final, one-time judgment (never tune on it)</pre></body></html>