Michal Kaszubski

When the most accurate model did not know when it was wrong

MSc research at UCL on automated detection of geometric distortion in prostate diffusion-weighted MRI, and on whether a model can tell when its own judgement is unreliable.

Years
2025 to 2026
Category
Research
Role
MSc researcher, UCL (thesis author)
Status
Retrospectively validated proof of concept; retrospective triage simulation only. Thesis, October 2025 to August 2026
Evidence
Research evidence
Technologies
PyTorch, DenseNet-121, Deep ensembles, Selective prediction, Calibration, Grad-CAM, pytest
Figure 2The dissociation. DenseNet-121 was the most accurate architecture, yet its deep ensemble ranks its own errors at an uncertainty-error AUROC of 0.52, barely above chance. The shallower ResNet-18 reaches 0.64. Means and spread across five patient-level folds. Thesis figure, 2026.

Figure 2, above, is the result this page is about: the architecture that classified best was the worst at knowing when it was wrong. The scans are patient data and cannot be shown, so this page shows aggregate results and model outputs only.

The problem

Diffusion-weighted MRI of the prostate is sensitive to geometric distortion, and an acquisition that looks plausible can still be unreliable for reading. My MSc thesis at UCL, October 2025 to August 2026, asked two questions. Can a model detect distorted acquisitions? And can it tell when its own judgement should not be trusted, so that the uncertain cases go to a person instead? The second question turned out to be the interesting one.

What I did

  • Built the experimental pipeline in PyTorch on 1,027 acquisitions from 627 patients (single centre, University College London Hospital, anonymised), under strict patient-level five-fold cross-validation.
  • Benchmarked four backbones against classical radiomic baselines, over 700+ training runs, then trained a three-seed DenseNet-121 ensemble and measured how far its members agree.
  • Built a heterogeneous nine-model ensemble, a retrospective triage simulation that defers the least-certain cases, and a distilled single model at about one-ninth of the ensemble’s inference cost.
  • Reported with bootstrap confidence intervals and paired Wilcoxon tests; checked behaviour with Grad-CAM, calibration analysis and synthetic-distortion validation.
Figure 1The system. Four backbones share one input format and one classification head, so the backbone is the only thing that changes between experiments.

The finding, and a plausible explanation

The three-seed DenseNet-121 ensemble was the most accurate model: mean AUROC 0.819, up to 0.17 above the classical radiomic baselines. Its uncertainty was close to useless. Uncertainty-error AUROC asks whether the cases a model is unsure about are the cases it gets wrong; 0.50 is chance. DenseNet-121 scored 0.52. ResNet-18, shallower and slightly less accurate, scored 0.64 (Figure 2).

A deep ensemble turns disagreement between its members into uncertainty, so I measured how much the members agree. DenseNet-121 models trained from different seeds make strongly correlated predictions: a mean pairwise correlation of 0.74, against 0.68 for ResNet-18 and 0.64 for ResNet-50. That ordering matches the ordering of the uncertainty results. It is consistent with the explanation that members which agree with one another, including when they are wrong, leave the ensemble little disagreement to report. It is an association across three architectures, not a demonstration of cause, and the thesis presents it as evidence for a plausible explanation and no more.

Figure 3Evidence for a plausible explanation. The architecture whose seed variants agree most (DenseNet-121, r = 0.74, against 0.68 and 0.64 for the two ResNets) is the one whose uncertainty ranks errors worst. The association is consistent with ensemble homogeneity as the reason; it does not prove it.

Decisions that mattered

Three choices shaped every number here. The folds are drawn at patient level, because several acquisitions share a patient and splitting by acquisition would have leaked patient-specific appearance across folds. The ensemble was made heterogeneous, three architectures with three seeds each, because same-architecture members agreed too much; that lifted uncertainty-error AUROC from 0.522 to 0.685 and made deferral worth simulating (Figure 4). And the nine models were distilled into one student, because nine forward passes on every scan is not a deployable cost.

Figure 4The fix. Mixing architectures lifts uncertainty-error AUROC from 0.522 to 0.685. Classification AUROC moves from 0.819 to 0.802, a gap well inside the spread across folds.

Evidence that it worked

All figures are from the thesis (October 2025 to August 2026) and are retrospective.

0.819
mean AUROC, distortion detectionThree-seed DenseNet-121 ensemble; SD 0.049 across the five patient-level folds; up to 0.17 AUROC above classical radiomic baselines.
0.685
uncertainty-error AUROCHeterogeneous nine-model ensemble, against 0.522 for the three-seed DenseNet-121 ensemble.
83.6%
retained-case accuracy at 70% coverageRetrospective triage simulation, deferring the least-certain cases.
One-ninth
of the ensemble’s inference costThe distilled single student model, approximately: one forward pass in place of nine.
700+
training runsIn the public PyTorch pipeline, across backbones, baselines, seeds and folds.

Deferral, and a check against physics

An uncertainty signal earns its keep when it decides which cases a model should not answer. Selective prediction ranks the cases by uncertainty, defers the least certain, and measures accuracy on the rest: a tunable deferral rule, shown retrospectively, never run on live cases.

Figure 5Selective prediction, for ResNet-18 with three uncertainty methods. Accuracy on the retained cases climbs as the system defers the scans it is least sure of. The bands, the spread across folds, are wide: the direction is consistent, the exact height is not.

A classifier trained at one centre can learn a shortcut that has nothing to do with the artefact. To test that, I injected synthetic geometric distortion of increasing magnitude into undistorted test acquisitions.

Figure 6Physics validation. The predicted probability of distortion rises monotonically with the injected magnitude for all three architectures, as a model responding to the artefact should. The rise is modest, so this is a sanity check on direction and no more.

Limitations and status

This is a retrospectively validated proof of concept: a single centre, a triage simulation on held-out retrospective data, and nothing deployed or validated in a clinic. The fold-to-fold spread is large, as it will be with 627 patients, and the seed-correlation result is an association, not a cause. The results are evidence that the approach is worth carrying forward; they are not a clinical claim.

What I learned

Accuracy and self-knowledge are different properties, and optimising the first can quietly damage the second.

An ensemble’s disagreement is only useful as an uncertainty signal if its members disagree in informative ways. I also learned to write a result down in its plainest form: spread across folds, splits at patient level, a simulation called a simulation, an association called an association.

The repository

The code is public under the MIT licence: miqa-prostate-dwi on GitHub (opens in a new tab), with the training and evaluation pipeline, the ensemble and distillation experiments, and a CPU-only test suite on synthetic data. The figures here are aggregate plots from the thesis; the dataset cannot be shared.