Read it, then run it
This page is the read-only chapter intro. To actually execute the cells (load the dataset, train a model, render GradCAM heatmaps on your own images), open the Colab notebook in a free T4 runtime. The curriculum is designed to be executed, not read.
Chapter 6: Evaluation & Clinical Metrics¶
Learning objectives: - Comprehensively evaluate a trained model beyond simple accuracy - Generate and interpret confusion matrices, ROC curves, and calibration plots - Compute bootstrap confidence intervals for AUC - Understand subgroup analysis and fairness in clinical AI
Clinical context: An overall accuracy of 95% sounds impressive - but what if the model gets 99% of the common classes right and only 60% of the rare but critical class? Clinical evaluation requires looking at performance from multiple angles, just as a thorough clinical workup goes beyond a single lab value.
Calibration: Can You Trust the Probabilities?¶
AUC tells you how well the model ranks predictions (separates positive from negative). But it doesn't tell you whether the probabilities are meaningful.
Calibration answers the question: "When the model says 80% chance of malignancy, is it actually right about 80% of the time?"
- Overconfident model: says 90% but is only right 60% of the time → dangerous for clinical decision-making
- Underconfident model: says 50% but is right 80% of the time → leads to unnecessary follow-up
- Well-calibrated model: predicted probability matches actual frequency → probabilities can be used for clinical thresholds
Why this matters clinically: If a screening tool says "95% probability of cancer" but the model is overconfident, the patient may undergo an unnecessary biopsy. If underconfident, a real cancer may be dismissed. Calibration is as important as accuracy for clinical deployment.
Augmentation-Induced Failures of the Foundation Model You'll Fine-Tune in Ch 8¶
The DINOv2-Small model published at t22000t/dinov2-small-mednist reaches 100% in-distribution validation AUC on the held-out split (val_indices.json, sha256-pinned) - the model gets every original val image correct.
That makes "natural" failure-mode visualization useless. So the gallery below shows augmentation-induced misclassifications: the model classifies each original val image correctly, then we apply one of eight test-time augmentations - each mapped to a clinical scenario radiologists would recognise (wrong patient orientation, motion blur, low SNR portable, mis-windowed DICOM, wrong field of view, …) - and harvest the cases where the model flips to a confident wrong prediction.
The lesson: in-distribution accuracy and robustness to mild distribution shift are two different properties. Calibration here (Ch 6) and explainability (Ch 7) are how you tell which regime you're in. When you reach Chapter 7 (GradCAM), revisit these images and ask why the attention heatmap lights up where it does on each broken input.
Confidence Intervals: How Certain Are We?¶
A single AUC number (e.g., 0.9923) looks precise, but it's just a point estimate from one specific test set. If we collected a different test set, the AUC might be slightly different.
Bootstrap confidence intervals quantify this uncertainty: 1. Repeatedly resample the test set with replacement (1000 times) 2. Compute AUC on each resampled set 3. Report the 2.5th and 97.5th percentiles as the 95% confidence interval
Clinical relevance: A model with AUC = 0.95 (95% CI: 0.94–0.96) is much more trustworthy than one with AUC = 0.95 (95% CI: 0.85–0.99). Journal reviewers and regulatory bodies expect confidence intervals, not just point estimates.
Subgroup Analysis and Fairness¶
A model that performs well overall might fail on specific patient subgroups. For example: - A chest X-ray model trained mostly on adult data may perform poorly on pediatric patients - A skin lesion classifier trained on light-skinned populations may miss melanomas on dark skin - A model trained on images from one scanner brand may degrade on images from a different scanner
Subgroup analysis evaluates model performance separately across: - Demographics (age, sex, race/ethnicity) - Clinical variables (disease severity, comorbidities) - Technical factors (scanner manufacturer, imaging protocol)
FDA guidance increasingly requires evidence that AI/ML devices perform consistently across relevant subgroups. The 2021 "Good Machine Learning Practice" guidelines emphasize evaluating for bias before clinical deployment.
In this tutorial, MedNIST doesn't include demographic metadata, so we can't perform subgroup analysis. But when building clinical AI with real patient data, this step is non-negotiable.
The Road to Clinical Deployment¶
The skills in this tutorial cover the research and development phase of clinical AI. For actual deployment, additional steps are required:
| Step | What's Needed | Tutorial Coverage |
|---|---|---|
| 1. Research | Model development, internal validation | ✅ Chapters 1–8 |
| 2. Clinical validation | External test set, prospective study | Partial (Ch 6 metrics) |
| 3. Regulatory clearance | FDA 510(k), De Novo, or PMA submission | ❌ Beyond this tutorial |
| 4. Deployment & monitoring | Integration, drift detection, auditing | ❌ Beyond this tutorial |
Key regulatory requirements: - Predefined performance endpoints (not post-hoc cherry-picking) - Locked test set (no peeking, no retraining on test data) - Prospective validation on new, unseen patients - Documentation of intended use, limitations, and failure modes