Out-of-Distribution Detection using Counterfactual Distance

Maria Stoica, Francesco Leofante, Alessio Lomuscio
8/13/2025
cs.LGcs.AI

No confident code implementation found for this paper.

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

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{stoica2025outofdistribution,
  title  = {Out-of-Distribution Detection using Counterfactual Distance},
  author = {Maria Stoica and Francesco Leofante and Alessio Lomuscio},
  year   = {2025},
  eprint = {2508.10148},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2508.10148v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2508.10148.svg)](https://codeofpaper.com/paper/2508.10148)

Discussion