Demonstration 1 of 1
Random folds against leave-one-subject-out, scored on new people
How far above the score on new people does a random stratified split sit, and does leave-one-subject-out close the gap?
With identical people a model that has seen a window's neighbours cannot cheat, because nothing about the person helps. As people differ, the random split lets the model learn each person's own cadence, amplitude and orientation and recognize their other windows, so it scores far above what it can do on someone new. Leave-one-subject-out withholds the whole person and lands near the new-people score.
Scroll sideways for the whole equation
F1_c is the F1 score of activity class c, C the number of classes, y the true activity and the prediction is the model's class for a window. Macro-F1 averages F1_c over classes.
Predict first. With moderately distinct people (1.0), how does the macro-F1 of random stratified 5-fold compare with the score on new people?
Choose an example
Scroll sideways for the whole figure
Constructed example: four seeded synthetic cohorts of simulated wearable recordings and extremely randomized trees, measured by the chapter activity.
Calculated values
- Random stratified macro-F1
- 0.799
- Leave-one-subject-out macro-F1
- 0.588
- Macro-F1 on new people
- 0.604
- Random minus new people
- +0.195
- Sitting vs standing, new people
- 0.528
At distinctiveness 1.0, random stratified folds report macro-F1 0.799 and leave-one-subject-out 0.588, while the model scores 0.604 on 12 new people. The random estimate is off by 0.799 - 0.604 = 0.195; leave-one-subject-out is off by 0.017. For sitting against standing alone the three scores are 0.724, 0.473 and 0.528. The random split overstates the transfer.
Worked steps
- Random stratified: 0.799 - 0.604 = +0.195 (estimate minus new people).
- Leave-one-subject-out: 0.588 - 0.604 = -0.017.
- Sitting against standing, random minus new people: 0.724 - 0.528 = +0.196.
- Cohorts averaged: 4, each with 8 development subjects and 12 new people.
Use the idea
Group the validation splits by subject (and by recording or session where those also repeat), report the subject-held-out estimate, and check class-pair confusions such as sitting against standing separately.
Where the conclusion applies
Constructed signals with a simple generator, six activities, and extremely randomized trees standing in for the chapter's gradient boosting. Subject differences are a built-in mechanism of cadence, amplitude and orientation; real subjects differ in other ways. With identical people the overlapping windows cost nothing measurable here because the activities are separable; with weaker class signal they might, and this activity does not test that.
Check your understanding: With identical people (0), why do all three estimates agree even though the random folds mix overlapping windows?
Chapter 23 source: section "The Fix: Leave-One-Subject-Out CV".