OneFlow: One-Class Flow for Anomaly Detection Based on a Minimal Volume Region

Lukasz Maziarka, Marek Smieja, Marcin Sendera, Lukasz Struski, Jacek Tabor, Przemyslaw Spurek · DOI

Abstract

Anomaly detection, or one-class classification, is the critical task of identifying data points that do not conform to the patterns of a "normal" training set. Traditional deep learning approaches often struggle with either over-modeling internal data density or suffering from mathematical instabilities like hypersphere collapse. We introduce OneFlow, a framework that leverages normalizing flows to find a minimal volume region enclosing a target percentage of the data. By employing a differentiable Bernstein quantile estimator, OneFlow focuses specifically on the decision boundary, resulting in a robust classifier. Our evaluation across tabular and image benchmarks shows that OneFlow consistently matches or exceeds the performance of state-of-the-art methods while providing unique geometric interpretability.

Introduction

Identifying anomalies is vital for applications ranging from fraud detection to industrial failure diagnosis. The primary challenge lies in the lack of anomaly examples during training. Existing methods typically fall into two categories: density-based models, which may over-focus on internal data structures, and distance-based models, which are prone to mapping all data to a single point (hypersphere collapse). OneFlow addresses these issues by seeking a minimal volume region that encloses a fixed percentage of the data without requiring a full density model.

Methodology

OneFlow integrates two key components to achieve robust anomaly detection:

Normalizing Flows

Normalizing flows are invertible neural networks that map complex input data into a simple latent space, such as a Gaussian distribution. Their invertibility allows for an explicit calculation of volume changes via the Jacobian. OneFlow uses this property to relate the volume of a hypersphere in the latent space back to the bounding region in the original input space.

Bernstein Quantile Estimator

To define a region containing exactly $(1-\alpha)$ of the data, the model must estimate a quantile. Since standard quantile estimators are non-differentiable, OneFlow utilizes the Bernstein quantile estimator. This provides a smooth, differentiable way to estimate the boundary, ensuring that gradients are primarily propagated through points near the decision boundary. This "support vector" behavior makes the model indifferent to the specific density of data deep within the normal region.

Figure 1: Comparison of OneFlow and standard log-likelihood flow (LL-Flow) on a 2D dataset. OneFlow (orange) successfully isolates the main cluster, while LL-Flow (blue) is pulled toward distant outliers.

Experimental Results

The authors evaluated OneFlow against various benchmarks, including tabular data (Thyroid, KDDCUP 99) and image datasets (MNIST, Fashion-MNIST).

Performance Metrics

OneFlow demonstrated superior performance in several key areas:

  • Tabular Data: On the Thyroid dataset, OneFlow achieved an F1 score of 0.7634, significantly outperforming Deep SVDD (0.6989).
  • Image Data: In MNIST and Fashion-MNIST experiments, OneFlow and its variant, OneFlow-Gen, consistently ranked among the top performers in terms of Area Under the Curve (AUC).

Geometric Interpretability

A unique advantage of OneFlow is its ability to provide a parametric form for the bounding region. This allows for the generation of 3D mesh representations of point clouds, effectively "shrink-wrapping" the data.

Figure 4: 3D point clouds of a car and a plane (left) and their corresponding mesh representations generated by OneFlow (right).

Discussion and Conclusion

OneFlow's focus on the boundary rather than internal density provides significant robustness to training noise. Even if the training set is corrupted with outliers, the model remains stable. However, the performance is sensitive to the $\alpha$ hyperparameter, which defines the expected fraction of outliers.

Future work may involve automating the selection of $\alpha$ and exploring more complex image datasets. Despite these challenges, OneFlow represents a significant step forward in creating mathematically rigorous and geometrically interpretable anomaly detection models.

Summary updated

BibTeX
@article{maziarka2022oneflow,
  author = {Lukasz Maziarka and Marek Smieja and Marcin Sendera and Lukasz Struski and Jacek Tabor and Przemyslaw Spurek},
  title = {{OneFlow: One-Class Flow for Anomaly Detection Based on a Minimal Volume Region}},
  journal = {IEEE Trans. Pattern Anal. Mach. Intell.},
  year = {2022},
  doi = {10.1109/tpami.2021.3108223},
}
Figure