cs.LGAug 13, 2025

Out-of-Distribution Detection using Counterfactual Distance

Authors: Maria Stoica, Francesco Leofante, Alessio Lomuscio

Organizations: Imperial College London

Abstract

Accurate and explainable out-of-distribution (OOD) detection is required to use machine learning systems safely. Previous work has shown that feature distance to decision boundaries can be used to identify OOD data effectively. In this paper, we build on this intuition and propose a post-hoc OOD detection method that, given an input, calculates the distance to decision boundaries by leveraging counterfactual explanations. Since computing explanations can be expensive for large architectures, we also propose strategies to improve scalability by computing counterfactuals directly in embedding space. Crucially, as the method employs counterfactual explanations, we can seamlessly use them to help interpret the results of our detector. We show that our method is in line with the state of the art on CIFAR-10, achieving 93.50% AUROC and 25.80% FPR95. Our method outperforms these methods on CIFAR-100 with 97.05% AUROC and 13.79% FPR95 and on ImageNet-200 with 92.55% AUROC and 33.55% FPR95 across four OOD datasets

Figures & tables

Appendix figures & tables2 assets

Supplementary material from the paper’s appendix.

Appendix

Explore similar work

CardsList
  1. AOE: Exhaustive Out-of-Distribution Detection via Recalibrating Outlier Labels

    May 27, 2026Fengqiang Wan, Qing-Yuan Jiang, Yang YangOut-Of-Distribution DetectionOutliers

  2. Sparse Autoencoders for Interpretable Out-of-Distribution Detection

    Jul 13, 2026Ayush Karmacharya, Luke Luschwitz, Lucia Romero +2Out-Of-Distribution DetectionOut-Of-Distribution

  3. A Robust Out-of-Distribution Detection Framework via Synergistic Smoothing

    May 5, 2026Maria Stoica, Abdelrahman Hekal, Alessio LomuscioOut-Of-Distribution DetectionSmoothing