The medical AI lab ·
Interactive Medical AI Lab
The fourteen demos below show, on synthetic data, how a medical AI model can pass its headline metric and still be wrong in the way that matters: beats, patients, thresholds, scanners, lesions, identifiers, slice thickness, sample size, subgroups, prevalence, shortcuts, drift and alert load. They are for clinicians who are asked to trust a model, for hospital and health-fund data teams who validate one, and for quality and regulatory people who have to sign it off. Each demo opens on a default reading you can quote:
- Heart rate from ECG: under heavy movement the rate error is +0.7 bpm while 3 beats are false and 4 are missed.
- Patient leakage: reported test AUC 0.98 split by record, 0.76 split by patient, 0.72 on new patients.
- Calibration & thresholds: two models with AUC 0.845 flag 301 and 918 of every 1,000 patients at the same 10% threshold.
- Scanner shift: Dice 0.86 on the tuning scanner, 0.01 on a scanner with 0.70× contrast and identical anatomy.
- Dice vs clinical error: Dice 0.98 with 1 of 2 lesions found; the missed 8 mm lesion is 1.4% of the lesion area.
- Note de-identification: default rules catch 6 of 13 identifiers in the fictional note, none of the address, towns, occupation or unique event.
- Nodule volume in 3D: an unchanged 8 mm nodule measures 189 mm³ against a true 254 mm³ on 5 mm slices, and two scans of it can differ by 58%.
- Sample size: 90% sensitivity measured on 20 positive cases has a 95% interval of 70% to 97%.
- Hidden subgroup failure: overall AUC 0.87 and 90% sensitivity, but AUC 0.66 and 59% sensitivity in a subgroup that is 15% of patients.
- Slice-by-slice segmentation in 3D: Dice 0.98 on the slices the model segments, yet one lesion is reported as 3 and its longest diameter as 20 mm instead of 30 mm.
- Predictive value in 3D: a test that is 90% sensitive and 90% specific has a positive predictive value of 8.3% at 1% prevalence.
- Shortcut learning: AUC 0.94 at the training hospitals and 0.64 at a new one, with 70% of the model’s weight on a hospital tag.
- Drift over time: the alarm fires 6 months after drift begins, when the true AUC has fallen from 0.85 to 0.79.
- Alert burden: a model with AUC 0.90 at 90% sensitivity sends a nurse 22 alerts per shift, about 1 in 199 of them real.
These demos are illustrative. Every signal, image, patient and note is synthetic and fictional, generated and scored in your browser, and every number shown is computed from that synthetic data. They show general principles, not the performance of any real model, product or project, and none of them is a medical device.
Nothing is uploaded. No patient data is used.
About the lab
What the lab is for
The Medical AI lab is a set of fourteen small experiments on the questions that decide whether a clinical model can be trusted. Was it tested on patients it had never seen? Do its predicted risks mean what they say? Does it hold up on another scanner? Does the headline metric reflect the clinical error? Is the text it uses really de-identified? Is a nodule growing, or was it measured on thicker slices? Is the test set large enough to support the claim? Does the overall score hold in every subgroup? What does a positive result mean when the condition is rare? Did the model learn the disease or the hospital? Will anyone notice when it degrades, and how many alerts will it send? Each demo isolates one of these problems, lets you change one or two settings and shows the numbers a validation report would contain.
It is written for people who build, buy or review medical AI: data scientists and machine-learning engineers in digital health and medical devices, clinical researchers who work with prediction models, and product, quality and regulatory staff who need to read a validation report and ask the right questions. It assumes no statistics beyond knowing what a test set is.
Every signal, image, patient and note is synthetic and generated in your browser. The demos are educational: they illustrate general principles, they are not medical advice and they say nothing about the performance of any real model. Each demo also has its own page with a worked example, a checklist for your own project and answers to common questions.
For the methods behind the demos, see clinical model validation, medical imaging AI, clinical data de-identification and the wiki page on medical AI validation.
Biosignals / clinical model validation
Right on average. Wrong beat by beat.
What this shows: as motion artifact grows, a beat detector misses real beats and adds false ones, and the two errors can cancel so the average heart rate still looks right.
Open as a page: Heart rate from a noisy ECG →Add motion artifact
You can also drag across the trace, or focus it and use the arrow keys.
The check passes when the estimated rate is within ±5 bpm of the true rate and at most one beat is false or missed. Watch for “fail: beats” with a small rate error.
Synthetic ECG and detected beats
sliding window · 250 HzHeart rate in the visible window
- true HR · bpm
- 72.0
- estimated HR · bpm
- 72.0
- error
- ±0.0 bpm
- detected / actual
- 9 / 9
- false · missed
- 0 · 0
- validation check
- pass
Amber: ECG with motion artifactBlue: detected beats, detector energyWhite: true beats, threshold
Synthetic data · illustrative · not a medical device
Wearables, patient monitors and any algorithm that reports a rate or count from a biosignal. A validation that compares only averages can pass a detector whose individual beats are wrong.
What this experiment models
A synthetic ECG built from Gaussian P, QRS and T waves at a known, slowly drifting heart rate, plus motion artifact made of baseline wander, muscle noise and movement bursts. The detector is a classical QRS detector: zero-phase 5–15 Hz band-pass, derivative, squaring, a 150 ms moving window, an adaptive threshold and a 250 ms refractory period. Detected beats are matched to true beats within 100 ms. It is the same code as the live demo on the Medical AI page.
Clinical model validation / data splits
Same model. Two test scores.
What this shows: split by record, a patient’s other visits sit in the training set, and the model scores well by recognising patients. Split by patient, the test score matches what it does on new patients.
Open as a page: Patient-level data leakage →Split the data
300 synthetic patients, 30% with the outcome; 25% of records, or of patients, go to the test set. The model is a 7-nearest-neighbour classifier on 8 features. Try one visit per patient: the two splits then agree.
Who is in the test set
first 12 of 300 patientsGrey: training recordBlue: test record
Bars start at AUC 0.5, chance level. New patients: 240 synthetic patients the model never saw.
Synthetic data · illustrative · not a medical device
Any clinical dataset with repeated visits, admissions, images or samples per patient. The split has to follow the unit the model will meet in practice: new patients, and often new sites or later time periods.
What this experiment models
Each synthetic patient has a stable set of 8 features, a fingerprint, and a single outcome that shifts 3 of those features slightly. Each visit adds small visit-to-visit noise to the fingerprint, so a patient’s visits are much more alike than two different patients. A distance-weighted 7-nearest-neighbour classifier is scored with the area under the ROC curve (AUC). The data is fixed by a seed, so the same settings always give the same numbers.
Clinical model validation / calibration
Same ranking. Different usefulness.
What this shows: a model that ranks patients just as well (same AUC) can still give wrong risks, flag the wrong number of people and deliver less net benefit, especially at a hospital where the disease is more or less common.
Open as a page: Calibration and decision thresholds →Set the decision
The model was developed where 10% of patients had the outcome. Move the prevalence to deploy it somewhere else.
Calibration and decision curve
4,000 synthetic patientsBlue: modelAmber: treat everyoneGrey: treat no oneWhite dashed: perfect calibration, threshold
Synthetic data · illustrative · not a medical device
Risk scores that trigger an action: a test, a referral, a treatment. Discrimination alone does not show whether the threshold makes sense, and a model moved to a new population usually needs its calibration checked again.
What this experiment models
4,000 synthetic patients with a risk score. True risk is the logistic function of the score plus an intercept set by the prevalence slider. The model is the same logistic function with the intercept that fits 10% prevalence; the miscalibrated variant multiplies its log-odds by 0.6 and adds 1, so most patients get too high a risk and the highest-risk patients too low a one. Outcomes are expected values, not random draws, so the numbers do not jitter. Net benefit follows decision-curve analysis: true positives minus false positives weighted by the threshold odds, t / (1 − t), per patient.
Medical imaging AI / domain shift
Tuned on one scanner. Tested on another.
What this shows: a segmentation rule tuned on scanner A fails on scanner B when contrast or noise changes, although the anatomy is identical. Normalising intensities first removes most of the contrast effect, not the noise.
Open as a page: Scanner shift in medical imaging →Change scanner B
The model smooths the image and keeps pixels inside an intensity window. The window was chosen to give the best Dice on scanner A.
Same anatomy, two scanners
128 × 128 synthetic sliceBlue: correct lesion pixelsRed: false lesionAmber: missed lesion
Blue: lesion pixels on BAmber: other tissue on BWhite dashed: window learned on A
Synthetic data · illustrative · not a medical device
Imaging models moved between scanners, protocols, vendors or sites. Learned models are far more flexible than this rule, but they can still depend on intensity and noise characteristics of the scanners they were trained on, which is why external, multi-site testing matters.
What this experiment models
A procedural slice: a body outline, two organs, a bright bony structure and an irregular lesion with a brighter core. Scanner A adds fixed Gaussian noise. Scanner B scales contrast around the image mean and adds its own noise. The “model” is a 3 × 3 mean filter followed by an intensity window, grid-searched for the best Dice on scanner A and then frozen. Normalisation, when on, z-scores each image before the window is applied, and the window is re-tuned on normalised scanner A.
Medical imaging AI / evaluation metrics
A high Dice. A missed lesion.
What this shows: Dice is dominated by the largest structure, so missing a small lesion barely moves it. A boundary distance and a simple count of lesions found tell a different story.
Open as a page: Dice score vs clinical error →Change the prediction
Two true lesions: one about 68 mm across and one small. Shrink the small lesion below about 5 mm and even the 95th-percentile distance stops noticing that it was missed.
Ground truth and prediction
160 × 160 mm · 1 mm pixelsBlue: predicted and trueAmber: missedRed: predicted, not true
Synthetic data · illustrative · not a medical device
Segmentation and detection where small findings change the clinical decision: metastases, small nodules, early lesions. Report per-lesion detection and a boundary metric next to Dice, and choose metrics for the clinical question.
What this experiment models
Binary masks on a 160 × 160 grid with 1 mm pixels. The large true lesion is a slightly irregular disc; the prediction follows its boundary with a fixed wobble scaled by the roughness slider. Dice is 2|A∩B| / (|A| + |B|) over all pixels. Boundary distances are measured between the boundary pixels of the two masks in both directions; HD95 is the larger of the two directed 95th percentiles, and the maximum is the Hausdorff distance. A lesion counts as detected if any predicted pixel overlaps it.
Clinical data de-identification / free text
Names are easy. The rest re-identifies.
What this shows: simple rules catch titled names and ID numbers early; dates, places and rare details such as an unusual job or a unique event need more, and turning the rules up also removes doses, drug names and ordinary words.
Open as a page: De-identifying a clinical note →Run the detector
Rules switched on
Fictional discharge note
13 annotated identifiersGreen: identifier caughtRed: identifier missedAmber: over-redacted
Synthetic data · fictional note · illustrative · not a medical device
Free-text notes, letters and reports before they reach analysts, vendors or language models. Measure missed identifiers and over-redaction on your own notes and languages; de-identification lowers disclosure risk but is not a guarantee of anonymity.
What this experiment models
One fictional note in three versions, with a ground-truth annotation of 13 identifiers: names, dates, an ID number and a phone number (all zeros), an address and towns, and two rare details. The detector is a list of regular expressions and word lists, switched on in five levels. An identifier counts as caught when at least half of its characters are redacted; a redaction that touches no identifier counts as over-redaction. Real systems combine rules with trained models and human review.
Medical imaging AI / 3D measurement
Same nodule. Different volume.
What this shows: the volume a CT segmentation reports depends on the slice thickness and on where the slices happen to fall. On thick slices, two scans of a nodule that has not changed can differ by more than the change used to call growth.
Open as a page: Nodule volume and slice thickness →Change the scan
Slice position shifts the slices along the scan axis by a share of one slice, as happens when the patient lies a little differently. The nodule itself never changes. In-plane pixels are 0.7 mm, and a voxel is kept when at least half of it is nodule.
The nodule and the slices the scan keeps
3D · drag to rotateBlue: slices kept by the segmentationWhite dashed: true surface
Drag to rotate, or focus the view and use the arrow keys.
Synthetic data · illustrative · not a medical device
Follow-up of lung nodules, lesions and any structure whose growth is judged from its volume. Baseline and follow-up need the same slice thickness and reconstruction, and a growth call should be compared with the measurement variability expected at that size. The 25% figure is the volume change the British Thoracic Society guideline on pulmonary nodules (2015) uses to define significant growth.
What this experiment models
One slightly lobulated synthetic nodule, the same shape at every diameter, sampled on a fine grid. A scan divides space into voxels of 0.7 × 0.7 mm in the slice plane and the chosen thickness along the scan axis. Each voxel holds the share of its volume that is nodule, which is the partial-volume effect, and the segmentation keeps voxels that are at least half nodule. Measured volume is the number of kept voxels times the voxel volume. The largest gap between two scans is the highest measured volume over the lowest across twenty slice positions. Real scanners add reconstruction kernels, noise and motion, and real segmentations differ; the demo isolates slice thickness and position only. The 3D view is drawn on a plain canvas and needs no plug-in.
Clinical model validation / sample size
A good number. A small study.
What this shows: a sensitivity measured on a handful of positive cases has a wide confidence interval. The number of positive cases, not the number of patients, decides how far the result can be trusted.
Open as a page: Sample size for validating a clinical model →Size the study
Sensitivity is measured only on the patients who have the condition. At 10% prevalence, 200 patients contain 20 of them.
How sure is the measured value?
95% Wilson intervalBlue: sensitivity, measured on the positives (red when it reaches below your minimum)Grey: the same value measured on the negativesWhite: 60 repeats of the studyAmber dashed: the minimum you require
Synthetic data · illustrative · not a medical device
Any validation study, external test or post-market check that reports sensitivity, specificity or another proportion. Plan the number of positive cases before collecting data, report every estimate with its interval, and state the minimum acceptable value in advance.
What this experiment models
The validation set has the chosen number of patients; the number with the condition is that number times the prevalence, rounded. The measured sensitivity is the expected value rounded to a whole number of detected cases. The interval is the 95% Wilson score interval for a proportion. The grey bar shows the same measured value on the patients without the condition, as a specificity would be, to show how much narrower the interval is on the larger group. The white dots are 60 simulated repeats of the same study with a model whose true sensitivity is the value entered, drawn with a fixed seed. Patients for ±5 points is the number of positive cases at which the interval half-width falls to 5 percentage points, divided by the prevalence.
Clinical model validation / subgroups
Good overall. Weak for some.
What this shows: a model can score well on the whole test set and still fail one group of patients, because a small group barely moves the overall figure. Only a per-subgroup report shows it.
Open as a page: Hidden subgroup failure →Change the subgroup
The subgroup can be an age band, a site, a device or any group the training data covered poorly. Signal is how well the model separates cases from non-cases there, relative to the main group. One threshold is used for everyone, set to reach the target sensitivity on the whole test set.
One model, three views
6,000 synthetic patientsWhite dashed: whole test setBlue: main groupAmber: subgroup
Synthetic data · illustrative · not a medical device
Models used across age bands, sexes, sites, devices, disease stages or care settings. Decide the subgroups before looking at the results, report discrimination and error rates for each with its interval, and check that each subgroup holds enough cases to say anything.
What this experiment models
6,000 synthetic patients, 20% with the outcome, each assigned to the main group or the subgroup. The model’s score is a standard normal value, shifted up by two standard deviations for cases in the main group and by the chosen share of that for cases in the subgroup. Prevalence is the same in both groups. The threshold is the highest cut-off that still reaches the target sensitivity on the whole test set, and it is applied to everyone. AUC, sensitivity and specificity are then computed for the whole set and for each group, with a 95% Wilson interval for the subgroup sensitivity. The data is fixed by a seed, so the same settings always give the same numbers.
Medical imaging AI / 3D segmentation
Each slice fine. The lesion in pieces.
What this shows: a model that segments a 3D lesion one slice at a time can score well on every slice it segments and still miss the lesion in a few slices. The lesion then comes out as several separate pieces, with the wrong count, length and volume.
Open as a page: Slice-by-slice segmentation of a 3D lesion →Change the prediction
The lesion is cut into 2 mm slices. The model looks at one slice at a time, so nothing ties its answer in one slice to the next. Missed slices are ones where it finds no lesion at all.
The lesion, slice by slice
3D · drag to rotateBlue: slices where the model found the lesionAmber: slices it missed
Drag to rotate, or focus the view and use the arrow keys.
Synthetic data · illustrative · not a medical device
CT and MRI segmentation used for lesion counts, longest-diameter measurements or volumes. Evaluate in 3D: report volume-level overlap, the number of connected lesions against the reference, and the measurements derived from the mask, not only a per-slice score.
What this experiment models
One elongated synthetic lesion, defined by its outline in each 2 mm slice. The prediction in each slice is the true outline scaled by a fixed slice-specific factor within the chosen inconsistency, or nothing at all in the missed slices, which are fixed interior positions. Dice on slices it segments is the mean Dice over the slices where the model found the lesion. Dice on the whole volume is computed over all voxels. Lesions reported is the number of runs of consecutive slices with a prediction. Longest diameter is the largest extent of the largest piece, along the scan axis or within a slice, against the true lesion length.
Clinical model validation / predictive value
Accurate test. Mostly false positives.
What this shows: what a positive result means depends on how common the condition is. A test with high sensitivity and specificity still produces mostly false positives when the condition is rare.
Open as a page: Predictive value and prevalence →Set the test and the population
Prevalence is the share of the tested population that has the condition. It is low in screening and higher in a referred or symptomatic group, so the same model has a different predictive value in each.
Positive predictive value
3D · drag to rotateBlue surface: positive predictive value, brighter is higherAmber: the test and population you set
Prevalence runs from 0.1% to 50% on a log scale, specificity from 50% to 99%. Drag to rotate.
Synthetic data · illustrative · not a medical device
Screening, triage and any model moved from an enriched study to routine use. Report predictive values at the prevalence of the intended population, and say how many people are flagged for each real case.
What this experiment models
Positive predictive value is the share of positive results that are true: prevalence × sensitivity divided by all positives, which also include (1 − prevalence) × (1 − specificity) false positives. Negative predictive value is the share of negative results that are true. The surface shows positive predictive value at the chosen sensitivity for every combination of prevalence, on a log scale from 0.1% to 50%, and specificity from 50% to 99%. Nothing is simulated: the numbers follow from the three settings by Bayes’ rule.
Medical imaging AI / shortcut learning
It learned the hospital, not the disease.
What this shows: when something unrelated to the disease, such as a hospital tag in the corner of the image, goes with the diagnosis in the training data, a model can learn the tag. It tests well where the tag still goes with the disease and fails where it does not.
Open as a page: Shortcut learning in medical imaging →Change the training data
At 50% the tag says nothing about the diagnosis. At 90%, nine in ten diseased images carry it and nine in ten healthy images do not, as when most sick patients are imaged on one portable machine. At the new hospital the tag is unrelated to disease.
What the model relies on
3,000 synthetic images per setRed glow: share of the model’s weightBlue: same hospitals as trainingAmber: new hospitalWhite: a model trained without the tag
Synthetic data · illustrative · not a medical device
Imaging and signal models trained on data where acquisition differs by diagnosis: portable versus fixed machines, different sites for sicker patients, burned-in text, markers, tubes or rulers. Test on sites where those links are broken, and check what the model responds to.
What this experiment models
Each synthetic image is reduced to two inputs: a disease signal, a number that is higher on average in diseased cases by the chosen strength, and a tag that is present or absent. Half the images are diseased. In the training set and the same-hospital test set the tag is present in the chosen share of diseased images and absent in the same share of healthy ones; in the new-hospital test set it is present in half of each. The model is a logistic regression on the two inputs. Weight on the tag is the tag’s share of the two standardised weights. The schematic scan is an illustration of that share and is not itself classified.
Clinical model validation / monitoring
It worked at launch. Then it slipped.
What this shows: a deployed model can lose performance slowly as patients, practice or equipment change. A monitoring rule based on a few labelled cases a month either notices late or fires by chance.
Open as a page: Model drift and monitoring →Set the monitoring
The model’s true AUC is 0.85 for the first 6 months and then falls by the amount you set each month. One in five labelled cases is positive. The alarm fires when the measured AUC is below the alarm line two months in a row.
AUC, month by month
24 months after deploymentWhite dashed: true AUCBlue: AUC measured that monthAmber dashed: alarm lineRed: alarm fires
Synthetic data · illustrative · not a medical device
Any model in routine use. Decide before deployment which metric is tracked, how labels will be obtained, how many cases a month that gives, and what margin and rule trigger a review. Watch inputs and case mix as well, because they move before labelled outcomes arrive.
What this experiment models
The model’s score separates cases from non-cases by an amount that gives a true AUC of 0.85, reduced month by month once drift starts, with a floor of 0.5. Each month the chosen number of labelled cases is drawn with 20% positives and the AUC is measured on them. The alarm line is the baseline AUC minus the margin, and the alarm fires at the second of two consecutive months below it. The random draws are fixed by a seed, so the same settings always give the same chart; a different seed would move the alarm by a month or two.
Clinical model validation / workload
A good AUC. An alert every half hour.
What this shows: a threshold is also a workload. Counted per nurse per shift, a model with a strong AUC can raise an alert every few minutes, almost all of them false, because real events are rare and every patient is scored many times.
Open as a page: Alert burden of an early-warning model →Set the model and the ward
A shift is 12 hours. A real event, such as deterioration, happens in 2% of patient-shifts and is present at one of that patient’s scores.
One nurse, seven shifts
each mark is an alertAmber: false alertGreen: alert for a real event
Synthetic data · illustrative · not a medical device
Early-warning scores, sepsis and deterioration alerts, and any model whose output interrupts a clinician. Express the threshold as alerts per clinician per shift and real events per alert, and agree what load the ward can act on before choosing it.
What this experiment models
Scores are normally distributed for assessments with and without an event, separated by the amount that gives the chosen AUC. The threshold is the one that reaches the chosen sensitivity. Each patient is scored at regular intervals through a 12-hour shift; 2% of patient-shifts contain one real event, present at one of those scores. Alerts per shift is the number of scores times the share that exceed the threshold. The chart simulates every score for one nurse over seven shifts with a fixed seed. Repeated alerts on the same patient are counted separately, as they are when each one has to be acknowledged.
One demo per page
Open a demo on its own
Each experiment also has its own page, with a short explanation of the principle behind it.
- 01Heart rate from a noisy ECG
A beat detector on a synthetic ECG with motion artifact. The average heart rate can stay right while individual beats are missed or false.
- 02Patient-level data leakage
One model scored on a record-level and a patient-level split of the same visits, and compared with its AUC on patients it has never seen.
- 03Calibration and decision thresholds
A calibration plot and a decision curve for a risk model, with missed cases and false alarms per 1,000 patients at the threshold you set.
- 04Scanner shift in medical imaging
A segmentation rule tuned on one scanner and applied to another with different contrast and noise, with and without intensity normalisation.
- 05Dice score vs clinical error
One large and one small lesion. Dice, boundary distances and the number of lesions found when the small one is missed.
- 06De-identifying a clinical note
A rule-based detector on a fictional discharge note in English, Hebrew or both, scored for missed identifiers and over-redaction.
- 07Nodule volume and slice thickness
A 3D view of one synthetic nodule and the slices a CT segmentation keeps. The measured volume changes with slice thickness and slice position while the nodule stays the same.
- 08Sample size for validating a clinical model
The 95% interval around a measured sensitivity, for the number of patients and the prevalence you choose, and the number of patients needed for a ±5 point margin.
- 09Hidden subgroup failure
One model and one threshold, scored on the whole test set, the main group and a subgroup. A good overall AUC next to a weak subgroup.
- 10Slice-by-slice segmentation of a 3D lesion
A 3D view of one lesion segmented a slice at a time. A high per-slice Dice next to a lesion reported in pieces.
- 11Predictive value and prevalence
A 3D surface of positive predictive value over prevalence and specificity, with the positives per 1,000 people tested.
- 12Shortcut learning in medical imaging
A model trained where a hospital tag goes with the diagnosis, tested at the same hospitals and at a new one.
- 13Model drift and monitoring
True and measured AUC over 24 months, and the month a simple monitoring rule raises the alarm.
- 14Alert burden of an early-warning model
A threshold counted in alerts per nurse per shift, time between alerts and real events per alert.
Clinical model validation →Medical imaging AI →Clinical data de-identification →