Palo Alto Health Labs
Resource · AI validation

How Big Should Your Medical AI Test Set Be? Sample Size, Patient-Level Splits and Subgroup Coverage

Sizing a test set from the confidence interval you need, computed tables for sensitivity and AUC, prediction-model validation, patient-level splits, and subgroup coverage, from fda.gov and peer-reviewed sources only.

Format
Guide
Read time
7 min
Sources
3 FDA, 6 peer-reviewed
Updated
Oct 27, 2026

Test-set size is a precision question

The question "how many cases do I need?" really means "how wide a confidence interval can I accept around the number I will report?" FDA's draft guidance for AI-enabled devices says "All performance estimates should be provided with confidence intervals," and FDA's statistical guidance for diagnostic tests lists "estimates of sensitivity and specificity pairs, likelihood ratio of positive and negative result pairs, and ROC … analysis along with confidence intervals" as appropriate measures. A small test set gives wide intervals. Riley and colleagues found that "Many existing validation studies are too small, which leads to wide confidence intervals of performance estimates and potentially misleading claims about a model's reliability."

Sources: FDA AI-enabled device software functions draft guidance, Jan 2025; FDA statistical guidance on diagnostic tests, 2007; Riley et al., BMJ 2024. This page is a summary, not regulatory or statistical advice for a specific submission.

How many cases for a target sensitivity?

Sensitivity is estimated only from cases that have the condition, so you size those first and then divide by prevalence to get the total number of cases to collect. Buderer (1996) set out this prevalence-based approach: sample size is "calculated based on a clinically acceptable degree of precision, the hypothesized values of sensitivity and specificity, and the estimated prevalence of disease."

The numbers below are our own calculation with the normal-approximation formula:

cases with condition = z² × Se × (1 − Se) / d²,   total cases = cases with condition / prevalence

where z = 1.96 for a 95% interval, Se is the sensitivity you expect, and d is the half-width you can accept. Results are rounded up.

Target sensitivity and 95% CI half-widthInterval you would expectCases with the conditionTotal cases at 5% prevalenceTotal at 10%Total at 20%
90% ± 5 points85%–95%1392,7801,390695
90% ± 7.5 points82.5%–97.5%621,240620310
90% ± 10 points80%–100%35700350175

Read the first row this way: if you expect 90% sensitivity and want the 95% interval to be about 85% to 95%, you need 139 positive cases. If only 5% of the cases you collect are positive, that means about 2,780 cases in total. Halving the half-width roughly quadruples the cases needed. Specificity works the same way using cases without the condition: divide by (1 − prevalence) instead.

Sources: Buderer 1996 (method, cited by reference); table values computed for this page. The normal approximation is rough when sensitivity is close to 100% or counts are small; in those cases a statistician will usually use an exact or Wilson interval (our note).

How many cases for a target AUC?

For a model that outputs a score, the area under the ROC curve (AUC) "represents the probability that a randomly chosen diseased subject is (correctly) rated or ranked with greater suspicion than a randomly chosen non-diseased subject." Hanley and McNeil give "closed-form expressions for the approximate magnitude of the sampling variability" of the AUC, and guidance on "the size of the sample required." The table applies their standard-error formula with equal numbers of cases with and without the condition.

SE(AUC) = √[ (A(1−A) + (n₁−1)(Q₁−A²) + (n₂−1)(Q₂−A²)) / (n₁n₂) ], with Q₁ = A/(2−A), Q₂ = 2A²/(1+A), half-width = 1.96 × SE

Cases with the conditionCases without95% CI half-width if AUC = 0.80If AUC = 0.90
5050±0.087±0.063
100100±0.061±0.044
200200±0.043±0.031
400400±0.031±0.022

Sources: Hanley & McNeil 1982; table values computed for this page.

Validating a clinical prediction model

For risk models, a single sensitivity or AUC target is not enough. Riley and colleagues note that "rules of thumb for sample size have been proposed, such as having at least 100 events and 100 non-events," but "Such rules of thumb provide a starting point but are problematic." Their approach sizes an external validation study for the precision of "R2, calibration curve, c statistic, and net benefit," and "The pmvalsampsize package in Stata and R allows researchers to implement the approach with one line of code." Separate methods papers cover binary and time-to-event outcomes.

Sources: Riley et al., BMJ 2024; Riley et al., Stat Med 2021; Riley et al., Stat Med 2022.

Patient-level splits and leakage

Good Machine Learning Practice calls for training data sets to be independent of test data sets. FDA's draft AI guidance adds that "it is also important for FDA reviewers to understand whether the test data are independent (e.g., sampled from completely different clinical sites) from the training data and are sequestered from the model developers and the model development stage."

In practice (our view), that means:

Sources: FDA/Health Canada/MHRA Good Machine Learning Practice, 2021 (paraphrased); FDA AI-enabled device software functions draft guidance, Jan 2025. The checklist is our practice recommendation.

Subgroup and site coverage

Good Machine Learning Practice also says clinical study participants and data sets should be representative of the intended patient population. FDA's draft AI guidance states: "Generally, subgroup analysis by patient characteristics (e.g., sex, age, race, ethnicity, disease severity), geographic sites, and data collection equipment are appropriate."

This drives size more than founders expect. If you want a usable interval for each subgroup, each subgroup needs enough positive cases on its own. Using the table above, a ±10-point interval around 90% sensitivity takes 35 positive cases per subgroup, so four age bands need about 140 positive cases before you account for prevalence (our arithmetic).

Sources: FDA/Health Canada/MHRA Good Machine Learning Practice, 2021 (paraphrased); FDA AI-enabled device software functions draft guidance, Jan 2025. FDA's January 2025 AI guidance is a draft and is not for implementation.

Reporting the result

Report the test-set size in patients and in positive cases, how it was chosen, the split method, and every performance estimate with its confidence interval, overall and by subgroup. For prediction models, the TRIPOD+AI reporting guideline lists what to include.

Sources: Collins et al., TRIPOD+AI, BMJ 2024; FDA AI-enabled device software functions draft guidance, Jan 2025.

Related resources

Frequently asked questions

How many labeled cases do I need to validate a medical AI model?

It depends on the metric you will report and how narrow its confidence interval must be. With the normal-approximation formula, estimating 90% sensitivity to within about plus or minus 5 points takes 139 cases with the condition; divide by prevalence to get the total number of cases.

Is 100 events and 100 non-events enough to validate a prediction model?

Riley and colleagues describe that rule of thumb as a starting point but problematic. They recommend sizing for the precision of calibration, the c statistic, R-squared and net benefit, for example with the pmvalsampsize package.

Can I split my test set by image or recording instead of by patient?

Training and test data should be independent. Splitting by image or recording can put the same patient on both sides, which leaks information and makes performance look better than it is. Split by patient, and by site where possible.

Scope it in 30 minutes

Book a scoping call and we'll name the smallest engagement that moves you forward. Most teams start with the fixed-scope Initial Audit.

Book a 30-min scoping call

Prefer to write? Send a short note.