# CL-TAD: A Contrastive-Learning-Based Method for Time Series Anomaly Detection
## 2 Related Works
### Deep-Learning-Based Approaches to Time Series Anomaly Detection  
As illustrated in Figure 1, the existing anomaly detection methods for time series data can be categorized into three primary approaches: one-class-classification-based, reconstruction-based, and prediction-based. One-class-classification-based methods employ a one-class classifier to identify anomalies. These methods define a latent hypersphere, where points falling inside the hypersphere are considered normal, while anomalies reside outside of it. The one-class classifier learns to differentiate between normal and anomalous data points, enabling the detection of anomalies in the time series data. Reconstruction-based methods in time series anomaly detection often leverage the effectiveness of encoder-decoder models or their variants, which have achieved notable successes in solving reconstruction problems in computer vision. These methods aim to reconstruct the input time series data using an encoder-decoder architecture, where the quality of the reconstructed output serves as an indicator of anomalies. That is, the deviations or discrepancies of the input and reconstructed data can be used to identify anomalies, the larger difference, the higher the possibility of anomalies at the corresponding time points. Lastly, prediction-based methods aim to forecast future values by training a predictive model. The predicted values are then compared with the actual values, allowing the identification of anomalies based on the discrepancies between them. By detecting significant deviations between the predicted and actual values, anomalies in the time series can be identified. In both reconstruction-based and prediction-based methods, a predefined threshold, denoted as \(\delta\), is commonly employed to determine whether a specific time point is anomalous. During the inference phase to identify anomaly events, the label \(\hat{y}_{t}\) of a new data point at time step \(t\) is assigned to an anomaly if the corresponding anomaly score \(S(\hat{y}_{t})\) exceeds the threshold \(\delta\), as described in Equation (1). \[\hat{y}_{t}= \begin{cases}1,&\text{if }S(\hat{y}_{t})\geq\delta.\\ 0,&\text{otherwise.}\end{cases}  \tag{1}\]  
where \(\hat{y}_{t}\) represents the label assigned to the \(t\)-th data point, \(S(. )\) quantifies the degree of abnormality or deviation of a data point from the normal patterns, and \(\delta\) is a prespeci-fied threshold. DL-based approaches have significantly pushed up performance levels, yet they still fall short of the benchmark required for deployment in various real-world applications. One key reason for this unsatisfactory performance lies in the scarcity of time series training data. In time series anomaly detection, the quantity of time series data illustrating normal patterns is sometimes insufficient, let alone the severe lack of data representing anomalous events. To tackle the issue of data scarcity, data augmentation techniques have been employed in deep learning, particularly in computer vision tasks. A reconstruction-based approach can leverage a masking technique to augment the training data available for building a reconstruction model. Deep-FIB [21] exemplifies such a method; it trains a reconstruction model using masked time series data. As illustrated in Figure 2, this method utilizes an encoder-decoder model to reconstruct the original time series from its masked series. Once such a model is trained, it is used to reconstruct the given input and then the reconstructed value is compared with its actual input to determine its anomaly. In the reconstruction-based approach, the masking strategy is important in building a model to extract meaningful characteristics for reconstruction. There are two main issues to be considered in the masking strategy: The first issue involves determining the amount of masking portion for input time series. Either overmasking or undermasking can cause a negative effect on the reconstruction capability of the model. Striking the right balance is crucial to ensure high performance.