Detecting Both Seen and Unseen Anomalies in Time Series
Chen Liu, Shibo He, Shizhong Li, Zhenyu Shi, Wenchao Meng · ACM Transactions on Knowledge Discovery from Data · 2025
A plethora of methods for time series anomaly detection has surfaced recently, encompassing both supervised and unsupervised settings. However, few approaches are designed to accommodate both settings simultaneously. Moreover, methods tailored for supervised scenarios often struggle to identify out-of-distribution (OOD) anomalies, while those for unsupervised scenarios may easily overlook in-distribution (ID) anomalies. To bridge this gap, we propose InvAD, a unified framework capable of detecting both ID and OOD anomalies, which seamlessly scales between unsupervised and supervised settings. To address the potential information loss in existing feature extraction techniques, our framework incorporates an information-preserving invertible neural network (INN) with a mathematical guarantee. Specifically, InvAD adopts a dual-branch structure with a shared feature encoder stacked by INN blocks. This encoder decomposes original intricate signals into ID features and OOD features without discarding any information. For ID anomalies, we treat all training data as ID samples and push their OOD features close to a predefined constant value. This step aims to encode all valuable information of ID samples within the ID features, which are then employed to recognize seen anomalies through a classifier. For OOD anomalies, during the training stage, we endeavor to reconstruct original signals from ID features and the constant value through the backward process of the feature encoder. OOD anomalies are detected when a significant discrepancy exists between the reconstructed and original signals during the testing stage. Additionally, while contrastive learning has shown remarkable success in time series analysis, the construction of effective sample pairs remains underexplored. To address this, we introduce a label-guided contrastive learning module. This module leverages pseudo labels provided by the classifier to correct false positive pairs generated by conventional data augmentation methods. Extensive experiments on 12 real-world datasets validate the superiority of InvAD under unsupervised, supervised, and weakly supervised settings. Furthermore, ablation studies demonstrate that the pseudo labels can effectively enhance the performance of contrastive learning in time series anomaly detection.