TL;DR
Training effective anomaly detectors is notoriously difficult due to the extreme scarcity of real-world anomalous data. While generative models can synthesize artificial anomalies to fill the gap, low-quality synthetic data—either too similar to normal data or completely unrealistic—can severely degrade model performance. This paper introduces the Expected Anomaly Posterior (EAP), a novel Bayesian framework that quantifies the quality of auxiliary anomalies by balancing both aleatoric and epistemic uncertainty, significantly improving downstream detector training and model selection.
What Problem Does This Paper Address?
Anomaly detection is crucial for identifying rare, high-stakes events like manufacturing defects, equipment failures, or financial fraud. However, because anomalies are inherently rare, training datasets are heavily imbalanced, often containing few or no anomalous examples.
To combat this, researchers frequently use generative models to create "auxiliary synthetic anomalies" to expose the detector to potential failure modes. The catch? Synthetic anomalies often fail in one of two ways:
- Indistinguishable anomalies: They look identical to normal data (e.g., an imperceptible image artifact), which confuses the model's decision boundary.
- Unrealistic anomalies: They are completely detached from the actual data distribution (e.g., random noise), providing no useful learning signal for real-world scenarios.
Existing data valuation metrics (like Data Shapley or Leave-One-Out) are designed to measure the impact of clean training data, not external, unlabelled synthetic anomalies. This paper bridges the gap by providing the first example-wise score function tailored to evaluate the utility of auxiliary anomalies.
Methods
The authors propose the Expected Anomaly Posterior (EAP), which leverages a Bayesian framework to model a detector's total uncertainty regarding a synthetic sample. High-quality anomalies must hit a "Goldilocks zone": they must be distinct from normal data while remaining realistic enough to resemble the broader data domain.
EAP achieves this by combining two distinct types of uncertainty:
- Aleatoric Uncertainty (Proximity to Normal Class): Estimated using a squashing scaler that maps standard anomaly scores (from an underlying detector like SSDO) into well-behaved conditional probabilities $P(Y=1|X=x)$.
- Epistemic Uncertainty (Data Density): Estimated using the reciprocal of a normalized Rarity Score (based on $k$-NN spheres around training data). This avoids the curse of dimensionality and the massive computational overhead of deep density estimators like Normalizing Flows.
By combining these via a Beta-Bernoulli conjugate prior setup, EAP computes the expected posterior probability of an instance being a useful anomaly. If a sample is too close to normal data or falls into a completely empty, unrealistic region of the feature space, its EAP score drops.
Datasets
The authors evaluated EAP across 40 benchmark datasets:
- Images: 15 datasets from the widely used MVTec AD manufacturing anomaly benchmark and 3 industrial Surface Defect Inspection (SDI) datasets.
- Tabular Data: 22 diverse datasets from the ADBench anomaly detection suite.
To rigorously test the selection process, the authors constructed artificial auxiliary sets for each dataset consisting of an equal split of true (realistic) anomalies, indistinguishable anomalies (normal data with flipped labels), and unrealistic anomalies (subsampled data projected from completely different datasets).
Key Insights and Ideas
- The Dual-Constraint Requirement: You cannot evaluate anomaly quality using density or class probability alone. A pure density estimator cannot differentiate a realistic anomaly from a normal sample. A pure class probability estimator cannot differentiate a realistic anomaly from out-of-distribution garbage noise. EAP's core strength is mathematically binding them together.
- Theoretical Guarantees: The authors prove that under mild assumptions, EAP mathematically guarantees ranking realistic anomalies above unrealistic ones, which are in turn ranked above indistinguishable ones.
Key Results
EAP was comprehensively tested against 12 adapted baseline data-valuation methods (including LAVA, DataOOB, and KNN-Shapley).
- Quality Ranking Accuracy ($AUC_{QLT}$): EAP consistently outperformed all baselines, achieving a mean quality ranking score of 0.803 on images and 0.821 on tabular data. It beat its closest competitors (LAVA and Rarity Score) by substantial margins across 30+ out of 40 datasets.
- Downstream Detector Enhancement: When the top 1/3 of EAP-selected anomalies were added to the training set, the detector's test accuracy improved significantly faster and higher than when using baseline selectors.
- Zero-Shot Prompt Tuning: The authors used EAP to select synthetic anomalies for tuning text prompts in a zero-shot CLIP model on MVTec images. EAP successfully identified the highest-quality prompts, achieving the best test AUC on 12 out of 15 object classes.
Limitations and Future Work
While highly effective, the authors note a couple of limitations:
- Domain-Specific Realism: The boundary between "unrealistic" and "realistic" can sometimes be domain-dependent. For instance, a massive, highly unusual tear in a fabric dataset might be mathematically flagged as "low density/unrealistic," even though it is a valid real-world anomaly.
- Sensitivity to Normal Sample Scale: Because EAP relies heavily on epistemic uncertainty relative to the training set, an overwhelming abundance of normal training samples can occasionally suppress the density signal, meaning users might need to downsample normal data to keep the uncertainty estimates sharp.
Summary updated