Real-Time Anomaly Detection with Synthetic Anomaly Monitoring (SAM)

Emanuele Luzio, Moacir Antonelli PontiarXiv 2025 · DOI · arXiv

Abstract

Traditional anomaly detection methods often struggle with the trade-off between computational efficiency, interpretability, and the ability to define "normal" behavior in high-dimensional data streams. This paper introduces Synthetic Anomaly Monitoring (SAM), a novel unsupervised framework that reframes anomaly detection through the lens of causal inference. By adapting Synthetic Control Methods (SCM) from econometrics, SAM models each data feature as a "synthetic" combination of its peers. Anomalies are identified as significant deviations from these counterfactual expectations. Evaluation across five benchmark datasets demonstrates that SAM achieves state-of-the-art performance, particularly in precision-recall metrics, while maintaining a constant computational complexity relative to the number of observations.

Introduction

In modern data environments, detecting anomalies—rare observations that deviate significantly from the majority of the data—is a critical task for cybersecurity, fraud prevention, and system health monitoring. However, practitioners frequently encounter three primary bottlenecks: the "black-box" nature of high-performing models like Isolation Forests, the poor scalability of distance-based methods like k-Nearest Neighbors (kNN), and the difficulty of defining a robust boundary for normality without labeled training data.

Synthetic Anomaly Monitoring (SAM) addresses these challenges by borrowing a concept from causal inference: the Synthetic Control Method. Rather than attempting to model the entire distribution of the data at once, SAM treats each individual feature as a unit of interest and uses the remaining features to predict its "normal" state. This approach provides a transparent, fast, and highly interpretable mechanism for real-time monitoring.

Methodology

The Synthetic Control Analogy

In economics, a synthetic control is a weighted combination of untreated units used to estimate what would have happened to a treated unit in the absence of an intervention. SAM applies this logic to multivariate data by treating each feature $X_i$ as a "treated" unit and the other features as the "control pool."

  1. Feature as a Unit: For a given dataset, SAM fits a linear model for every feature using all other features as predictors.
  2. The Counterfactual: This model generates a "synthetic" version of the feature, representing its expected value based on the correlations present in the rest of the data.
  3. Anomalies as Treatments: When a new data point arrives, SAM compares the observed value of each feature to its synthetic counterpart. A large residual (the difference between observed and predicted) is interpreted as a "treatment effect," signaling an anomaly.

Robustness with RANSAC

To prevent the model from learning from existing outliers in the training set, the authors incorporate RANSAC (Random Sample Consensus). RANSAC iteratively selects random subsets of the data to find the best linear fit for the majority (the inliers), effectively ignoring noise and outliers during the weight-estimation phase.

Computational Efficiency

One of SAM’s primary advantages is its inference speed. Because the model relies on linear dot products, its complexity is $O(d^2)$, where $d$ is the number of features. Unlike kNN or Local Outlier Factor (LOF), which scale with the number of historical observations ($n$), SAM’s performance remains constant regardless of the dataset's volume, making it ideal for high-speed streaming applications.

Experimental Evaluation

Datasets and Benchmarks

The researchers evaluated SAM against four industry-standard models: Isolation Forest, LOF, kNN, and One-Class SVM. The testing suite included five diverse datasets:

  • Credit Card Fraud (cc): Imbalanced transaction data.
  • HTTP Attack (http): Web request logs for intrusion detection.
  • KDD Cup 1999 (kdd): Network traffic benchmarks.
  • Forest Cover (cover): Cartographic variables.
  • Mulcross (mc): A synthetic multivariate dataset with 10% anomalies.

Performance Metrics

The study focused on ROC AUC (Area Under the Receiver Operating Characteristic Curve) and PR AUC (Area Under the Precision-Recall Curve). PR AUC is particularly vital for anomaly detection, as it better reflects model performance on highly imbalanced datasets where anomalies are rare.

Key Results

SAM variants (specifically SAM++ and SAM-+, which utilize different normalization strategies) demonstrated superior performance across several benchmarks:

  • State-of-the-Art Accuracy: SAM outperformed the Isolation Forest on the "http," "kdd," and "mulcross" datasets in terms of ROC AUC.
  • Precision-Recall Excellence: On the "http" dataset, SAM achieved a perfect 1.00 PR AUC, and a 0.97 on "mulcross," significantly surpassing the benchmarks.
  • The Role of Normalization: The authors found that normalizing residual errors (dividing the deviation by the expected value) was crucial for datasets with varying feature scales, such as network traffic data.

Discussion and Interpretability

Beyond raw performance, SAM offers built-in explainability. Most anomaly detection models provide a single score for a row of data. SAM, however, calculates a residual for every feature. This allows operators to see exactly which feature—or set of features—deviated from the synthetic norm, providing an immediate root-cause analysis for the detected anomaly.

Limitations

While SAM is highly efficient, it currently relies on linear relationships between features. While this ensures speed and transparency, it may struggle to capture complex, non-linear dependencies. Additionally, the stochastic nature of RANSAC means that model weights can vary slightly between training runs.

Conclusion

Synthetic Anomaly Monitoring (SAM) represents a significant step forward in making anomaly detection both interpretable and scalable. By reframing the problem as a causal counterfactual, SAM provides a mathematically grounded framework that rivals the accuracy of complex ensemble methods while maintaining the speed required for real-time production environments. Future work will focus on adapting SAM for "concept drift" through online learning, allowing the synthetic controls to evolve alongside changing data patterns.

Summary updated

BibTeX
@misc{luzio2025real,
  author = {Emanuele Luzio and Moacir Antonelli Ponti},
  title = {{Real-Time Anomaly Detection with Synthetic Anomaly Monitoring (SAM)}},
  year = {2025},
  eprint = {2501.18417},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2501.18417},
}
Figure