Abstract
We propose OneFlow - a flow-based one-class classifier for anomaly (outlier) detection that finds a minimal volume bounding region. Contrary to density-based methods, OneFlow is constructed in such a way that its result typically does not depend on the structure of outliers. This is caused by the fact that during training the gradient of the cost function is propagated only over the points located near to the decision boundary (behavior similar to the support vectors in SVM). The combination of flow models and a Bernstein quantile estimator allows OneFlow to find a parametric form of bounding region, which can be useful in various applications including describing shapes from 3D point clouds. Experiments show that the proposed model outperforms related methods on real-world anomaly detection problems.
The Challenge of Density Estimation in Anomaly Detection
Anomaly detection—identifying data points that deviate significantly from the norm—is a fundamental challenge in fields ranging from fraud detection to industrial safety. Most modern approaches fall into two camps: kernel methods like One-Class SVM, which struggle to scale to massive datasets, or deep generative models like Variational Autoencoders and standard Normalizing Flows, which focus primarily on density estimation.
The inherent problem with density estimation is that it attempts to model the entire distribution of normal data. In many practical scenarios, the internal structure of the "normal" cluster is irrelevant; the priority is identifying where the cluster ends. Standard flow-based models can be "distracted" by fitting every peak and valley of the data density, often leading to sub-optimal boundaries for detecting outliers. OneFlow bridges this gap by directly solving the "minimum volume" problem—finding the smallest possible region that encloses a fixed percentage (e.g., 95%) of the training data.
Methodology: Combining Flows and Quantile Estimation
OneFlow integrates two powerful mathematical frameworks to define these boundaries:
- Normalizing Flows: These deep learning models learn an invertible mapping between a complex data distribution and a simple latent space (such as a hypersphere). Because the mapping is invertible and provides an explicit Jacobian determinant, the model can precisely calculate how volumes change when moving from the latent space back to the original data space.
- Bernstein Quantile Estimator: To find a region containing exactly $(1-\alpha)$ of the data, the model must estimate a quantile boundary. Since standard quantile estimators are often non-differentiable, OneFlow utilizes a Bernstein polynomial-based estimator, which is smooth and differentiable, allowing for effective neural network training via gradient descent.
During training, OneFlow maps data to a latent space and identifies a hypersphere that encloses most points. It then minimizes the volume of the corresponding region in the original input space. Crucially, the gradient of the cost function is primarily influenced by points near the decision boundary. This creates a "Support Vector" effect, where the model ignores the dense center of the cluster and focuses its learning effort on defining the edge.
Key Insights: Volume over Density
OneFlow's approach offers several advantages over traditional generative models:
- Boundary Focus: By prioritizing the volume of the bounding region over the probability density of every point, OneFlow ignores internal "blobs" and focuses on a tight outer shell.
- Parametric Boundaries: Because the flow is invertible, OneFlow provides an explicit parametric form for the boundary. This allows the model to generate 3D meshes that perfectly "shrink-wrap" complex point clouds.
- Robustness to Noise: The focus on the boundary makes the model naturally more robust to "polluted" training sets. Even if a portion of the training data contains anomalies, the Bernstein estimator helps maintain a clean, accurate boundary.
Experimental Results
The model was evaluated across diverse benchmarks, including tabular data (Thyroid, KDDCUP 99), image datasets (MNIST, Fashion-MNIST), and 3D point clouds.
Key performance highlights include:
- State-of-the-Art Performance: On the Thyroid and KDDCUP datasets, OneFlow achieved F1 scores of 0.7634 and 0.9702, respectively, outperforming Deep SVDD and standard log-likelihood flow models.
- Superior Out-of-Distribution (OOD) Detection: When trained on Fashion-MNIST and tested on MNIST, OneFlow correctly identified 92.47% of the unseen data as anomalies, compared to 89.59% for standard flow models.
- Visual Fidelity: Qualitative results demonstrate that OneFlow produces much smoother and tighter boundaries than standard density-based flows, which often produce jagged or overly complex regions.
Conclusion and Future Directions
OneFlow demonstrates that for one-class classification, focusing on the decision boundary rather than full density estimation leads to more robust and accurate anomaly detection. While the model shows sensitivity to the pre-defined outlier fraction ($\alpha$) and backbone architecture complexity, its ability to describe complex 3D shapes and maintain performance on polluted datasets opens new avenues for research in geometric deep learning and industrial monitoring.
Summary updated