Table of Contents
Fetching ...

An Evidence-Based Post-Hoc Adjustment Framework for Anomaly Detection Under Data Contamination

Sukanya Patra, Souhaib Ben Taieb

TL;DR

EPHAD tackles the practical challenge that unsupervised anomaly detectors are often trained on contaminated data and deployed without access to clean training pipelines. The framework performs a simple yet principled post-hoc adjustment at test time by reweighting the contaminated density (or scores) with an evidence function that encapsulates domain knowledge or external models (e.g., CLIP, LOF). By formulating evidence-driven updates through exponential tilting and a tunable temperature parameter $eta$, EPHAD produces a revised density or score $ ext{(updated)} \, s$ that better separates normal from anomalous samples under contamination. The authors provide theoretical links via KL divergence to show when the updated density moves closer to the true inlier distribution, and extend the method to score-based detectors, where the revised inlier score becomes $ ext{updated} \, s_{in} = s_{in} + T(x)/\beta$. An adaptive variant, EPHAD-Ada, selects $eta$ in an unsupervised manner using test-time entropy minimisation, removing the need for labeled validation data. Extensive experiments across eight visual datasets, 26 tabular datasets, and an industrial CSP plant dataset show that EPHAD consistently improves AUROC when paired with diverse evidence sources and detectors, with CLIP-based evidence providing particularly strong gains in many settings. The framework remains robust to varying contamination levels and model choices, and ablations highlight the roles of contamination ratio, $eta$, and evidence quality in driving performance. The work contributes a practical, model-agnostic tool for data-contamination-aware anomaly detection and provides open-source code for reproducibility.

Abstract

Unsupervised anomaly detection (AD) methods typically assume clean training data, yet real-world datasets often contain undetected or mislabeled anomalies, leading to significant performance degradation. Existing solutions require access to the training pipelines, data or prior knowledge of the proportions of anomalies in the data, limiting their real-world applicability. To address this challenge, we propose EPHAD, a simple yet effective test-time adaptation framework that updates the outputs of AD models trained on contaminated datasets using evidence gathered at test time. Our approach integrates the prior knowledge captured by the AD model trained on contaminated datasets with evidence derived from multimodal foundation models like Contrastive Language-Image Pre-training (CLIP), classical AD methods like the Latent Outlier Factor or domain-specific knowledge. We illustrate the intuition behind EPHAD using a synthetic toy example and validate its effectiveness through comprehensive experiments across eight visual AD datasets, twenty-six tabular AD datasets, and a real-world industrial AD dataset. Additionally, we conduct an ablation study to analyse hyperparameter influence and robustness to varying contamination levels, demonstrating the versatility and robustness of EPHAD across diverse AD models and evidence pairs. To ensure reproducibility, our code is publicly available at https://github.com/sukanyapatra1997/EPHAD.

An Evidence-Based Post-Hoc Adjustment Framework for Anomaly Detection Under Data Contamination

TL;DR

EPHAD tackles the practical challenge that unsupervised anomaly detectors are often trained on contaminated data and deployed without access to clean training pipelines. The framework performs a simple yet principled post-hoc adjustment at test time by reweighting the contaminated density (or scores) with an evidence function that encapsulates domain knowledge or external models (e.g., CLIP, LOF). By formulating evidence-driven updates through exponential tilting and a tunable temperature parameter , EPHAD produces a revised density or score that better separates normal from anomalous samples under contamination. The authors provide theoretical links via KL divergence to show when the updated density moves closer to the true inlier distribution, and extend the method to score-based detectors, where the revised inlier score becomes . An adaptive variant, EPHAD-Ada, selects in an unsupervised manner using test-time entropy minimisation, removing the need for labeled validation data. Extensive experiments across eight visual datasets, 26 tabular datasets, and an industrial CSP plant dataset show that EPHAD consistently improves AUROC when paired with diverse evidence sources and detectors, with CLIP-based evidence providing particularly strong gains in many settings. The framework remains robust to varying contamination levels and model choices, and ablations highlight the roles of contamination ratio, , and evidence quality in driving performance. The work contributes a practical, model-agnostic tool for data-contamination-aware anomaly detection and provides open-source code for reproducibility.

Abstract

Unsupervised anomaly detection (AD) methods typically assume clean training data, yet real-world datasets often contain undetected or mislabeled anomalies, leading to significant performance degradation. Existing solutions require access to the training pipelines, data or prior knowledge of the proportions of anomalies in the data, limiting their real-world applicability. To address this challenge, we propose EPHAD, a simple yet effective test-time adaptation framework that updates the outputs of AD models trained on contaminated datasets using evidence gathered at test time. Our approach integrates the prior knowledge captured by the AD model trained on contaminated datasets with evidence derived from multimodal foundation models like Contrastive Language-Image Pre-training (CLIP), classical AD methods like the Latent Outlier Factor or domain-specific knowledge. We illustrate the intuition behind EPHAD using a synthetic toy example and validate its effectiveness through comprehensive experiments across eight visual AD datasets, twenty-six tabular AD datasets, and a real-world industrial AD dataset. Additionally, we conduct an ablation study to analyse hyperparameter influence and robustness to varying contamination levels, demonstrating the versatility and robustness of EPHAD across diverse AD models and evidence pairs. To ensure reproducibility, our code is publicly available at https://github.com/sukanyapatra1997/EPHAD.
Paper Structure (27 sections, 1 theorem, 25 equations, 5 figures, 10 tables)

This paper contains 27 sections, 1 theorem, 25 equations, 5 figures, 10 tables.

Key Result

Proposition 4.1

Let $f^+_{X}$, $f^{\pm}_{X}$, and $\check{f}^{\pm}_{X}$ be PDFs over the same domain ${\mathcal{X}}$. Then the KL divergence between $f^+_{X}$ and $\check{f}^{\pm}_{X}$ is strictly less than the divergence between $f^+_{X}$ and $f^{\pm}_{X}$ iff

Figures (5)

  • Figure 1: DeepSVDD trained on 2D synthetic contaminated training data with different configurations: (I) Supervised AD with ground truth labels for reference, (ii)"Blind" considering all samples as normal, (iii) "Refine" filtering out a fraction of the anomalies, and (iv) EPHAD updating the "Blind" anomaly detector using evidence computed on the samples available at test-time.
  • Figure 2: Ablation on parameters.
  • Figure 3: Ablation on $\epsilon$.
  • Figure 4: Ablation on $\beta$.
  • Figure 5: Ablation on varying proportion of anomalies in the test set.

Theorems & Definitions (2)

  • Proposition 4.1
  • proof