# CL-TAD: A Contrastive-Learning-Based Method for Time Series Anomaly Detection
## 1 Introduction
Motivated by the successes of reconstruction-based learning techniques and the potential of contrastive learning for unlabeled data, we propose a novel method for anomaly detection in time-series data, called CL-TAD (Contrastive-Learning-based method for Times series Anomaly Detection). The key aspects of the proposed method are as follows:  
* The CL-TAD method is comprised of two main components: positive sample generation and contrastive-learning-based representation learning. The first component plays role of generating positive samples from normal time series data. This is accomplished through a reconstruction process that tries to recover the original data from masked data. This reconstruction-based sampling is expected to augment a scarce original dataset into a robust and large training dataset that retains the essential information of normal patterns. The second component applies a contrastive learning technique to both the generated samples and the original data to produce their representations. Instead of directly producing the representations for generated samples, a transformation function with learnable parameters is applied to those samples to extract more meaningful information. The employed learnable transformation is attributed to learning more effective representations for anomaly detection. * The CL-TAD method employs a temporal convolutional network (TCN) [47] for temporal feature extraction within time series data. The TCN is used in both positive sample generation and representation learning components. * The proposed method uses a reconstruction-based data augmentation for the normal time series dataset to generate a sufficient amount of training data. On training the model for anomaly detection, it uses only the original data and their augmented data, and hence it is a nonsupervised learning approach that does not require the labeling task over the training data. * To evaluate the effectiveness of our proposed method, we conducted some experiments on the following well-known nine benchmark datasets for time series anomaly detection: Power demand [21; 27], ECG and 2D-Gesture [21; 27], UCR and SMD [43], PSM [42], MSL [43], SWaT [42], and WADI [42]. The performance of the proposed method has been compared with those of 10 recently developed anomaly detection methods: MAD-GAN [32], DAGMM [22], MSCRED [36], CAE-M [28], OmiAnomaly [30], TranAD [42], GDN [29], Anomaly Transformer [42], MTAD-GAT [38], and USAD [39]. The experimental results have demonstrated that the proposed method achieved repetitive performance on all of these datasets. Notably, the proposed method achieved the best performance on the following nine benchmark datasets: Power Demand, UCR, ECG, 2D-Gesture, PSM, SMD, MSL, SWaT, and WADI. The remainder of the paper is organized as follows: Section 2 describes some related works on time series anomaly detection. Section 3 presents the proposed anomaly detection method in detail. In Section 4, we present the experimental results of the proposed method, comparing it with several recent anomaly detection methods using nine benchmark datasets. Finally, Section 5 draws conclusions about the proposed method.