Lensa ML
Lensa ML

Train, Validation & Test Sets

Step 1 of 6

Why Split?

You can't grade your own exam

xydegree = 1
Model complexity (polynomial degree)1
DEGREE
1
TRAIN FIT
88%
PARAMS
2

A simple model captures the general trend but doesn't memorize individual points. The training fit is moderate.

Step 1 of 6: Why Split?

You can't grade your own exam

xydegree = 1
Model complexity (polynomial degree)1
DEGREE
1
TRAIN FIT
88%
PARAMS
2

A simple model captures the general trend but doesn't memorize individual points. The training fit is moderate.

Step 2 of 6: Train & Test

The basic split

Train (24)Test (6)80/20xy
Train/Test ratio80/20
Model degree3
TRAIN SIZE
24
TEST SIZE
6
TRAIN SCORE
89%
TEST SCORE
83%

A 80/20 split is standard. The test set gives an unbiased estimate of how the model will perform on new, unseen data.

Step 3 of 6: The Validation Set

Tuning without cheating

Train (20)Val (5)Test (5)65%15%20%xy
Validation fraction15%
Model degree3
TRAIN
92%
VAL
57%
TEST
84%

The validation set is your practice exam. You use it to tune hyperparameters (like model complexity) without touching the test set. A 15% validation split is typical. The test set stays locked away until final evaluation.

Step 4 of 6: Underfitting & Overfitting

The training curves tell the story

UnderfitSweet SpotOverfitComplexity →LossTrainValgap
Model complexity3
TRAIN LOSS
0.608
VAL LOSS
0.903
GAP
0.295

Good fit! Both losses are low and the gap is small (0.30). The validation set helps us find this sweet spot without touching the test set.

Step 5 of 6: Cross-Validation

Using all data for validation

176.3%269.3%380.1%472.2%572.6%TrainValidationavg: 74.1%
Number of folds (k)k = 5
FOLDS
5
AVG SCORE
74.1%
STD DEV
3.7%

K-fold cross-validation rotates through 5 folds so every data point is validated exactly once. 5-fold is the most popular choice. It balances bias and variance in the performance estimate. Std of 3.7% tells you how stable the estimate is.

Step 6 of 6: The Golden Rule

Never touch the test set until the end

TrainLearnValidateTuneRepeatIterateTestFinal evaliterateReported75.0%Real-world75.0%
Times test set was "peeked" at0
REPORTED
75.0%
REAL-WORLD
75.0%
INFLATION
0%

The golden rule: never touch the test set until your final evaluation. The workflow is: train on training data, tune on validation data, and only evaluate once on test data.