Closing the AI generalization gap by adjusting for dermatology condition distribution differences across clinical settings

Rajeev V. Rikhye, Aaron Loh, Grace Eunhae Hong, Preeti Singh, Margaret Ann Smith, Vijaytha Muralidharan, Doris Wong, Rory Sayres, Michelle Phung, Nicolas Betancourt, Bradley Fong, Rachna Sahasrabudhe, Khoban Nasim, Alec Eschholz, Basil Mustafa, Jan Freyberg, Terry Spitz, Yossi Matias, Gregory S. Corrado, Katherine Chou, Dale R. Webster, Peggy Bui, Yuan Liu, Yun Liu, Justin Ko, Steven LinarXiv 2024 · DOI · arXiv

Introduction

Deep learning models have demonstrated remarkable potential in dermatology, often achieving performance levels comparable to specialists in controlled experimental settings. However, a significant challenge remains: the "generalization gap." When these models are deployed in new clinical environments, their accuracy often declines. Traditionally, researchers attributed this drop to "domain shift"—variations in image quality, lighting, or patient demographics. This paper investigates the root causes of this gap and proposes efficient strategies to bridge it, focusing on the transition from large-scale development datasets to real-world clinical settings like Stanford Health Care.

Identifying the Source of the Gap

A primary concern in modern dermatology is the rise of teledermatology, where images are frequently "Patient-Taken" (PAT) rather than "Clinician-Taken" (CLIN). It was hypothesized that the lower quality or inconsistent framing of PAT images might be the primary driver of performance degradation.

However, this research reveals a different reality. Through UMAP visualizations of model embeddings, the authors found that the AI clustered images by condition and body location rather than by the source of the photo. Furthermore, multivariable logistic regression indicated that patient demographics—including age, sex, and Fitzpatrick skin type—were not significantly associated with AI errors. Instead, the primary driver of the generalization gap was found to be the shift in the distribution of skin conditions (the "priors") between the training and deployment sites.

Methodology

The researchers employed a robust deep learning framework to evaluate and mitigate these shifts:

  • Model Architecture: A Wide ResNet-101x3 feature extractor was used, pretrained on web-scale images via contrastive learning.
  • Metadata Integration: To incorporate clinical context, the model used Feature-wise Linear Modulation (FiLM). This allowed the model to contextualize visual features using 25 categorical variables, such as patient history and symptoms.
  • Adaptation Strategies: Four methods were tested to close the gap:
  • Score Recalibration: Adjusting confidence scores using multiclass Platt scaling to match the target site's distribution.
  • Distribution Matching: Resampling training data to mirror the condition frequencies of the new environment.
  • Data Augmentation: Incorporating a small subset of labeled data from the target site.
  • Head Fine-tuning: Freezing the core feature extractors and retraining only the final classification layer.

Experimental Setup and Datasets

The study utilized two primary datasets:

  • Development (DEV) Set: 41,290 cases (approximately 195,000 images) covering 204 primary conditions.
  • Stanford Evaluation Set: 2,500 eConsult cases from Stanford Health Care. This set was notably different from the DEV set, featuring a higher proportion of patient-taken images (25%) and a distinct prevalence of conditions, such as a higher frequency of cutaneous infections (e.g., tinea and herpes zoster).

Key Results

The baseline AI performance on the Stanford dataset initially yielded a top-3 accuracy between 71% and 74%. By addressing the distribution shift, the researchers achieved significant gains:

  • Impact of Distribution Matching: Simply resampling the evaluation set to match the training distribution improved accuracy by 8.4% to 10.0%.
  • Fine-Tuning Efficacy: Fine-tuning the classification head using condition-aware sampling resulted in a ~13% improvement in top-3 accuracy. This adjustment brought the AI's performance to a level comparable with that of Stanford dermatologists.
  • Computational Efficiency: The study highlighted that fine-tuning only the final classification layer was nearly as effective as end-to-end retraining, offering a computationally efficient path for local model adaptation.

Discussion and Limitations

While the study provides a clear roadmap for adapting AI to new clinical settings, some limitations remain. The most effective adaptation methods require labeled data from the target site, which can be resource-intensive to collect. Additionally, the study did not account for the "recommended next steps" (such as biopsies) that clinicians use to resolve ambiguity. Future research should also address dynamic shifts, such as seasonal variations in condition prevalence.

Conclusion

This research demonstrates that the AI generalization gap in dermatology is driven less by image source or demographics and more by differences in the underlying distribution of conditions across clinical settings. By recalibrating models to account for these local priors, it is possible to maintain high diagnostic accuracy across diverse environments, moving AI closer to reliable clinical deployment.

Summary updated

Abstract

Recently, there has been great progress in the ability of artificial intelligence (AI) algorithms to classify dermatological conditions from clinical photographs. However, little is known about the robustness of these algorithms in real-world settings where several factors can lead to a loss of generalizability. Understanding and overcoming these limitations will permit the development of generalizable AI that can aid in the diagnosis of skin conditions across a variety of clinical settings. In this retrospective study, we demonstrate that differences in skin condition distribution, rather than in demographics or image capture mode are the main source of errors when an AI algorithm is evaluated on data from a previously unseen source. We demonstrate a series of steps to close this generalization gap, requiring progressively more information about the new source, ranging from the condition distribution to training data enriched for data less frequently seen during training. Our results also suggest comparable performance from end-to-end fine tuning versus fine tuning solely the classification layer on top of a frozen embedding model. Our approach can inform the adaptation of AI algorithms to new settings, based on the information and resources available.
BibTeX
@misc{rikhye2024closing,
  author = {Rajeev V. Rikhye and Aaron Loh and Grace Eunhae Hong and Preeti Singh and Margaret Ann Smith and Vijaytha Muralidharan and Doris Wong and Rory Sayres and Michelle Phung and Nicolas Betancourt and Bradley Fong and Rachna Sahasrabudhe and Khoban Nasim and Alec Eschholz and Basil Mustafa and Jan Freyberg and Terry Spitz and Yossi Matias and Gregory S. Corrado and Katherine Chou and Dale R. Webster and Peggy Bui and Yuan Liu and Yun Liu and Justin Ko and Steven Lin},
  title = {{Closing the AI generalization gap by adjusting for dermatology condition distribution differences across clinical settings}},
  year = {2024},
  eprint = {2402.15566},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2402.15566},
}
Figure