Bridging Unsupervised and Semi-Supervised Anomaly Detection: A Theoretically-Grounded and Practical Framework with Synthetic Anomalies

Matthew Lau, Tian-Yi Zhou, Xiangchi Yuan, Jizhou Chen, Wenke Lee, Xiaoming Huo

TL;DR

This paper bridges the gap between unsupervised and semi-supervised anomaly detection by introducing a theoretically-grounded framework that mixes known anomalies with uniformly sampled synthetic ones during training. The authors provide the first mathematical formulation and theoretical convergence guarantees for semi-supervised anomaly detection using neural networks. This simple addition of synthetic data yields consistent empirical performance gains across five diverse real-world benchmarks.

What Problem Does This Paper Address?

Anomaly detection (AD) typically operates in one of two modes: unsupervised (training only on normal data) or semi-supervised (training on normal data plus a small labeled subset of known anomalies). Intuitively, having access to real examples of anomalies should make a model better. However, if you simply train a standard binary classifier to separate normal data from a limited set of known anomalies, you run into two major roadblocks:

  1. False Negative Modeling: If an entirely new, unknown type of anomaly appears during testing in a region where normal data density is low and known anomalies are absent, the classifier will likely misclassify it as normal.
  2. Insufficient Regularity of Learning (The Zero-Margin Problem): Without data filling the empty spaces between normal and anomalous clusters, the underlying regression function becomes discontinuous. This lack of smoothness makes it incredibly difficult for neural networks to reliably learn a clean decision boundary.

The authors tackle this gap by exploring whether principles from unsupervised AD—specifically, using synthetic anomalies to define the boundaries of "normal" space—can be generalized to improve semi-supervised AD.

Mathematical formulations of different AD tasks

Methods

The authors propose a simple yet mathematically elegant solution: inject uniformly distributed synthetic anomalies into the training dataset alongside the normal data and known anomalies.

By defining the anomaly class as a mixture of known anomalies and uniform synthetic noise, they ensure that the mathematical density of the anomaly class is bounded away from zero everywhere. This transforms a discontinuous learning problem into a smooth, continuous one ($C^r$ continuous), allowing neural networks to effectively approximate the optimal decision boundary.

The framework trains a standard ReLU neural network using a Hinge loss empirical risk minimizer (ERM) on the combined dataset: $$\text{Normal Data} \cup \text{Known Anomalies} \cup \text{Synthetic Anomalies}$$

Crucially, the authors leverage this formulation to prove the first-ever minimax optimal convergence rates for excess risk in semi-supervised AD.

Figure 2: Problem and Proposed Method. We present two cases of potential issues (pink regions) from using the known anomaly density as h2 (i.e., set h2 = h−). Sample 1D density plots and 2D data plots are provided. Circles are normal data while triangles are anomalies. The first row demonstrates the issue of wrongly modeling anomalies as normal, while the second row demonstrates the issue of insufficient regularity of learning, with the example of zero margin between normal data and known anomalies. Our solution of adding synthetic anomalies addresses these issues. In the first row, the pink region is populated with anomalies, so we can correctly model it as anomalous. In the second row, synthetic anomalies smoothen the regression function, which improve learning.

Datasets

The framework was evaluated across five distinct real-world benchmarks spanning tabular, image, and text modalities:

  • NSL-KDD: A tabular cybersecurity dataset for network intrusion detection.
  • Thyroid & Arrhythmia: Tabular medical datasets containing patient vitals.
  • MVTec: An industrial manufacturing image dataset, processed using frozen 1024-dimensional DINOv2 embeddings.
  • AdvBench: A language dataset for harmful text detection, processed using frozen 384-dimensional BERT sentence embeddings.

Key Insights and Ideas

  • Synthetic Anomalies as a Geometric Regularizer: The core "aha moment" is that synthetic anomalies do not need to resemble real anomalies to be useful. Instead, they act as a geometric space-filler. By populating the "open space" where no data exists, they force the network to draw tight boundaries around the normal data.
  • A Unified Mathematical Framework: The proposed mixture model elegantly unifies unsupervised and semi-supervised AD. If the known anomalies are removed or the mixture parameter is set to zero, the formulation naturally collapses back into standard unsupervised density level set estimation.
  • Smoothing the Regression Function: The paper mathematically demonstrates that adding uniform noise prevents the likelihood ratio from exploding in low-density normal regions, directly solving the false-negative modeling problem.

Key Results

  • Superior Performance on Unknown Anomalies: The proposed method (Vanilla Classification with Synthetic Anomalies, or VC-SA) consistently outperformed vanilla classification, showing clear performance gains in 19 out of 24 unknown anomaly categories across the benchmarks.
  • No Dilution of Labeled Signals: Adding synthetic data did not dilute the utility of the real, labeled anomalies; in fact, VC-SA improved performance on known anomalies in 5 out of 7 categories.
  • Broad Generalizability: The benefit of adding synthetic anomalies extended beyond their specific vanilla classifier to other state-of-the-art classification-based AD methods (such as ES and DROCC). However, the approach was less effective for autoencoder-based architectures (like DeepSAD), where synthetic data can conflict with reconstruction constraints.

Limitations and Future Work

  • Autoencoder Incompatibility: The framework shows mixed results when paired with autoencoders. The authors note that negative supervision needs to be more carefully designed for reconstruction-based models, potentially through contrastive learning frameworks.
  • Assumption of Clean Normal Data: The current theoretical guarantees assume that the normal training data is completely pure. In practice, training data is often "contaminated" with hidden anomalies. Extending this mathematical framework to handle contaminated training data is a prominent direction for future work.

Summary updated

BibTeX
@misc{lau2025bridging,
  author = {Matthew Lau and Tian-Yi Zhou and Xiangchi Yuan and Jizhou Chen and Wenke Lee and Xiaoming Huo},
  title = {{Bridging Unsupervised and Semi-Supervised Anomaly Detection: A Theoretically-Grounded and Practical Framework with Synthetic Anomalies}},
  year = {2025},
  eprint = {2506.13955},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2506.13955},
}
Figure