Slice-level cross-validation leaks: 99.99 % against 80.8 % on the same MRI scans

A 2026 Alzheimer's paper shows that splitting MRI slices at random gives 99.99 per cent accuracy and splitting by subject gives 80.8 per cent. We rebuild both splits with fibub's train-test split tool and show where the leak comes from.

Medical imaging datasets are usually many pictures of few people. Split those pictures at random and the same person’s brain appears in both the training and the test set, so a model can score nearly perfectly by recognising the person rather than the disease. A 2026 paper in Applied Sciences measures that gap on one dataset: 99.99 % accuracy when 86,437 MRI slices from 347 subjects are split at the slice level, and 80.8 % when the same model and the same pipeline are split by subject. This article rebuilds both splits with the train-test split, shows that the leak is not a matter of luck but of arithmetic, and reproduces the two accuracies with a classifier that does nothing but memorise. Then take the honest split onward with the confusion matrix and check your table for duplicates first with the CSV profiler.

The paper in brief

The authors use the OASIS cross-sectional MRI collection as repackaged on Kaggle: 347 subjects, 86,437 axial slices, about 250 slices per subject, labelled non-demented against demented in a 78:22 split, with only two subjects in the moderate-dementia class. They train an attention-based multi-scale network two ways. With subject-level stratified 10-fold cross-validation, where every slice of one subject stays in one fold, accuracy is 0.808 (AUC 0.873, sensitivity 0.620), rising to 0.824 when slice predictions are aggregated per subject. With image-level 10-fold cross-validation, the identical pipeline reports 0.9999 accuracy and an AUC of 1.0000.

The paper’s point is that the second number is an artefact, and that published accuracies above 99 % on this dataset should be read as leakage. Our interest is that both numbers can be checked without a GPU.

Checked with the tools

We rebuilt a cohort with the paper’s shape (our simulation): 347 subjects, 86,437 slices, 249 or 250 slices each, and 76 demented subjects, which puts 21.9 % of slices in the demented class, close to the paper’s 22 %. Then we used the tool’s own split functions.

Step 1: count the leak. A record-wise (slice-level) 10-fold split of 86,437 rows gives folds of 8,644 and 8,643 slices. In every one of the ten folds, all 347 subjects have slices in both the training part and the test part. Not most of them: all of them, in all folds. The grouped (subject-level) split gives 34 or 35 subjects and 8,470 to 8,719 slices per fold, matching the paper’s “about 35 subjects and 8,000 to 10,000 images”, with zero subjects split across folds.

Step 2: the leak is arithmetic, not bad luck. The chance that all of a subject’s slices happen to land in the same fold of a ten-fold random split is 10 × (1/10)ⁿ for n slices: 10 % at two slices, 1 % at three, one in a thousand at four, one in a hundred thousand at six (Figure 1). At 249 slices it is about 10⁻²⁴⁸. No seed, no shuffle and no amount of repetition can rescue a record-wise split when each subject brings hundreds of rows.

A slice-level fold cannot keep a subject togetherA slice-level fold cannot keep a subject together020406080100123456789101112Slices per subjectChance the subject stays in one fold (%)one in a thousandfibub.com
Figure 1. The chance that all of one subject's slices land in the same fold of a ten-fold slice-level split, worked out for one to twelve slices. Beyond about six slices the subject is certain to appear on both sides, and the MRI study has roughly 250 slices each.

Step 3: reproduce both accuracies with a memoriser. We built the dumbest possible classifier: for a test slice, look for other slices of the same subject in the training part; if there are any, copy their label, and otherwise guess the majority class. It has no pixels, no network and no training.

Split Our memoriser The paper’s network
Record-wise (slice-level) 10-fold 1.0000 0.9999
Grouped (subject-level) 10-fold 0.7810 0.808

That is the whole story in two lines. The 0.9999 reported for image-level validation is what you get from identity, not from radiology. And the subject-level 0.808 is only 2.7 percentage points above what a majority-class guess achieves on this imbalance, which is why the paper’s own sensitivity of 0.620 matters more than its accuracy.

Step 4: the price of the honest split. Grouped splits move whole people, so the class mix of the test set bounces around. Over 200 grouped 80/20 splits of our cohort, the demented share of the test slices ranged from 10.0 % to 34.3 % (95 % of them between 12.9 % and 31.4 %), while a stratified slice-level split held it at 21.9 % every time (Figure 2). With two moderate-dementia subjects and ten folds, at most two of the ten folds can contain one, which is a concrete reason to merge classes as the paper does rather than report per-class scores for a class with two people in it.

Class mix of the test set when whole subjects moveClass mix of the test set when whole subjects move10152025303550100150200The 200 grouped splits, sortedDemented share of test slices (%)grouped 80/20 splitsstratified slice-level splitfibub.com
Figure 2. Our simulation with the tool's grouped and stratified splits on a cohort of 347 subjects: the class mix of the test set when whole subjects move, over 200 seeds, against one stratified slice-level split.

That trade-off has a name in the tool: Grouped keeps subjects whole, Stratified keeps the class shares, and you often want both. Where a dataset has enough subjects, group the split and report the spread over several seeds; where it does not, say so.

Check Paper Our tool result
Subjects leaking across a slice-level fold leakage claimed 347 of 347, in all 10 folds
Subjects per subject-level test fold about 35 34 to 35
Slices per subject-level test fold 8,000 to 10,000 8,470 to 8,719
Image-level accuracy 0.9999 1.0000 for a pure memoriser
Subject-level accuracy 0.808 0.781 for a majority-class guess
Folds that can hold a moderate-dementia subject not stated 2 of 10

How we made the graphs

Both charts and every number above come from scripts/blog-figures/slice-level-versus-subject-level-cross-validation-leakage.mjs in fibub’s public code. It calls kfold, groupKfold, groupSplit, stratifiedSplit and balance from src/lib/sci/split.ts, the maths behind the train-test split.

The cohort’s shape (347 subjects, 86,437 slices, about 250 each, 22 % demented, two moderate-dementia subjects) and both accuracies come from the paper. Which subject has which label, and the even 249-or-250 slices per subject, are our assumption: we did not download the images, and no MRI data is used here. The memoriser is our own two-line classifier, not the paper’s network.

How we test the maths

On every change to fibub, tests/sci.mjs runs tests/sci-tools/train-test-splitter.mjs, which pins the split counts against scikit-learn 1.9:

  • train_test_split sizes: 41 rows with 20 % test must give 32 + 9, and 137 rows with 15 % must give 116 + 21, as scikit-learn’s ceil rule does.
  • Stratified test counts per class must match train_test_split(stratify=y) over 60 random states (for a 40-row example with 24, 7 and 9 in the classes and 20 % test: 5, 1 and 2).
  • StratifiedKFold per-fold class counts, KFold and GroupKFold fold numbers for every row, and the number of test groups from GroupShuffleSplit, must all match scikit-learn on a 200-row set with 23 groups.
  • New with this article: a 347-subject, 86,437-slice cohort must give ten record-wise folds in which all 347 subjects appear on both sides, and ten grouped folds of 34 to 35 subjects and 8,470 to 8,719 slices with no subject split.

Check it yourself

A 12-row stand-in shows the whole effect (our own made-up rows: four patients, three slices each). On the train-test split:

  1. In Your data, paste this table (first line is the header): patient, slice, label then P1, s1, demented; P1, s2, demented; P1, s3, demented; P2, s1, demented; P2, s2, demented; P2, s3, demented; P3, s1, healthy; P3, s2, healthy; P3, s3, healthy; P4, s1, healthy; P4, s2, healthy; P4, s3, healthy.
  2. Set Method to k-fold: a fold number for every row, Folds made to Shuffled, Number of folds k to 4 and leave Seed at 42. P1’s three slices come out in folds 1, 3 and 1: the same patient is in two folds, which is the leak.
  3. Change Folds made to Grouped and set Group column to patient. Now each patient owns one fold: P4 in fold 1, P3 in fold 2, P2 in fold 3, P1 in fold 4.
  4. Switch Method to Grouped (whole groups stay together) with Test (%) 25 and Validation (%) 0. One whole patient goes to the test set: with seed 42 it is P1, so the test set is 3 rows and the training set 9.
  5. Look at Class balance: the test set holds 3 demented and 0 healthy rows. That is the cost of a grouped split on a small dataset, and the reason to check the balance table rather than trusting the percentage you typed.
  6. Set Class column to label and try a few seeds: the test set’s class mix jumps between all-demented and all-healthy, because there are only four patients to deal out.

What researchers can use it for

  • Audit a published accuracy before believing it: if the paper says “images were split 80/20” and each subject has many images, the number is about identity, not disease.
  • Make the split you meant to make, with whole patients, farms, schools or sessions on one side, and download the parts as CSV.
  • Report the spread, not one seed. Run several grouped splits and quote the range of the class mix and of the score.
  • Spot a class too small to validate: with two subjects in a class, most folds have none, so per-class metrics are meaningless.
  • Pair the honest split with honest metrics in the confusion matrix, where sensitivity on the minority class usually tells the real story, and plan the next cohort’s size with sample size.

The fine print

  • No MRI data was downloaded. Our cohort has the paper’s shape only, with equal slices per subject and an even spread of labels, both our assumption; the real dataset’s per-subject counts vary, which changes the fold sizes a little but not the leakage.
  • Our memoriser is a thought experiment made real, not a replication of the paper’s network. It shows the ceiling that leakage creates and the floor that imbalance creates; the paper’s model sits at the floor plus 2.7 points.
  • The paper reports two slightly different subject-level accuracies (0.808 and 0.805) in different tables, and 0.824 after aggregating slices to subjects. We used 0.808, the figure in its abstract.
  • Leakage has other routes besides subject identity: repeated scans of one person, data augmentation applied before the split, and feature scaling fitted on the whole table. Splitting by group fixes only the first.
  • Accuracy on a 78:22 problem is a weak measure whatever the split. Read the sensitivity and the AUC.

Sources

  • Yildiz O. and Subasi A. (2026), AttentionMS-Net: An Attention-Enhanced Multi-Scale Framework for Alzheimer's Disease Classification with Subject-Level Validation, Applied Sciences 16(9): 4338, doi:10.3390/app16094338. Licence CC BY, checked on the MDPI article page (the footer states the Creative Commons Attribution licence) and in the Crossref record (CC BY 4.0, 'vor', 2026-04-29), 2026-11-24; no correction or retraction notice. Values used here: the OASIS cross-sectional MRI collection as repackaged on Kaggle, 347 subjects and 86,437 two-dimensional axial slices, about 250 slices per subject; 78 % non-demented against 22 % demented at image level, a 3.5:1 imbalance; two subjects with moderate dementia (488 images); stratified 10-fold cross-validation at subject level with about 35 subjects and 8,000 to 10,000 images per test fold, and a 10-fold comparison at image level; image-level accuracy 0.9999 (AUC 1.0000, sensitivity 1.0000), subject-level accuracy 0.808 (AUC 0.873, sensitivity 0.620) and 0.824 after aggregating slices to subjects (AUC 0.889).
  • Split rules: scikit-learn 1.9's train_test_split, StratifiedShuffleSplit, GroupShuffleSplit, KFold, StratifiedKFold and GroupKFold, whose row counts the fibub tool reproduces (checked in our tests).

If you are an author or publisher and want a credit or a passage changed or removed, tell us and we will act quickly.

Tools in this article

Read next