Out-of-Distribution Detection for Skin Lesion Images with Deep Isolation Forest

Xuan Li, Yuchen Lu, Christian Desrosiers, Xue Liu

Abstract

Deep learning models in dermatology often struggle with "out-of-distribution" (OOD) samples—skin conditions not present in the training data. Standard approaches frequently misclassify these unseen diseases with high confidence, posing a significant safety risk. We present DeepIF, a novel framework that integrates deep convolutional neural networks with Isolation Forests. By utilizing non-parametric modeling of high-dimensional features, DeepIF avoids the pitfalls of traditional Gaussian assumptions. Our results on the HAM10000 dataset demonstrate a 20% improvement in OOD detection performance compared to existing state-of-the-art methods while maintaining high classification accuracy.

Introduction: The Challenge of the "Closed-World"

While deep learning models have reached expert-level performance in classifying common skin cancers, they typically operate under a "closed-world" assumption. Most public datasets, such as HAM10000, contain only a handful of disease categories, whereas clinical practice involves thousands of distinct conditions. When presented with an unknown disease, standard models often force a classification into a known category. Effective Out-of-Distribution (OOD) detection—the ability of a model to identify samples it has not seen before—is therefore critical for the safe deployment of medical AI.

Previous OOD detection methods often assumed that image features follow a simple Gaussian (bell curve) distribution. However, the high intra-class diversity of skin lesions makes such parametric assumptions unreliable, leading to poor separation between known and unknown classes.

The DeepIF Framework

To address these limitations, we propose DeepIF (Deep Isolation Forest), a two-stage pipeline designed for robust OOD detection without requiring model retraining:

  1. Feature Extraction: A standard deep backbone (ResNet152), pre-trained on known skin lesion classes, extracts high-dimensional feature vectors ($h$) from the last convolutional layer. This layer captures the semantic information necessary to distinguish complex disease morphologies.
  2. Non-Parametric Modeling: Instead of fitting a statistical distribution, we employ an Isolation Forest (IF). Isolation Forests operate on the principle that anomalies are "few and different." By building random decision trees to partition the feature space, anomalies are isolated in shorter branches than normal data points.
Architecture of the DeepIF framework combining CNN feature extraction with Isolation Forest estimators.

As shown in the architecture above, an Isolation Forest is trained for each known class. For a new image, the system calculates a "normality score" based on its path length in these forests. If the image is not easily isolated within any known class forest, it is flagged as OOD.

Experimental Setup

The framework was evaluated using the HAM10000 dataset, which includes 25,331 dermatoscopic images across eight classes: Melanoma (MEL), Melanocytic nevus (NV), Basal cell carcinoma (BCC), Actinic keratosis (AK), Benign keratosis (BKL), Dermatofibroma (DF), Vascular lesion (VASC), and Squamous cell carcinoma (SCC).

We employed a "leave-one-out" strategy: the model was trained on seven classes, while the eighth was reserved as the "unseen" OOD sample for testing. This process was repeated for different class combinations to ensure comprehensive evaluation.

Results and Discussion

DeepIF consistently outperformed baseline methods, including Mahalanobis distance, Confidence Scoring, and Variational Autoencoders (VAEs).

ROC curves comparing DeepIF (Ours) against baseline OOD detection methods.

Key findings include:

  • Superior Detection: DeepIF achieved a mean AUROC of 0.7136, a significant improvement over the Mahalanobis-based state-of-the-art (0.5771).
  • Accuracy Preservation: Unlike some OOD methods that degrade primary classification performance, DeepIF maintained a high validation accuracy of approximately 90.3%.
  • Flexibility: As a "plug-and-play" solution, DeepIF can be applied to any pre-trained CNN without modifying the training loss or architecture.

The results confirm that non-parametric models like Isolation Forests are better suited for the complex, "messy" feature spaces characteristic of medical imaging. By not assuming a specific data shape, DeepIF can more accurately define the boundaries of known classes.

Conclusion and Future Work

DeepIF represents a significant step toward safer medical AI by providing a reliable mechanism for identifying unknown skin conditions. While the 20% improvement in detection rate is substantial, an AUROC of ~0.71 indicates that further research is needed before autonomous OOD flagging can be fully realized in high-stakes clinical environments. Future work will focus on extending DeepIF to other medical modalities, such as MRI and CT scans, and exploring more advanced non-parametric techniques.

Summary updated

BibTeX
@inproceedings{li2020out,
  author = {Xuan Li and Yuchen Lu and Christian Desrosiers and Xue Liu},
  title = {{Out-of-Distribution Detection for Skin Lesion Images with Deep Isolation Forest}},
  booktitle = {MLMI @ MICCAI},
  year = {2020},
  url = {https://openreview.net/forum?id=Ud4aeDNBwH},
}
Figure