{# REVIEW: the wording of this section was written by the builder, not by the author. #}
{# A schematic, not data: three hospitals, two slides each, every slide cut into nine patches. In hospital 0 both slides
belong to one patient. The cells drawn as test show which unit each way of holding data out keeps away from training. #}
{% macro split_diagram(level) %}
{% endmacro %}
{% set split_text = {
"patch": "Random patches are held out. Their neighbors from the same slide stay in training.",
"slide": "Whole slides are held out. A patient's other slide can still be in training.",
"patient": "All slides of a patient are held out together.",
"hospital": "A whole hospital is held out, so every test patch comes from a lab never seen in training."
} %}
Four ways to count one
Each slide is cut into thousands of small patches, and the network sees one patch at a time. Patches from one slide look alike, so a test patch whose neighbors were in training makes an easy test. The four ways below differ only in which unit is kept out of training.
{% for r in p2.lvtable %}
By {{ r.level }}
{{ split_diagram(r.level) }}
{{ split_text[r.level] }}
{{ r.auroc|num(3) }} pooled AUROC
{% endfor %}
training test two slides from one patient Schematic, not to scale: each small square is a patch, each block of nine a slide, each box a hospital.
The same network was trained for each of {{ p2.levels.levels|length|count }} ways of holding data out, {{ p2.n_folds|count }} times each, so that a different fifth of the data was the test set every time, and every patch was predicted exactly once. The figure shows the pooled AUROC with a {{ p2.ci_level|pct(0) }} interval that resamples slides, not patches.
Top: pooled AUROC for each level; the vertical bar is the interval, the short gray ticks to the left are the individual folds. Bottom: the hospital level, one point per held-out hospital, with intervals that resample that hospital's slides. Plain models, first seed.
The numbers behind the figure
Held out
Pooled AUROC
Interval (slides)
Accuracy
Mean of the fold AUROCs
Fold range
{% for r in p2.lvtable %}
{{ r.level }}
{{ r.auroc|num(4) }}
{{ r.ci|ci(4) }}
{{ r.acc|pct(1) }}
{{ r.fold_mean|num(4) }}
{{ r.fold_min|num(3) }} to {{ r.fold_max|num(3) }}
{% endfor %}
Patch level, resampling patches instead of slides, gives the narrower interval {{ p2.patch_row_ci|ci(4) }}. That interval treats neighboring patches as independent, which they are not, so the slide interval is the one to trust.
Caveats
With only {{ p2.hier.n_slides|count }} slides, the intervals for slide, patient and hospital overlap widely. The data show that the patch level is far above the rest. They do not show which of the other three is hardest.
The pooled number mixes the scores of {{ p2.n_folds|count }} different models. At the slide level it is {{ p2.slide_pooled|num(3) }}, below the mean of the fold values ({{ p2.slide_fold_mean|num(3) }}), because the models are not equally calibrated.
One training run is not one answer. Training the plain hospital-level model again with a different random seed moved the pooled AUROC from {{ p2.seedvar.plain.auroc_s0|num(3) }} to {{ p2.seedvar.plain.auroc_s1|num(3) }}. The stain-augmented model moved from {{ p2.seedvar.aug.auroc_s0|num(3) }} to {{ p2.seedvar.aug.auroc_s1|num(3) }}. The same run on two different graphics cards differed by {{ p2.hardware.patient_f0.difference|num(3) }} on a hard fold, and by {{ p2.hardware.patch_f2.difference|num(5) }} on an easy one.