Research question

An earlier project found Hadamard fusion beating attention-based fusion on HAM10000. But that result came from a single loss function, a single augmentation scheme, and a single train/test split held fixed throughout — so it was impossible to tell whether Hadamard's advantage was a genuine property of the fusion mechanism, or just an artifact of that particular pipeline. This project set out to answer that, by rebuilding the pipeline and varying one factor at a time across six experimental groups, instead of changing everything at once.

What I built

A configurable Swin-Tiny pipeline with lesion-grouped splitting (no lesion appears in more than one of train/validation/test), five loss functions, four independently toggleable preprocessing/augmentation components, 5-fold cross-validation, 8-transform test-time augmentation, three fusion strategies, and an external evaluation protocol against ISIC 2019 — a second dataset the model never trains on.

Diagram of the six experimental groups: Ablation 1 compares five loss functions on raw images; Ablations 2 and 3 individually ablate preprocessing and augmentation components under the top two losses from Ablation 1; Ablation 4 uses 5-fold cross-validation to isolate test-time augmentation; Ablation 5 repeats cross-validation with MixUp and ISIC2019 external validation; Ablation 6 compares three fusion strategies on the final configuration.
The six experimental groups. Each holds every factor fixed except the one under study, with later groups building on the winning configuration from earlier ones.

Each experimental group holds everything fixed except the one factor under study, with later groups building on whichever configuration won in the earlier ones.

Findings, by experiment

1. Loss function

Five losses were compared under identical conditions on raw images. Logit-Adjusted Cross-Entropy (LA-CE) got the highest balanced accuracy (74.94%), but also the worst calibration of the five. Confusion-Frequency Reweighted CE — a reweighting scheme designed for this project — won on macro-F1 and calibration (ECE 0.0392) instead. The two never agreed: accuracy and calibration pulled in opposite directions at the loss level.

2–3. Component ablation under both losses

MixUp, DullRazor hair removal, CutMix, and segmentation-guided cropping were each added individually under both losses. The same component behaved differently depending on the loss underneath it: MixUp nearly preserved balanced accuracy under LA-CE while cutting calibration error by 57%, but reduced balanced accuracy by 3.8 points under CFR-CE. Segmentation-guided cropping had the worst calibration under LA-CE and the best under CFR-CE. No preprocessing choice was universally good — its effect depended entirely on the loss it was paired with.

4. Cross-validation and isolated TTA

Across 5 lesion-grouped folds, balanced accuracy ranged from 72.5% to 76.7% (mean 74.6%) — and the original single-split result sat slightly above that mean, meaning the first reported number was somewhat favorable rather than representative.

Scatter plot of test balanced accuracy across 5 lesion-grouped cross-validation folds, ranging from 0.7248 to 0.7672, compared against the single train/validation/test split estimate of 0.7494, which sits above the 5-fold mean of 0.7458.
Test balanced accuracy across 5 cross-validation folds versus the original single-split estimate.

Test-time augmentation gave a small, consistent accuracy gain and a clearer calibration improvement across every fold.

5. External validation on ISIC 2019

This is the headline result: balanced accuracy fell from 74.7% internally to 47.8% on the external dataset — a 27-point drop — while calibration error nearly tripled.

Bar chart showing balanced accuracy dropping from 0.7471 internally on HAM10000 to 0.4784 externally on ISIC2019, a 26.9 point fall.
Balanced accuracy: internal vs. external.
Bar chart showing Expected Calibration Error rising from internal to external evaluation, alongside the balanced accuracy drop.
Calibration error: internal vs. external.

Melanoma recall dropped sharply (more false negatives), while vascular lesion and dermatofibroma recall held up but came with very low precision (over-prediction instead). Strong internal numbers did not transfer.

6. Fusion strategy, revisited

Internally, the original finding reproduced exactly: Hadamard outperformed Attention, which outperformed Concatenation, on balanced accuracy and macro-F1 — now under a completely different backbone, loss, and augmentation scheme. Externally, the ranking flipped: Concatenation led on balanced accuracy, while Hadamard remained best on calibration. No single fusion strategy won on every axis.

Internal (HAM10000, 5-fold mean) vs. external (ISIC 2019) results, LA-CE with MixUp
EvaluationBalanced accuracyMacro-F1ECE
Internal (HAM10000, 5-fold mean)74.71%0.66180.0389
External (ISIC 2019)47.84%0.37930.1256
Why it matters

Loss function, not fusion strategy, is what first resolves catastrophic minority-class failure. LA-CE alone, with no metadata at all, already achieves non-trivial recall on the rarest classes. Fusion only refines a baseline that already works; it doesn't create minority-class performance where none existed. No single intervention — loss, preprocessing, TTA, or fusion — simultaneously optimized balanced accuracy, calibration, and generalization to a new dataset. Each one traded off against the others.

Limitations

Cross-validation and external validation were only run for LA-CE-based configurations, so it's unknown whether the other losses or components would be equally robust. ISIC 2019 evaluation used a harmonized 7-class subset, excluding two classes with no HAM10000 equivalent. Each fusion strategy was evaluated with a single trained checkpoint, not across folds or seeds, so the reversed external ranking hasn't been stress-tested for its own variance.