Abstract
Anomaly detection (AD) is traditionally framed as a one-class classification problem, which often fails to leverage limited known anomalies or overfits when treated as a binary task. This paper introduces Normalizing Flow Anomaly Detection (NFAD), a method that transforms AD into a robust binary classification task. By using Normalizing Flows (NF) to sample 'surrogate anomalies' from the low-density tails of the normal data distribution, NFAD provides a model-agnostic framework to incorporate real-world anomaly samples without the risk of overfitting. Experimental results demonstrate that NFAD significantly outperforms existing one-class and semi-supervised methods across tabular and image datasets.
Introduction
In real-world applications, anomaly detection often occupies a middle ground between purely unsupervised learning and fully supervised classification. While most systems are trained on 'normal' data, practitioners frequently possess a small number of known anomalous examples, such as specific fraud cases or system failures. Standard one-class methods, such as One-Class SVM or Deep SVDD, ignore these examples, while standard binary classifiers overfit to the small, non-representative anomaly set. NFAD bridges this gap by using generative modeling to 'fill the empty space' around normal data with synthetic outliers.
Methodology
NFAD follows a three-step procedure to create a robust detector:
- Density Estimation: A Normalizing Flow is trained on the normal data distribution. NFs learn a bijective mapping between the complex data space and a simple latent space, typically a Gaussian.
- Surrogate Anomaly Sampling: Once the NF is trained, surrogate anomalies are sampled from the low-density tails of the latent Gaussian distribution. These points represent regions where normal data is unlikely to exist.
- Binary Classification: A standard classifier (e.g., a Deep Neural Network) is trained to distinguish between the normal data and a combined set of real known anomalies and the sampled surrogate anomalies.
Jacobian Regularization
A critical challenge in using NFs for anomaly detection is density distortion. A point in the latent tail might map back to a high-density region in the data space if the transformation has a non-unit Jacobian. To ensure that latent tails correspond to true data-space anomalies, the authors introduce Jacobian Regularization. This technique penalizes non-unit transformations, maintaining the integrity of the density mapping and preventing surrogate anomalies from 'leaking' into the normal data space.
Experimental Results
The researchers evaluated NFAD on various datasets, including KDD-99 (network intrusion), HIGGS (physics), and CIFAR-10 (image classification).
Performance Gains
On the KDD-99 dataset, NFAD achieved a ROC AUC of 0.981 in a one-class setting. Remarkably, with the addition of just four known anomalies, the performance improved to 0.997, consistently beating established methods like Deep SVDD and DevNet. On CIFAR-10, NFAD-ResFlow reached a ROC AUC of 0.877, a substantial improvement over traditional one-class methods which typically hover between 0.54 and 0.58.
Limitations and Challenges
Despite its success, the authors noted limitations when dealing with complex, multi-modal distributions. In such cases, the reconstructed shape can lead to 'bridges' between modes, reducing separation quality. Additionally, on image data, NFs sometimes focus on local pixel statistics (textures) rather than high-level semantics, potentially missing anomalies that are semantically different but statistically similar at the pixel level.
Conclusion
NFAD provides a principled way to transition from one-class to semi-supervised anomaly detection. By leveraging the latent space of Normalizing Flows to generate surrogate outliers, the method allows standard classifiers to learn more effective decision boundaries. While challenges remain in capturing high-level semantics and handling highly non-convex distributions, NFAD represents a significant step forward in making anomaly detection more robust and data-efficient.
Summary updated