What the Split Does and Does Not Say
Compare training MAE and held-out MAE side by side while recognizing sampling variance on small splits, repeated peeking, and future distribution shift.
The problem
Across the previous five pages, we isolated disjoint role masks, fitted the training mean, froze predictions, scored held-out rows, and computed Held-Out MAE. Reporting [train_mae, held_out_mae] side by side answers a precise question: on this exact partition, how far did our frozen training rule miss unseen rows?
Treating one held-out MAE as a universal certificate of real-world accuracy overreaches in three ways: small-sample split luck, repeated hyperparameter peeking, and future regime shift.
Work through the numbers
Consider six [role, y] rows: [1, 10], [1, 12], [0, 14], [1, 14], [1, 12], and [0, 34]. Four calm readings sit near 12 while r5 = 34 is a genuine spike. Under this default split (swap = 0), training rows [10, 12, 14, 12] average tr_mean = 48 / 4 = 12.
Against 12, training errors [2, 0, 2, 0] average train_mae = 4 / 4 = 1, whereas held-out rows r2 = 14 (|14 - 12| = 2) and r5 = 34 (|34 - 12| = 22) average held_out_mae = 24 / 2 = 12, yielding [1, 12].
Now swap only the role labels of r3 and r5 (swap = 1). Training rows become [10, 12, 12, 34] with tr_mean = 68 / 4 = 17, train_mae jumps to (7 + 5 + 5 + 17) / 4 = 8.5, and held-out rows [14, 14] drop to held_out_mae = (3 + 3) / 2 = 3.
The live model
The left panel lists all six rows colored by split; the right chart compares train MAE (blue) and held-out MAE (amber). At default swap = 0, r5 = 34 sits in held-out and the MAE pair reads [1, 12]. Slide swap to 1 to trade roles between r3 and r5 without altering a single measurement: tr_mean moves to 17 and the MAE pair flips to [8.5, 3], making held-out error look smaller than training error by pure split luck.
![Side-by-side comparison of row targets and [train_mae, held_out_mae] showing [1, 12] when outlier row r5 sits in held-out.](../assets/ml/what-the-split-does-and-does-not-say--demo.png)
let swap = scene.parameter("swap", 0.0, 0.0, 1.0, 1.0);
let table = input.clone();
table.set(6, 1.0 - swap);
table.set(10, swap);
let role = table.select(1, 0);
let y = table.select(1, 1);
let tr_mask = role.eq(1.0).to(DType.F64);
let te_mask = role.eq(0.0).to(DType.F64);
let tr_mean = (y * tr_mask).sum().div(tr_mask.sum());
let abs_err = (y - tr_mean).abs();
let tr_mae = (abs_err * tr_mask).sum().div(tr_mask.sum()).reshape(1);
let te_mae = (abs_err * te_mask).sum().div(te_mask.sum()).reshape(1);
let answer = torch.cat(torch.list().add(tr_mae).add(te_mae), 0);
out.set("train_mean", tr_mean).set("train_and_test_mae", answer);
{
"train_mean": 12,
"train_and_test_mae": [
1,
12
]
}Your turn
Held-out spike r5 = 34 has leaked into the starter's baseline, pulling tr_mean up to 16 and distorting train_and_test_mae to [4, 10]. Fit the baseline on the training split alone before measuring errors so the default partition reports [1, 12].

let table = input;
let role = table.select(1, 0);
let y = table.select(1, 1);
let tr_mask = role.eq(1.0).to(DType.F64);
let te_mask = role.eq(0.0).to(DType.F64);
let tr_mean = y.mean();
let abs_err = (y - tr_mean).abs();
let tr_mae = (abs_err * tr_mask).sum().div(tr_mask.sum()).reshape(1);
let te_mae = (abs_err * te_mask).sum().div(te_mask.sum()).reshape(1);
let answer = torch.cat(torch.list().add(tr_mae).add(te_mae), 0);
out.set("train_mean", tr_mean).set("train_and_test_mae", answer);
{
"train_mean": 16,
"train_and_test_mae": [
4,
10
]
}Compute [train_mae, held_out_mae] from a baseline fitted strictly on training rows so held-out spikes cannot pull the fitted mean.
Keeping held-out rows out of tr_mean restores the training baseline 12, yielding tr_mae = 1 and te_mae = 12.
Read the result carefully
On small tables a single high-leverage row (34) swings [1, 12] into [8.5, 3], which is why k-fold cross-validation holds every row out once across disjoint folds. Notice that swap = 0 ({r2, r5}, MAE 12) and swap = 1 ({r2, r3}, MAE 3) both hold out r2.
Partitioning the six rows into three disjoint pairs {r2, r5}, {r0, r3}, and {r1, r4} holds every row out once: {r2, r5} gives tr_mean = 12 and MAE 12; {r0, r3} ([10, 14] against tr_mean = 72 / 4 = 18) gives (8 + 4) / 2 = 6; and {r1, r4} ([12, 12] against tr_mean = 18) gives (6 + 6) / 2 = 6, averaging (12 + 6 + 6) / 3 = 8.
Keep two further boundaries in mind. First, if you try twenty models and pick the winner by held-out MAE, that split has been used for selection and is no longer held out. Second, a random split drawn from winter traffic says nothing about summer demand—temporal or domain shifts require splitting by time or group.
Recap
- A clean train-test split guarantees zero target leakage between
tr_maskfitting andte_maskscoring on that partition ([1, 12]). - Small held-out sets suffer high sampling variance: swapping two role labels on identical data flips
[1, 12]to[8.5, 3]. - Repeatedly selecting models on held-out MAE leaks information through human choices, and random splits cannot detect future distribution shift.