TL;DR
This paper introduces CARLA, a novel self-supervised contrastive learning framework for time series anomaly detection (TSAD). By cleverly injecting synthetic anomalies and leveraging nearest/furthest neighbors, CARLA learns robust representations that significantly improve anomaly detection accuracy, especially in scenarios with limited labeled data.
What Problem Does This Paper Address?
Time series anomaly detection (TSAD) is crucial for monitoring systems and identifying unusual events. However, a major hurdle is the scarcity of labeled data in real-world applications. Existing unsupervised methods often define "normal" too narrowly, leading to high false positive rates. While contrastive learning has shown promise, standard approaches for time series often make assumptions (like augmented windows being positive and distant windows being negative) that don't always hold true, leading to suboptimal performance. This paper aims to bridge this gap by proposing a more robust contrastive learning method that effectively learns to distinguish normal from anomalous patterns without relying on ground truth labels.
Methods
CARLA employs a two-stage approach:
- Pretext Stage: This stage focuses on learning discriminative representations.
- Anomaly Injection: Instead of relying on standard augmentation, CARLA injects various types of synthetic anomalies (point and subsequence anomalies like global, contextual, seasonal, shapelet, and trend) into the time series windows. This helps the model learn to recognize deviations from normal behavior and generalize across different anomaly types.
- Contrastive Representation Learning: A ResNet architecture is used to extract features from time series windows. A triplet loss function is employed to learn representations where temporally proximate windows are similar, and injected anomalous windows are dissimilar to their original counterparts.
- Nearest/Furthest Neighbor Identification: After learning initial representations, the method identifies the Q nearest and Q furthest neighbors for each window in the representation space. This step aims to capture semantic similarity and dissimilarity.
- Self-supervised Classification Stage: This stage refines the learned representations.
- Contrastive Classification: A new ResNet is initialized with the pretext stage's learned features. A custom loss function is used to maximize similarity between a window and its nearest neighbors (classified as the same class) while minimizing similarity with its furthest neighbors (classified as different classes). This stage also incorporates an entropy loss to encourage class diversity and prevent overfitting.
- Inference: The model classifies windows as normal or anomalous based on their assignment to the majority class (identified from the original, non-anomalous windows) or by calculating an anomaly score.
Datasets
CARLA was evaluated on seven widely used real-world benchmark datasets for TSAD:
- MSL (Mars Science Laboratory)
- SMAP (Soil Moisture Active Passive)
- SMD (Server Machine Dataset)
- SWaT (Secure Water Treatment)
- WADI (Water Distribution testbed)
- Yahoo-A1 (a subset of the Yahoo dataset)
- KPI (Key Performance Indicators)
The paper notes that all datasets, except Yahoo, have a predefined train/test split with unlabeled training data.
Key Insights and Ideas
- Anomaly Injection is Key: Injecting diverse synthetic anomalies is more effective than standard augmentation for learning robust representations in TSAD, especially when ground truth is scarce.
- Beyond Standard Contrastive Assumptions: The paper argues that traditional contrastive learning assumptions for time series (e.g., augmented windows are positive) are flawed and proposes a more tailored approach.
- Nearest/Furthest Neighbors as Priors: Using semantically meaningful nearest and furthest neighbors in the representation space significantly enhances the discriminative power of the learned features.
- Two-Stage Refinement: The two-stage approach (pretext learning followed by self-supervised classification) demonstrably improves the segregation of normal and anomalous patterns.
- Balance is Crucial: CARLA achieves a strong balance between precision and recall, leading to high F1 and AU-PR scores, which is vital for reliable anomaly detection.
Key Results
CARLA demonstrated superior performance across a range of multivariate and univariate time series datasets.
- It achieved the highest F1 scores across most datasets, with a notable exception on SWaT.
- CARLA consistently ranked as the best-performing model in terms of average rank based on F1 scores.
- The model showed significantly lower False Positive Rates (FPR) compared to other models, indicating fewer false alarms.
- CARLA achieved high AU-PR scores, demonstrating its ability to accurately identify anomalies while minimizing false positives, especially on imbalanced datasets.
- Ablation studies showed that the combination of Linconsistency and Lentropy loss components was crucial for optimal performance.
- The window size of 200 was found to be optimal, and 10 classes provided the best classification performance.
Limitations and Future Work
- Anomaly Injection Limitations: The authors acknowledge that their injected anomalies are not exhaustive and suggest broadening the forms of injected anomalies. They also hypothesize that varying the severity of injected anomalies could further improve detection.
- Positive/Negative Sample Selection: Future research could focus on refining positive and negative sample selection strategies.
- Abnormal Sample Handling: For datasets with a significant number of abnormal samples, revisiting the selection of positives and negatives for abnormal anchors in unsupervised settings is recommended.
- Parameter Sensitivity: While optimal parameters were identified (window size 200, 10 classes, 5 neighbors, entropy coefficient 5), further exploration of parameter sensitivity could be beneficial.
Summary updated