Anomaly detection—the art of finding the "needle in the haystack" or the "wolf in sheep's clothing"—is a cornerstone of modern AI, powering everything from credit card fraud detection to identifying cyber attacks. While deep learning has recently pushed the boundaries of this field, most high-performing methods were "hand-crafted" for images.
In their ICLR 2020 paper, "Classification-Based Anomaly Detection for General Data," Liron Bergman and Yedid Hoshen introduce GOAD (Distance-Based Multiple Transformation Classification). This approach bridges the gap between image-specific tricks and general-purpose data, setting a new standard for how we detect the unexpected in tabular datasets.
TL;DR
GOAD generalizes self-supervised anomaly detection by replacing image-specific rotations with random affine transformations, making it applicable to any data type. By using a distance-based "open-set" classification approach rather than standard softmax, it achieves state-of-the-art results on tabular data and improves robustness against adversarial attacks.
What Problem Does This Paper Address?
Most successful anomaly detection methods follow a "semi-supervised" path: they train only on "normal" data and must learn to flag anything else as an anomaly.
Recently, self-supervised learning became the gold standard for images. The idea was simple: take a normal image, rotate it by 0, 90, 180, or 270 degrees, and train a classifier to guess the rotation. If the model can’t guess the rotation of a new image accurately, that image is likely an anomaly.
However, this approach had two major flaws:
- Domain Specificity: You can rotate an image of a cat, but you can't "rotate" a row in a spreadsheet of medical records or network logs.
- The "Closed-Set" Trap: Standard classifiers (using softmax) are designed to pick the best category out of a fixed list. When shown something completely alien, they often become "unreasonably certain" about a wrong guess, failing to realize the data point is an anomaly.
Methods
The authors propose GOAD, which introduces two key innovations:
1. Random Affine Transformations
To make the method work for general (tabular) data, they ditch rotations. Instead, they apply $M$ random affine transformations ($T(x) = Wx + b$) to the input data. Because these are random linear projections, they can be applied to any vector of data, not just pixels. This creates $M$ different "subspaces" for the model to learn.
2. Distance-Based Classification (The "Open-Set" Approach)
Instead of a standard classifier, GOAD learns a feature space where transformed versions of normal data cluster around specific centers ($c_m$).
- The Loss: They use a center triplet loss. This ensures that the distance between a sample and its correct transformation center is small, while the distance to other transformation centers is large.
- The Normality Score: At test time, they calculate the probability that a sample belongs to its assigned transformation center. They add a small regularizing constant ($\epsilon$) to the calculation. This acts as a "prior for uncertainty," ensuring that if a data point is far from all known centers, the model doesn't get overconfident, resulting in a high anomaly score.
Key Insights and Ideas
- Randomness is a Feature, Not a Bug: You don't need "meaningful" transformations like rotation to learn a good representation. Randomly projecting data into different subspaces provides enough signal for the model to learn what "normal" looks like.
- Softmax is Dangerous for Anomalies: The paper highlights that standard softmax classifiers have high variance when faced with anomalies. By moving to a distance-to-center metric with an uncertainty constant, the model becomes much better at saying "I don't know what this is," which is exactly what an anomaly detector should do.
- Adversarial "Security through Obscurity": Because the transformations in GOAD are random and not publicly known (unlike "rotate 90 degrees"), it is significantly harder for an attacker to craft an anomaly that tricks the system.
Key Results
The authors evaluated GOAD across image domains (CIFAR-10, FashionMNIST) and tabular domains (medical and cybersecurity datasets).
- Tabular Dominance: GOAD achieved massive gains on cybersecurity datasets. On the KDD dataset, it reached an $F_1$ score of 98.4%, significantly outperforming the previous best of 93.7% (DAGMM).
- Image Competitive: On CIFAR-10, GOAD achieved an average AUC of 88.2%, beating the previous SOTA (GEOM) at 86.0%.
- Robustness to "Pollution": In real-world scenarios, training data is rarely 100% clean. GOAD proved remarkably robust, maintaining high accuracy even when the "normal" training set was contaminated with up to 5% anomalies.
- Efficiency: The authors found that as few as 16 random transformations are enough to stabilize the model's performance, minimizing computational overhead.
Limitations and Future Work
- Model Complexity: While deep networks helped on large datasets like KDD, they tended to overfit on smaller medical datasets (Arrhythmia/Thyroid). In those cases, a simple linear classifier actually performed better.
- Parameter Sensitivity: While generally robust, the choice of the margin parameter ($s$) in the triplet loss can cause some instability if set too small.
- Future Directions: The authors suggest that this distance-based framework could be a foundation for future theoretical analysis of why self-supervised tasks work so well for anomaly detection.
Paper Citation: Bergman, L., & Hoshen, Y. (2020). Classification-Based Anomaly Detection for General Data. International Conference on Learning Representations (ICLR).
Summary updated