Probabilistic Distance-Based Outlier Detection

David Muhr, Michael Affenzeller, Josef Küng · DOI

Abstract

Distance-based outlier detection methods, such as $k$-Nearest Neighbors ($k$NN), are widely used but produce raw scores that are difficult to interpret across different datasets and scales. This paper introduces a ranking-stable transformation that converts these raw scores into interpretable probabilities. By leveraging the often-discarded information in a dataset's distance matrix to model distance distributions, the authors provide a way to define "outlierness" that is consistent across different algorithms without sacrificing detection performance.

Introduction

Distance-based outlier detection typically produces scores representing physical or manifold distances. These scores are notoriously difficult to interpret: a score of 5.0 might indicate a definite outlier in one dataset but a normal point in another, depending on scale, dimensionality, and local density. This lack of a universal scale makes it nearly impossible to set a standard threshold for anomaly detection without manual tuning or extensive domain context. While methods like Local Outlier Factor (LOF) attempt local normalization, they lack a true probabilistic interpretation that generalizes across different algorithmic families.

Notation used in the probabilistic transformation framework.

Methodology

Unified Weighting Scheme ($k$NNW)

The authors first formalize various distance-based methods into a unified weighting scheme called $k$NNW (weighted $k$-Nearest Neighbors). This framework represents $k^{th}$NN (distance to the $k$-th neighbor) and $k$NN (average distance to $k$ neighbors) as specific instances of a weight vector applied to neighbor distances. This unification allows the probabilistic transformation to be applied consistently across a variety of distance-based algorithms.

Weighting schemes for generalized k-nearest neighbors (kNNW), showing how different methods prioritize specific neighbors.

Probabilistic Mapping

The core of the proposal is a transformation based on the distribution of distances within the data. Most algorithms compute a distance matrix but discard the majority of those distances. The authors use these discarded distances to form a "normalization set."

By treating the distances in the normalization set as a random variable $r$ following a distribution $P$, the raw outlier score $s$ is transformed using a Cumulative Distribution Function (CDF):

$$f(s) = P(r \le s)$$

A resulting score of 0.99 means the point’s distance relationship is in the top 1% of all distance relationships observed in the reference data. This logic is also extended to image-based anomaly detection (ProbabilisticPatchCore) by applying the transformation to patch-level scores.

Experimental Evaluation

Datasets

The method was evaluated across a diverse range of benchmarks:

  • Tabular Data: Over 30 datasets from the DAMI library (e.g., Annthyroid, Arrhythmia) and the UTSD (Univariate Time Series Dataset) benchmark.
  • Image Data: The MVTec AD dataset, containing 15 categories of industrial objects with pixel-precise ground truth for anomalies.

Key Results

  • Ranking Stability: Because the CDF transformation is monotonically non-decreasing, the relative ranking of data points remains unchanged. Consequently, the Area Under the ROC Curve (ROC AUC) remains identical to the raw versions, ensuring interpretability is gained without losing predictive power.
  • Contrast Enhancement: The transformation increases the "contrast" between normal and outlier points. By mapping distances to a probability space, the gap between the bulk of normal data and the outliers becomes more pronounced.
  • Thresholding: The authors demonstrate that using statistical distances (like Earthmover Distance) on transformed scores allows for identifying near-optimal cut-off thresholds even in unsupervised settings where labels are unavailable.

Discussion and Future Work

While the method proves effective, the size of the "normalization set" ($m$) can impact the resulting contrast, and there is currently no automated method for choosing the optimal $m$ for every dataset. Furthermore, while the experiments focused on Euclidean distance, future work should explore how this transformation behaves with non-metric similarity measures, such as Cosine similarity in high-dimensional latent spaces. The authors also call for more theoretical analysis of how the normalization behaves under specific mathematical distributions.

Summary updated

BibTeX
@article{muhr2023probabilistic,
  author = {David Muhr and Michael Affenzeller and Josef Küng},
  title = {{Probabilistic Distance-Based Outlier Detection}},
  journal = {Mach. Learn. Knowl. Extr.},
  year = {2023},
  doi = {10.3390/make5030042},
}
Figure