Feature perception pre-training method and system for time sequence anomaly detection
Through the feature-aware pre-training method, the hierarchical contrastive loss method is used to optimize the convolutional encoder, which solves the problem of poor detection effect of zero-sample time series, achieves high efficiency and accuracy of time series anomaly detection, and is suitable for multi-variable data sets. Generalization ability.
Patent Information
- Application Number
- CN202410749279.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-12
- Publication Date
- 2024-09-27
AI Technical Summary
In the existing technology, when anomaly detection is performed on zero-sample time series, the detection effect is poor, and the model is difficult to migrate from one data set to another, resulting in the need to retrain the model in industrial applications, which increases the cost.
A feature-aware pre-training method is proposed. By obtaining single-dimensional time series data, generating data embedding vectors, and using the hierarchical contrastive loss method to optimize the convolutional encoder, an anomaly detection model is obtained, which can learn the characteristics of time series and improve Detection accuracy and efficiency.
This method can learn the characteristic relationships between data in the absence of label information, improve the accuracy and efficiency of time series anomaly detection, reduce the cost of model migration, and show strong generalization ability on multi-variable data sets.
Smart Images

Figure CN118708932A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data anomaly detection, and in particular to a feature perception pre-training method and system for time series anomaly detection. Background Art
[0002] Currently, anomaly detection aims to find outliers or rare signals in data. It has many applications in the industry and is an important research area in data mining. Enterprises usually collect a set of key data information that monitors the health of various business scenarios and observes them over time to detect unexpected behaviors. This series of data observations arranged in chronological order is called a time series. However, as the complexity and dimensionality of this data grow, enterprises cannot monitor this data manually, which requires methods that can automatically detect anomalies in high-dimensional data in a timely manner.
[0003] Since time series historical data generally lacks information to mark anomalies, the anomaly detection problem is usually regarded as an unsupervised learning problem. In the past few years, researchers have developed many unsupervised methods, which can be mainly divided into two categories: methods based on traditional machine learning and methods based on deep learning. However, these methods are trained from scratch for different downstream tasks. Due to the different characteristics of each time series, such as length, dimension, and distribution, it is difficult for the model to migrate the information trained from one dataset to another. This process is very inconvenient in actual industrial applications, because whenever a new dataset appears, the terminal must train a new model, which may bring heavy training costs to large companies that need to maintain thousands of models.
[0004] In practical industrial applications, there may not be enough data to train a general model, which is a typical zero-shot problem. For example, although the TS2Vec model used in the existing technology can be pre-trained, it has poor detection effect when performing anomaly detection on zero-shot time series. Summary of the invention
[0005] In order to solve the problem that the pre-training model in the prior art has poor detection effect when performing anomaly detection on a time series with zero samples, the present invention proposes a feature-aware pre-training method for time series anomaly detection, comprising:
[0006] Get single-dimensional time series data;
[0007] Generate a data embedding vector according to the one-dimensional time series data and a preset convolution encoder;
[0008] The convolution encoder is pre-trained according to the data embedding vector, and the parameters in the convolution encoder are optimized by using a layered contrast loss method to obtain an anomaly detection model.
[0009] Optionally, generating a data embedding vector according to the one-dimensional time series data and a preset convolution encoder includes:
[0010] Performing high-dimensional feature mapping on the single-dimensional time series data through a fully connected layer to obtain a high-dimensional feature vector;
[0011] Obtaining an embedded representation vector according to the high-dimensional feature vector and the attribute features corresponding to the one-dimensional time series data;
[0012] According to the preset convolutional encoder, obtaining a dimension axis of a hidden layer in the convolutional encoder;
[0013] The embedding representation vectors are concatenated along the dimension axis of the hidden layer to generate a data embedding vector.
[0014] Optionally, obtaining the embedded representation vector according to the attribute features corresponding to the high-dimensional feature vector and the one-dimensional time series data includes:
[0015] Using the attribute features corresponding to the one-dimensional time series data as feature labels;
[0016] Based on a pre-constructed embedding vector space, the feature label is encoded, and the encoded feature label is embedded in the high-dimensional feature vector to obtain an embedded representation vector.
[0017] Optionally, pre-training the convolution encoder according to the data embedding vector, and optimizing the parameters in the convolution encoder by using a layered contrast loss method to obtain an anomaly detection model, including:
[0018] Inputting the data embedding vector as an input item into the convolution encoder to obtain representation information of the data embedding vector at each timestamp;
[0019] Calculating a hierarchical contrast loss function value of the convolution encoder based on representation information of the data embedding vector at each timestamp;
[0020] According to the layered contrast loss function value of the convolutional encoder, the parameters in the convolutional encoder are optimized to obtain an anomaly detection model.
[0021] Optionally, after acquiring the one-dimensional time series data and before generating the data embedding vector according to the one-dimensional time series data and a preset convolution encoder, the method further includes:
[0022] The single-dimensional time series data is standardized by using a z-score to obtain the standardized single-dimensional time series data;
[0023] Performing instance division on the standardized one-dimensional time series data to obtain time instance data of each segment corresponding to the standardized one-dimensional time series data;
[0024] Randomly cutting each time instance data segment into a plurality of subsequence data including overlapping areas;
[0025] The subsequence data corresponding to each segment of time instance data is used as new single-dimensional time series data.
[0026] Optionally, after optimizing the parameters in the convolution encoder by using a layered contrast loss method to obtain an anomaly detection model, the method further includes:
[0027] Get a multidimensional time series dataset;
[0028] Performing data preprocessing on the multidimensional time series data set to obtain a preprocessed multidimensional time series data set;
[0029] Generate a corresponding data embedding vector according to the preprocessed multidimensional time series data set;
[0030] Based on the data embedding vector corresponding to the multidimensional time series data set, using the anomaly detection model, obtaining an anomaly detection result corresponding to the multidimensional time series data set;
[0031] According to the anomaly detection result, using a preset maximum pooling encoder, output a final representation vector corresponding to the anomaly detection result;
[0032] According to the final characterization vector corresponding to the anomaly detection result, an anomaly score of the final characterization vector corresponding to the anomaly detection result is calculated.
[0033] Optionally, performing data preprocessing on the multidimensional time series data set to obtain a preprocessed multidimensional time series data set includes:
[0034] Standardizing the multidimensional time series data set using a z score to obtain a standardized multidimensional time series data set;
[0035] Performing variable division on the standardized multidimensional time series data set to obtain a univariate data set and a multivariate data set corresponding to the standardized multidimensional time series data set;
[0036] Performing feature dimensionality reduction on the multivariate data set using principal component analysis to obtain a reduced-dimensional feature data set;
[0037] The univariate data set and the dimension-reduced feature data set are used as a preprocessed multidimensional time series data set.
[0038] Optionally, the obtaining, based on the data embedding vector corresponding to the multidimensional time series data set and using the anomaly detection model, an anomaly detection result corresponding to the multidimensional time series data set includes:
[0039] Inputting the univariate data set into the anomaly detection model to obtain an anomaly detection result corresponding to the univariate data set;
[0040] The time series corresponding to each variable in the dimension reduction feature data set is taken as a univariate time series and respectively input into the anomaly detection model to obtain an anomaly detection result corresponding to each univariate time series.
[0041] Optionally, the multidimensional time series dataset includes one or more of the following: a safe water treatment dataset, a water distribution dataset, a network intrusion dataset, a soil moisture active and passive satellite dataset, and a Mars Science Laboratory rover dataset.
[0042] Based on the same inventive concept, the present invention also provides a feature perception pre-training system for time series anomaly detection, comprising:
[0043] Data acquisition module: used to obtain single-dimensional time series data;
[0044] Feature perception module: used to generate a data embedding vector according to the one-dimensional time series data and a pre-set convolution encoder;
[0045] Pre-training module: used to pre-train the convolution encoder according to the data embedding vector, and optimize the parameters in the convolution encoder by using a layered contrast loss method to obtain an anomaly detection model.
[0046] Optionally, the feature perception module is specifically used to:
[0047] Performing high-dimensional feature mapping on the single-dimensional time series data through a fully connected layer to obtain a high-dimensional feature vector;
[0048] Obtaining an embedded representation vector according to the high-dimensional feature vector and the attribute features corresponding to the one-dimensional time series data;
[0049] According to the preset convolutional encoder, obtaining a dimension axis of a hidden layer in the convolutional encoder;
[0050] The embedding representation vectors are concatenated along the dimension axis of the hidden layer to generate a data embedding vector.
[0051] Optionally, the feature perception module obtains an embedded representation vector according to the high-dimensional feature vector and the attribute features corresponding to the one-dimensional time series data, including:
[0052] Using the attribute features corresponding to the one-dimensional time series data as feature labels;
[0053] Based on a pre-constructed embedding vector space, the feature label is encoded, and the encoded feature label is embedded in the high-dimensional feature vector to obtain an embedded representation vector.
[0054] Optionally, the pre-training module is specifically used for:
[0055] Inputting the data embedding vector as an input item into the convolution encoder to obtain representation information of the data embedding vector at each timestamp;
[0056] Calculating a hierarchical contrast loss function value of the convolution encoder based on representation information of the data embedding vector at each timestamp;
[0057] According to the layered contrast loss function value of the convolutional encoder, the parameters in the convolutional encoder are optimized to obtain an anomaly detection model.
[0058] Optionally, after acquiring the single-dimensional time series data, the data acquisition module further includes:
[0059] The single-dimensional time series data is standardized by using a z-score to obtain the standardized single-dimensional time series data;
[0060] Performing instance division on the standardized one-dimensional time series data to obtain time instance data of each segment corresponding to the standardized one-dimensional time series data;
[0061] Randomly cutting each time instance data segment into a plurality of subsequence data including overlapping areas;
[0062] The subsequence data corresponding to each segment of time instance data is used as new single-dimensional time series data.
[0063] Optionally, after the pre-training module optimizes the parameters in the convolution encoder using a layered contrast loss method to obtain an anomaly detection model, the method further includes:
[0064] Get a multidimensional time series dataset;
[0065] Performing data preprocessing on the multidimensional time series data set to obtain a preprocessed multidimensional time series data set;
[0066] Generate a corresponding data embedding vector according to the preprocessed multidimensional time series data set;
[0067] Based on the data embedding vector corresponding to the multidimensional time series data set, using the anomaly detection model, obtaining an anomaly detection result corresponding to the multidimensional time series data set;
[0068] According to the anomaly detection result, using a preset maximum pooling encoder, output a final representation vector corresponding to the anomaly detection result;
[0069] According to the final characterization vector corresponding to the anomaly detection result, an anomaly score of the final characterization vector corresponding to the anomaly detection result is calculated.
[0070] Optionally, the pre-training module performs data preprocessing on the multidimensional time series data set to obtain a preprocessed multidimensional time series data set, including:
[0071] Standardizing the multidimensional time series data set using a z score to obtain a standardized multidimensional time series data set;
[0072] Performing variable division on the standardized multidimensional time series data set to obtain a univariate data set and a multivariate data set corresponding to the standardized multidimensional time series data set;
[0073] Performing feature dimensionality reduction on the multivariate data set using principal component analysis to obtain a reduced-dimensional feature data set;
[0074] The univariate data set and the dimension-reduced feature data set are used as a preprocessed multidimensional time series data set.
[0075] Optionally, the pre-training module uses the anomaly detection model based on the data embedding vector corresponding to the multidimensional time series data set to obtain an anomaly detection result corresponding to the multidimensional time series data set, including:
[0076] Inputting the univariate data set into the anomaly detection model to obtain an anomaly detection result corresponding to the univariate data set;
[0077] The time series corresponding to each variable in the dimension reduction feature data set is taken as a univariate time series and respectively input into the anomaly detection model to obtain an anomaly detection result corresponding to each univariate time series.
[0078] Optionally, the multidimensional time series dataset in the pre-training module includes one or more of the following: a safe water treatment dataset, a water distribution dataset, a network intrusion dataset, a soil moisture active and passive satellite dataset, and a Mars Science Laboratory rover dataset.
[0079] Compared with the prior art, the present invention has the following beneficial effects:
[0080] The present invention provides a feature perception pre-training method and system for time series anomaly detection, comprising: acquiring single-dimensional time series data; generating a data embedding vector according to the single-dimensional time series data and a pre-set convolutional encoder; pre-training the convolutional encoder according to the data embedding vector, and optimizing the parameters in the convolutional encoder by using a layered contrast loss method to obtain an anomaly detection model; the present application can perceive the features in the time series data by generating a data embedding vector according to the single-dimensional time series data and a pre-set convolutional encoder, pre-training the convolutional encoder by using a data embedding vector containing the features, and optimizing the parameters by using a contrastive learning method, not only considering the similarity between samples, but also enabling the model to learn the feature priors of the time series data, which helps the model learn a more robust feature representation, and is beneficial to improving the accuracy and efficiency of anomaly detection of the time series. BRIEF DESCRIPTION OF THE DRAWINGS
[0081] Figure 1 A schematic diagram of a flow chart of a feature perception pre-training method for time series anomaly detection provided by the present invention;
[0082] Figure 2 A schematic diagram of the F1 score distribution of a TS2Vec model pre-trained using Yahoo and KPI as data sets in a feature-aware pre-training method for time series anomaly detection provided by the present invention;
[0083] Figure 3 A schematic diagram of an algorithm flow of a hierarchical contrast loss method used in a feature perception pre-training method for time series anomaly detection provided by the present invention;
[0084] Figure 4 A schematic diagram of a flow chart of a feature perception pre-training method for time series anomaly detection provided by the present invention;
[0085] Figure 5 A schematic diagram of the structural composition of a feature perception pre-training system for time series anomaly detection provided by the present invention;
[0086] Figure 6 The present invention provides a schematic structural diagram of an electronic device. DETAILED DESCRIPTION
[0087] The present invention proposes a feature perception pre-training method and system for time series anomaly detection. The specific implementation methods of the present invention are further described in detail below in conjunction with the accompanying drawings.
[0088] Embodiment 1:
[0089] A feature-aware pre-training method for time series anomaly detection, the flow chart is as follows Figure 1 As shown, including:
[0090] Step 1: Obtain single-dimensional time series data;
[0091] Step 2: Generate a data embedding vector based on the one-dimensional time series data and the pre-set convolutional encoder;
[0092] Step 3: According to the data embedding vector, the convolution encoder is pre-trained, and the layered contrast loss method is used to optimize the parameters in the convolution encoder to obtain the anomaly detection model.
[0093] Generally, anomaly detection for time series is an important research field in data mining, especially in the industrial world, where there are many applications. By collecting a set of key data information that monitors the health status of various business scenarios and observing them over time, abnormal behavior can be detected. This type of data observation value arranged in chronological order is called time series data. Time series data can usually include single-dimensional time series data and multi-dimensional time series data. Since time series data generally lacks information to mark anomalies, anomaly detection based on time series data is usually regarded as an unsupervised learning problem. Since the characteristics of each time series data are different, such as length, dimension and distribution, it is difficult for the model to transfer the information obtained from one data set to another during pre-training. In actual industrial applications, there may not be enough data to train a general model. This scenario forms a typical zero-sample problem.
[0094] In order to solve the zero-sample problem, the present invention uses a large amount of unlabeled single-dimensional time series data as a pre-training data set to learn the universal representation of time series, so that when the pre-training model is trained, the characteristic relationship between the data can be learned even if there is no label information in the pre-training data set. In order to better express the relationship between the data, the present invention uses a single-dimensional time series to represent a single-variable data set, and uses multi-dimensional time series data to represent a multi-variable data set. In order to improve the performance of the pre-training model, the pre-training data set selected by the present invention contains more than 100 million timestamps with different lengths and different sampling granularities, which are used to test the effect of anomaly detection applied to a variety of different feature data to detect anomalies.
[0095] For example, the univariate datasets that can be selected may include: Yahoo dataset, KPI dataset, UCI vehicle sensor dataset, MIT-BIH dataset and SMD dataset; among them, the Yahoo dataset is a benchmark dataset for anomaly detection, consisting of 367 time series sampled every hour with marked anomalies; the KPI dataset is a competition dataset released by AIOPSChallenge, which contains multiple finely sampled real KPI curves from many Internet companies; the UCI vehicle sensor dataset contains data collected from various vehicle sensors, and the time series data of a single sensor (such as engine speed, vehicle speed, etc.) can be selected for analysis to identify potential vehicle failures or abnormal behaviors; the MIT-BIH dataset is an electrocardiogram dataset, which provides a large amount of physiological signal data, especially electrocardiogram (ECG) data, and can extract the time series of a single lead electrocardiogram for arrhythmia and other anomaly detection research; the SMD dataset is an anomaly detection dataset derived from the HDFS (Hadoop Distributed File System) server, which contains indicators such as CPU usage and disk read and write rates of multiple servers, and can be used to study anomaly detection problems in IT operation and maintenance.
[0096] For example, the multivariate datasets that can be selected may include: the Safe Water Treatment (SWaT) dataset, the Water Distribution (WADI) dataset, the network intrusion (e.g., KDDCup99) dataset, the Soil Moisture Active Passive Satellite (SMAP) dataset, and the Mars Science Laboratory Rover (MSL) dataset; the Safe Water Treatment (SWaT) dataset comes from the water treatment testbed coordinated by the Singapore Public Utilities Board, including 11 days of continuous operation: 7 days collected under normal operation and 4 days collected under attack scenarios. As an extension of SWaT, the Water Distribution (WADI) dataset is a water distribution system composed of a large number of water distribution pipes, so that the Water Distribution (WADI) forms a more complete and realistic water treatment, storage, and distribution network. The dataset contains two weeks of normal operation data and two days of attack scenario data. The KDDCup99 dataset is a network intrusion dataset, which consists of two types of records: normal network activities and various attack behaviors. The attack types include denial of service attacks, remote login attacks, buffer overflow attacks, and many other types. The Soil Moisture Satellite Active Passive (SMAP) dataset and the Mars Science Laboratory Rover (MSL) dataset are real-world spacecraft datasets from NASA with expert labels;
[0097] The time series length corresponding to the above-mentioned univariate data set or multivariate data set generally ranges from 98 to 23737, and the sampling interval covers minute, hour and day granularity. Therefore, the present invention can embed fully trained feature labels (C-tags) into the data by selecting the above-mentioned univariate data set or multivariate data set with diversity as the pre-training data set, and the model pre-trained according to the above-mentioned data set can always transfer the pre-trained feature perception knowledge when facing any unknown test data.
[0098] Time series data often contain complex structures and patterns, such as periodicity, trends, seasonality, etc. Feature perception can identify and utilize these features to more accurately distinguish normal fluctuations from truly abnormal features. Therefore, obtaining different features of time series is very important for the accuracy and efficiency of anomaly detection. The following example discusses the impact of different features of time series on anomaly detection: First, collect data sets: randomly sample 25% of the data from the above-mentioned univariate data sets or multivariate data sets as unlabeled pre-training data sets. According to the two basic characteristics of time series, namely length and sampling granularity, the collected data sets are divided into subsets of similar sizes, and a TS2Vec model is pre-trained on each subset. The model learns a common representation of time series and applies it to the KPI data set and the Yahoo data set for anomaly detection. The corresponding F1 score for anomaly detection is shown below. Figure 2 As shown in the figure, when the pre-training datasets have different characteristics, a huge gap can be observed on the two datasets: the maximum difference in F1 scores on the KPI dataset can exceed 12%. Therefore, for the KPI dataset, longer pre-training time series provide more benefits, while the Yahoo dataset needs to extract information from shorter time series. It can be seen from the figure that different sampling granularities also show different effects on the two datasets. Therefore, for time series, sampling granularity also plays a crucial role in the performance of these two models.
[0099] The above results show that the performance of the pre-trained model can be further improved by using a suitable pre-training dataset. However, there is usually no information about the test dataset in the pre-training stage, so it is impossible to select suitable data in advance. When further studying the commonalities between the pre-training datasets that achieve gain and the KPI dataset, it is noted that the higher the similarity of the intrinsic features (such as length and sampling granularity), the greater the performance improvement of the pre-trained model. The pre-trained model pre-trained on time series with a length of more than 2000 achieves better performance on the KPI dataset, while the length of the time series in KPI exceeds 3000. In addition, the sampling granularity of the KPI dataset is also closer to hourly. For the Yahoo dataset, sampling is performed once an hour with an average length of 1560. It can also be found that pre-trained data with similar length and sampling interval are more conducive to detecting its anomalies. Inspired by this example, the present invention uses a characterization method that fuses feature information to achieve model pre-training by using these prior feature knowledge in the anomaly detection task to match different time series data features, which is conducive to improving the accuracy and efficiency of anomaly detection.
[0100] For example, the technical problem to be solved by the present invention can be defined as: let the pre-training dataset X∈RT′×V; T′ represents the input time series of T′ variables, for example, for a univariate time series, V=1; V represents the input time series of V variables; R represents the number of timestamps. The i-th variable of the pre-training dataset X is represented as a column vector in, Represents the first data point of the i-th variable of the pre-training dataset X; represents the Lnth data point of the i-th variable of the pre-training dataset X; Ln represents the total number of data points of the i-th variable of the pre-training dataset X; T represents transposition. If there is a too long time series in the pre-training dataset, it will be split into Segments, where max_l is the maximum length allowed by the model. Anomaly detection works by assigning a binary label (0 for normal and 1 for anomaly) to each timestamp of the test data.
[0101] When the present invention pre-trains the anomaly detection model, single-dimensional time series data is preferentially selected as the pre-training data set. If the pre-training data set is multi-dimensional time series data, each dimension in the multi-dimensional time series data needs to be pre-trained as a single variable. Taking meteorological time series data as an example, when training the pre-training model, variables such as temperature and humidity need to be first used as single variables and then participate in model pre-training.
[0102] After obtaining the one-dimensional time series data in step 1 above, it is also necessary to perform data preprocessing on the one-dimensional time series data. The specific process may include:
[0103] The z-score is used to standardize the single-dimensional time series data to obtain the standardized single-dimensional time series data;
[0104] Perform instance division on the standardized single-dimensional time series data to obtain time instance data corresponding to each segment of the standardized single-dimensional time series data;
[0105] Randomly cut each time instance data into multiple subsequence data containing overlapping areas;
[0106] The subsequence data corresponding to each time instance data segment is used as the new single-dimensional time series data;
[0107] When the present invention performs data preprocessing on a one-dimensional time series, the original data is standardized using z scores, and all variables are converted to the same scale, which can eliminate the impact of different dimensions or scales between data, and can more easily identify patterns, trends and outliers in the data; by taking a time period with a specific length as an example, two overlapping subsequences are randomly cropped to generate common segments with contextual consistency; overlapping subsequences can help the model learn local dependencies within the sequence and contextual connections between adjacent segments, thereby enhancing the model's ability to understand and predict complex patterns in time series data.
[0108] In one implementation, the process of generating a data embedding vector according to the one-dimensional time series data and a preset convolution encoder in the above step 2 may include:
[0109] The single-dimensional time series data is mapped to high-dimensional features through a fully connected layer to obtain a high-dimensional feature vector;
[0110] According to the attribute features corresponding to the high-dimensional feature vector and the one-dimensional time series data, an embedded representation vector is obtained;
[0111] According to the preset convolutional encoder, the dimension axis of the hidden layer in the convolutional encoder is obtained;
[0112] The embedding representation vectors are concatenated along the dimension axis of the hidden layer to generate the data embedding vector.
[0113] In this implementation, the process of obtaining the embedded representation vector according to the attribute features corresponding to the high-dimensional feature vector and the one-dimensional time series data may include:
[0114] The attribute features corresponding to the single-dimensional time series data are used as feature labels;
[0115] Based on the pre-constructed embedding vector space, the feature labels are encoded and the encoded feature labels are embedded into the high-dimensional feature vector to obtain the embedded representation vector;
[0116] In the prior art, the data embedding vector is generally obtained by mapping the time series data through a fully connected layer, but this method easily ignores the time structure information. The fully connected layer does not consider the time order of the input data. It only performs independent weighted summation of the features of each time point of the input through a weight matrix. Therefore, this method may lose important time dependencies and dynamic patterns in the time series, which are crucial for tasks such as prediction and sequence classification. In addition, if a fully connected layer is used directly for long sequence data, a large number of weight parameters may be required to process all features at each time point, which will cause the model to become very large, not only occupying a large amount of memory, but also may cause overfitting problems. In order to overcome the above problems, the present invention uses different features of each time series to enhance the embedding representation vector, and splices all the representation vectors along the hidden layer dimension axis to obtain a complete time series embedding and generate a data embedding vector. By designing a separate embedding process for the specific features of each time series, the patterns and structures in the data can be captured more finely. Different features may carry information about different aspects of the time series (such as trends, periodicity, seasonality, etc.). Such processing can better retain and highlight this information and improve the model's ability to understand complex patterns. And because the embedding of each feature is learned independently, the model can more flexibly identify and utilize the interactions and independent influences between different features, which helps to obtain better generalization performance on new data sets. After the feature embedding vectors are concatenated in the hidden layer, the model has the opportunity to learn the complex interactions between different features, which is particularly important for capturing nonlinear relationships and patterns, especially in scenarios involving time series behaviors that are jointly influenced by multiple factors. Therefore, the method of the present invention generates data embedding vectors by enhancing the representation at the feature level, which can promote a deeper understanding and analysis of time series data and help improve the performance and application effect of the pre-trained model.
[0117] In one implementation, in the above step 3, the convolution encoder is pre-trained according to the data embedding vector, and the parameters in the convolution encoder are optimized by using the layered contrast loss method. The process of obtaining the anomaly detection model may include:
[0118] The data embedding vector is input as an input item to the convolution encoder to obtain the representation information of the data embedding vector at each timestamp;
[0119] Based on the representation information of the data embedding vector at each timestamp, the layered contrast loss function value of the convolution encoder is calculated;
[0120] According to the layered contrast loss function value of the convolutional encoder, the parameters in the convolutional encoder are optimized to obtain the anomaly detection model.
[0121] For example, the above convolution encoder can be composed of N one-dimensional dilated convolution blocks with residual connections. Each block contains two convolution layers with the same receptive field. The dilated convolution can not only achieve universality in length, but also capture rich information by exponentially increasing the receptive field of the network.
[0122] In this implementation, data embedding vectors are incorporated into the model to promote knowledge transfer between similar data distributions, and its capabilities are further demonstrated through large-scale pre-training. Extensive experiments are also conducted on multiple datasets to demonstrate the effectiveness of the learned invention in anomaly detection.
[0123] In the prior art, data is generally represented in a universal manner by adopting the context consistency strategy of TS2Vec. However, this method creates positive and negative sample pairs in different time windows for self-supervised learning, which may involve a lot of computation and memory consumption, especially on long sequences or high-dimensional data. In order to solve the above problems, the present invention can extract the context representation of each timestamp by inputting the data embedding vector into the convolutional encoder, and optimize the parameters in the convolutional encoder by the hierarchical contrast loss method. This method generates multi-granularity and multi-dimensional contrast losses by multiple maximum pooling operations and layer-by-layer joint use of contrast information in the two dimensions of instance and time. This means that at different levels of the encoder, features will focus on different abstract levels of data, from low-level edges and textures to high-level shapes and structures. Such a hierarchical structure helps to build a richer and more semantic representation, and is conducive to reducing computation and memory consumption, and is more suitable for long sequences or high-dimensional data. The core of the hierarchical contrast loss is to maximize the similarity between similar sample pairs while minimizing the distance between different sample pairs. When it is applied to the convolutional encoder, it can prompt the model to learn more discriminative features and improve performance in classification, clustering or retrieval tasks. Since the pre-training data set in the present invention contains a large amount of unlabeled information, the use of hierarchical contrast loss in the convolutional encoder can optimize the model parameters by mining the intrinsic similarities and differences of the data in the absence of labeled data. Therefore, the present invention optimizes the parameters of the convolutional encoder by adopting the hierarchical contrast loss method, which can not only enhance the hierarchy and discrimination of the features, but also improve the generalization ability of the model, so that the model exhibits strong performance in various tasks, especially in data representation learning.
[0124] By comparing the context consistency strategy of TS2Vec used in the prior art with the hierarchical contrast loss method of the present invention, it can be found that: TS2Vec performs self-supervised learning by creating positive and negative sample pairs in different time windows, which may involve a lot of calculation and memory consumption, especially on long sequences or high-dimensional data. In contrast, the hierarchical contrast loss is designed to efficiently process large-scale data sets and deep feature representations, reducing the computational burden through a hierarchical structure. Secondly, the hierarchical contrast loss can more finely control the granularity of contrastive learning by constructing a multi-level contrast framework, thereby capturing the structural characteristics of data at different scales, which may make it more flexible and effective when processing data with complex hierarchical structures, while the context strategy of TS2Vec may appear to be relatively simple in these scenarios. Although the context consistency strategy is intended to improve robustness, in practical applications, if the time series data contains a lot of noise or outliers, over-reliance on local context may cause the model to learn the wrong pattern. Hierarchical contrast loss may alleviate the impact of noise to a certain extent by comparing samples across different levels, because it encourages the model to learn invariant features across a wider context. Finally, hierarchical contrast loss directly maximizes information entropy or minimizes the distance between similar samples by comparing representations at different levels. The objective function is clear and targeted; while the optimization goal of TS2Vec's contextual consistency strategy may sometimes require more parameter adjustments to achieve optimal performance. The present invention calculates the hierarchical contrast loss function value (Calculating the hierarchical contrasitive loss) based on common fragments for the pre-trained convolutional encoder. The loss generates multi-granularity and multi-dimensional contrast losses through multiple maximum pooling operations and layer-by-layer joint use of contrast information in both instance and time dimensions.
[0125] Among them, the contrast loss function value represented by each time series data = the loss of multiple rounds of pooling (including the sum of instance loss and time loss) / the number of pooling times. The algorithm flow of hierarchical contrast loss is as follows Figure 3 As shown, the specific steps include:
[0126] 1: The procedure accepts two input parameters r and r′, and the contrast loss is expressed as HIERLOSS(r,r′);
[0127] 2: Initialize a variable L hier For L dual (r, r′);
[0128] 3: Set a counter d to 1;
[0129] 4: Perform the following operations when the time length (time_length) of the input parameter r is greater than 1;
[0130] 5: Use the maxpool1d function to downsample along the time axis;
[0131] 6: The kernel size (kernel_size) is 2, and the result r after the maximum pooling is assigned to r;
[0132] 7: The kernel size (kernel_size) is 2, and the result r′ after the maximum pooling is assigned to r′;
[0133] 8: Change the current L hier With the new L dual (r, r′) and reassign the result to L hier ;
[0134] 9: Add 1 to the value of counter d;
[0135] 10: The loop ends;
[0136] 11: L hier Divide by d and return the final L hier ;
[0137] 12: L hier As a result of calculation;
[0138] 13: Program execution ends.
[0139] The main purpose of the present invention by adopting the hierarchical contrast loss method is to construct different levels of contrast losses by gradually reducing the time resolution of the input parameter r, and accumulate these losses, and finally adjust the accumulated total loss according to the number of iterations, that is, the value of the counter d, which helps to capture patterns in sequence data at different time scales.
[0140] After obtaining the anomaly detection model as described above, it is usually necessary to evaluate the performance of the model. For example, the present invention can select one or more of the following evaluation indicators to evaluate the anomaly detection performance of the model: standard indicator, precision (Prec), recall rate (Rec) or F1 score. Evaluating the model by the above evaluation indicators can ensure that the pre-trained model is neither overly sensitive nor overly conservative, and can promote the optimization, selection and continuous monitoring of the model, which is crucial to ensuring the security and stability of the system.
[0141] In one implementation, after the above-mentioned embedding representation vector is obtained based on the attribute features corresponding to the high-dimensional feature vector and the one-dimensional time series data, and the parameters in the convolution encoder are optimized using the layered contrast loss method to obtain the anomaly detection model, the following may also be included:
[0142] Get a multidimensional time series dataset;
[0143] Data preprocessing is performed on a multidimensional time series data set to obtain a preprocessed multidimensional time series data set; the data preprocessing method in the present invention is performed by calculating the z-score of the normalized zero mean and unit variance of the univariate time series data, and the z-score adopted is a standardized method based on statistical theory, which can intuitively reflect the degree of deviation of each data point relative to the overall mean, especially in the field of anomaly detection, by using the z-score to perform data preprocessing on the data set, data of different scales and distributions can be converted to the same dimension and distribution form, which is convenient for comparison across features or across data sets, which is particularly important for multivariate anomaly detection.
[0144] Generate the corresponding data embedding vector according to the preprocessed multidimensional time series data set;
[0145] Based on the data embedding vector corresponding to the multidimensional time series data set, the anomaly detection detection model is used to obtain the anomaly detection results corresponding to the multidimensional time series data set;
[0146] According to the anomaly detection results, the preset maximum pooling encoder is used to output the final representation vector corresponding to the anomaly detection results;
[0147] According to the final characterization vector corresponding to the anomaly detection result, the anomaly score of the final characterization vector corresponding to the anomaly detection result is calculated.
[0148] By pre-training the convolution encoder with single-dimensional time series data to obtain an anomaly detection model, it is necessary to verify whether the anomaly detection model can migrate the information obtained from a single-variable data set training to a new multivariate data set. Therefore, in this implementation, the present invention inputs the multidimensional time series data into the pre-trained anomaly detection model, and determines whether the anomaly detection result is accurate by calculating the anomaly score corresponding to the anomaly detection result.
[0149] In this implementation, the above-mentioned method generates the corresponding data embedding vector based on the preprocessed multidimensional time series dataset, and uses the different features of each time series to enrich the embedding representation vector, and splices the representation vector along the hidden dimension axis to obtain a complete time series embedding, thereby generating a data embedding vector; that is, the generation process of the data embedding vector consists of the combined splicing of input mapping, feature embedding and embedding vector. Since the input data of the anomaly detection dataset may have multiple variables, in order to make our model universal, we design the pre-trained model input method to split the multivariate into multiple univariate time series and input them sequentially:
[0150] (1) Input mapping: Multidimensional time series data is mapped to a higher dimension through a fully connected layer, and its corresponding output is represented by fc_emb (fully connected layer embeddings, fc_emb);
[0151] (2) Feature embedding: It is beneficial to use data with similar features to the test data to pre-train the model. Inspired by this, the present invention uses feature label embedding, utilizes the essential features of each time series as different feature labels and calculates the corresponding embedded representation. For example, the essential features of the time series can be: original length, cropped length and sampling granularity of each instance. Among them, the above-mentioned cropped length refers to the length of the input data after random cropping, which is part of the unsupervised training strategy; the present invention encodes each feature label by constructing an embedding vector space. For the original length and the cropped length, the length range of the time series is (0, +∞), which is the full set. On this basis, we set a length range partitioning method and regard the partitioning method as a set of partition keys. In mathematical representation, each subinterval of the partition is defined as: Li∈(li,li+1]; Li then serves as the key value of the encoding embedding vector, where li represents a pre-set integer; Li represents the partitioned subinterval. For example, if the original length of the time series is l, then if l∈Li, the key value is Li, where Li is one of the elements of the partition set. There are only three partition keys for the time granularity, including every minute, every hour, and every day. For specific input data, the feature label embedding of each feature depends on which partition key the feature is mapped to.
[0152] (3) Combination and concatenation of embedding vectors: The feature label represents the essential characteristics of the entire instance and should be equally conveyed to each timestamp. Therefore, for each timestamp, based on fc_emb, each feature label is concatenated along the hidden dimension axis of fc_emb. The final embedding vector can be expressed as: Among them, Xsgt_emb, Xolt_emb and Xclt_emb represent the feature tags of embedded sampling granularity (sgt), original length (olt) and cropped length (clt), respectively, and the mapping dimensions of the three feature tags are consistent.
[0153] In this implementation, the process of performing data preprocessing on the multidimensional time series data set to obtain the preprocessed multidimensional time series data set may include:
[0154] Use z-score to standardize the multidimensional time series data set to obtain a standardized multidimensional time series data set;
[0155] Perform variable division on the standardized multidimensional time series data set to obtain the corresponding univariate data set and multivariate data set in the standardized multidimensional time series data set;
[0156] The principal component analysis method is used to reduce the dimension of multivariate data sets to obtain the reduced dimension feature data sets;
[0157] The univariate data set and the dimension-reduced feature data set are used as the preprocessed multidimensional time series data set. In this implementation, the computational load can be reduced by using the principal component analysis method on the multivariate data set.
[0158] In one implementation, the process of obtaining an anomaly detection result corresponding to the multidimensional time series data set by using an anomaly detection model based on the data embedding vector corresponding to the multidimensional time series data set may include:
[0159] Input the univariate data set into the anomaly detection model to obtain the anomaly detection result corresponding to the univariate data set;
[0160] The time series corresponding to each variable in the dimension reduction feature data set is taken as a univariate time series and input into the anomaly detection model respectively to obtain the anomaly detection result corresponding to each univariate time series.
[0161] According to the above discussion, the present invention uses a univariate data set as a pre-training data set to pre-train the convolution encoder to obtain an anomaly detection model, and applies the anomaly detection model to a multivariate data set, effectively migrating prior knowledge to different business scenarios. Therefore, the method of the present invention can process time series data of various lengths and dimensions and has generalization across data sets. That is to say, the pre-training process of the present invention for time series can include a pre-training stage and an inference stage, and the implementation process is as follows Figure 4 As shown in the figure, FC represents the fully connected layer, SG C-tags represents the sampling granularity feature label, OL C-tags represents the original length feature label, and CL C-tags represents the cropped length feature label;
[0162] The pre-training phase includes four steps: data pre-processing, data embedding vector generation, encoder, and contrast loss optimization, specifically:
[0163] S1. Data preprocessing: Preprocess the time series input data, standardize the raw data using z-scores, and randomly crop two overlapping subsequences for each instance to generate context-consistent common segments;
[0164] S2, data embedding vector generation: use the different features of each time series to enhance the embedding representation vector, and splice all the representation vectors along the hidden layer dimension axis to obtain the complete time series embedding and generate the data embedding vector;
[0165] S3, encoder: input the embedding vector in S2 into the convolutional encoder to extract the context representation of each timestamp;
[0166] S4, contrast loss optimization: Use the convolutional encoder in S3 to optimize through layered contrast loss. Use the convolutional encoder in S3 to optimize through layered contrast loss. This loss generates multi-granular and multi-dimensional contrast loss through multiple maximum pooling operations and layer-by-layer joint use of contrast information in both instance and time dimensions;
[0167] The inference phase includes six steps: data preprocessing, principal component analysis (PCA), data embedding vector generation, encoder, pooling layer, and anomaly score calculation. Specifically,
[0168] a. Standardize the raw data using z-scores;
[0169] b. For multivariate data sets (when dimension ≥ n, n is a positive integer), PCA is used to reduce the computational load (reducing the dimension to n, n can be set to 5 in specific experiments);
[0170] c. Use the different features of each time series to enrich the embedding representation vector, and concatenate the representation vectors along the hidden dimension axis to obtain the complete time series embedding and generate the data embedding vector;
[0171] d. After obtaining the data embedding vector in step c, the univariate dataset is input into the pre-trained encoder to encode it, and each variable in the multivariate dataset is regarded as a univariate time series and encoded separately;
[0172] e. Use the maximum pooling encoder to output the final representation vector;
[0173] f. Calculate the anomaly score according to the anomaly score definition.
[0174] By implementing anomaly detection for multidimensional time series data in the inference phase:
[0175] First, the pre-trained model encodes the input time series into a timestamp-level representation vector through a forward pass. For univariate datasets, encoding can be done directly because the pre-training data are all univariate. For multivariate datasets, principal component analysis (PCA) is applied to reduce the number of variables to a predefined dimension k. Then, the pre-trained model encodes each component in the k-dimensional time series. Max pooling is applied along the variable dimension to obtain the final representation: O∈RT′×E; where O represents the final representation of the component after max pooling; T′ represents the input time series of length T′ variables, E is the encoding dimension of the encoder; R represents the number of timestamps.
[0176] Define the anomaly score (that is, define how to calculate the score of each point. If this point is masked, mask means partial masking, and the resulting representation is very different from that without mask, then it is very likely to be an anomaly point). It is calculated based on the difference between the representations of the partially masked (masked) and unmasked inputs calculated by the model. Let Ont represent the encoded representation of the input at timestamp t that is not partially masked, and Omt represent the encoded representation of the input after timestamp t is partially masked. Then define the anomaly score st at timestamp t as st=||maxpool(Ont)-maxpool(Omt)||1, which is the L1 norm value after the maximum pooling of the two representations; maxpool() represents the maximum pooling function. This definition method of the anomaly score is based on the sensitivity of the input data points to changes in the model representation space. Its core idea is to identify anomalies by comparing the differences between the original input and the partially masked (masked) input in the deep representation of the model. Specifically, the method can be explained as follows:
[0177] 1. Masking of input data: First, for each data point in the input data (which can be a time point in a time series, a pixel in an image, or a word in a text), create a masked version of the data. Masking can be achieved by replacing the value of the point with 0, the average value, a specific mask symbol, or using other strategies, in order to simulate a scenario where the point does not exist or the information is missing.
[0178] 2. Two forward propagation of the model:
[0179] First pass: the original unmasked input data is fed into the model, and the model (such as a deep neural network) processes it.
[0180] We get a deep feature representation or characterization, which we call the original representation.
[0181] Second pass: Feed the masked input data into the same model to get a deep feature representation again, which we call the masked representation.
[0182] 3. Calculate the representation difference: Compare the difference between the original representation and the masked representation. The difference can be the Euclidean distance between the two, the negative value of cosine similarity, the L1 norm, or any other measure of the difference between vectors. If masking a point causes a significant change in the representation, it means that the point contributes a lot to the model's representation, and removing it affects the model's overall understanding of the input.
[0183] 4. Define anomaly score: This difference measurement value is the anomaly score of the data point. In theory, the higher the anomaly score, the greater the change in the model representation after masking the point, and the more likely the point is an anomaly in the data.
[0184] In addition, in order to avoid data drift, the present invention also Adjust the anomaly score, where is the average anomaly score of R timestamps before adjustment; st represents the current anomaly score; sadjt represents the adjusted anomaly score. Finally, the mean μ and standard deviation σ of the adjusted anomaly scores in the training set are used to determine the threshold θ = μ + λσ, where λ is a hyperparameter. When st exceeds θ, it can be inferred that timestamp t is abnormal, otherwise it is normal.
[0185] Aiming at the problem that the pre-trained model in the prior art has poor detection effect when performing anomaly detection on zero-sample time series, inspired by the existing pre-training methods in the fields of natural language processing, the present invention proposes a feature-aware pre-training method for time series anomaly detection, which uses a large amount of unlabeled univariate data as a pre-training data set to learn the general representation of time series, embeds key features in the representation vector space, and uses a contrastive learning method for unsupervised pre-training, so that the model can learn the feature priors of time series data, providing a general representation method for anomaly detection tasks. The pre-trained model obtained by the method of the present invention has the ability of zero-sample learning, and does not need to be retrained or fine-tuned on different downstream tasks. The model can be directly applied to new multivariate data sets, can effectively transfer prior knowledge to different business scenarios, process time series data of various lengths and dimensions, and has generalization across data sets, which is conducive to improving the accuracy and efficiency of anomaly detection of time series.
[0186] Embodiment 2:
[0187] The anomaly detection model obtained by the method of the present invention is compared with the model in the prior art. The process specifically includes: for a univariate data set, the models selected are: TS2Vec (Time Series to Vector), SPOT (Scalable Probability Of Outliers), DSPOT (Dynamic Scalable Probability Of Outliers), DONUT (Detecting Outliers in Networks with Uncertainty and Tolerance), SR (Spectral Residual) and SR-CNN (Spectral Residual Convolutional Neural Network). For multivariate datasets, the models used are: DAGMM (Deep Autoencoding Gaussian Mixture Model), LSTM-VAE (Long Short-Term Memory Variational Autoencoder), MAD-GAN (Multivariate Anomaly Detection for Time Series Data withGenerative Adversarial Networks), OmniAnomaly (Multivariate Time Series Anomaly Detection), USAD (Unsupervised Anomaly Detection via Multi-Scale Attention Modeling on Time Series), MTAD-GAT (Multi-variable Time-series Anomaly Detection with Graph Attention Networks), and GDN (Generative Deep Neural Networks). For each model, each dataset was trained from scratch and the same sliding window size p = 100 was used.
[0188] In this embodiment, the mapping dimension of the fully connected layer is set to 64, and the mapping dimension of the three feature labels is set to 3. The convolutional encoder consists of 10 dilated convolution blocks, with a kernel size of 3 and a hidden dimension of 320. For optimization, the balance factor of the temporal contrast loss and the instance loss is empirically set to α = 0.5. The AdamW optimizer is used, and the smoothing coefficient β of the first-order moment is 1 Set to 0.9, the smoothing coefficient β of the second-order moment 2 This example uses the anomaly detection model parameter values obtained by pre-training to evaluate the existing data set without fine-tuning: the training cycle (epoch) is set to 5, the batch size (batch size) is set to 16, and the learning rate is set to 5×10 -4 , the maximum length max_l is set to 3000, and the performance of each model is evaluated using F1 score, evaluation precision (Prec) and recall rate (Rec). The evaluation performance of different models on univariate datasets is shown in Table 1:
[0189] Table 1 Evaluation performance of the algorithms on the public univariate anomaly detection dataset
[0190]
[0191] In the table, CAT-AD indicates that the pre-trained model obtained by the method of the present invention shows excellent generalization ability and consistently obtains the best F1 score on two common univariate anomaly detection public datasets. Specifically, compared with the best state-of-the-art performance on KPI and Yahoo, the present invention improves the F1 score by 9.5% and 2.7%, respectively. Compared with the two best models (SR-CNN and TS2Vec, both with an average ranking of 2.5), the average F1 of CAT-AD is significantly improved by 13.5% and 6.6%, respectively.
[0192] The evaluation performance of different models on univariate datasets is shown in Table 2:
[0193] Table 2 Evaluation performance of the algorithm on the multivariate anomaly detection public dataset
[0194]
[0195] As can be seen from the table, the CAT-AD of the present invention also substantially outperforms existing models in multivariate anomaly detection tasks. For example, CAT-AD achieves the best results on 4 out of 5 datasets, with an average ranking of 1.2, and is 13.3% higher than the best baseline USAD (average ranking of 2.6) in average F1 score. These results show that the present invention can learn excellent time series representations for various anomaly detection tasks.
[0196] In summary, the superiority of the feature-aware pre-training method for time series anomaly detection proposed in this paper for pre-training on self-supervised time series is attributed to the following two aspects. First, feature label embedding enables the framework to accurately match feature prior knowledge with downstream data distribution. Second, applying max pooling to refine the representation of multivariate datasets can extract the most salient information required for anomaly detection and make the pre-trained representation effective and universal.
[0197] Embodiment 3:
[0198] The present invention based on the same inventive concept also provides a feature perception pre-training system for time series anomaly detection, the structural composition diagram is as follows: Figure 5 As shown, including:
[0199] Data acquisition module: used to obtain single-dimensional time series data;
[0200] Feature perception module: used to generate data embedding vectors based on single-dimensional time series data and pre-set convolutional encoders;
[0201] Pre-training module: used to pre-train the convolution encoder according to the data embedding vector, and optimize the parameters in the convolution encoder using the layered contrast loss method to obtain the anomaly detection model.
[0202] After acquiring the single-dimensional time series data, the above data acquisition module further includes:
[0203] The z-score is used to standardize the single-dimensional time series data to obtain the standardized single-dimensional time series data;
[0204] Perform instance division on the standardized single-dimensional time series data to obtain time instance data corresponding to each segment of the standardized single-dimensional time series data;
[0205] Randomly cut each time instance data into multiple subsequence data containing overlapping areas;
[0206] The subsequence data corresponding to each time instance data segment is used as the new single-dimensional time series data.
[0207] The above-mentioned feature perception module is specifically used for:
[0208] The single-dimensional time series data is mapped to high-dimensional features through a fully connected layer to obtain a high-dimensional feature vector;
[0209] According to the attribute features corresponding to the high-dimensional feature vector and the one-dimensional time series data, an embedded representation vector is obtained;
[0210] According to the preset convolutional encoder, the dimension axis of the hidden layer in the convolutional encoder is obtained;
[0211] The embedding representation vectors are concatenated along the dimension axis of the hidden layer to generate the data embedding vector.
[0212] In the above-mentioned feature perception module, an embedded representation vector is obtained according to the attribute features corresponding to the high-dimensional feature vector and the one-dimensional time series data, including:
[0213] The attribute features corresponding to the single-dimensional time series data are used as feature labels;
[0214] Based on the pre-constructed embedding vector space, the feature labels are encoded, and the encoded feature labels are embedded in the high-dimensional feature vector to obtain the embedded representation vector.
[0215] The above pre-training module is specifically used for:
[0216] The data embedding vector is input as an input item to the convolution encoder to obtain the representation information of the data embedding vector at each timestamp;
[0217] Based on the representation information of the data embedding vector at each timestamp, the layered contrast loss function value of the convolution encoder is calculated;
[0218] According to the layered contrast loss function value of the convolutional encoder, the parameters in the convolutional encoder are optimized to obtain the anomaly detection model.
[0219] In the above pre-training module, the layered contrast loss method is used to optimize the parameters in the convolution encoder. After obtaining the anomaly detection model, it also includes:
[0220] Get a multidimensional time series dataset;
[0221] Performing data preprocessing on the multidimensional time series data set to obtain a preprocessed multidimensional time series data set;
[0222] Generate the corresponding data embedding vector according to the preprocessed multidimensional time series data set;
[0223] Based on the data embedding vector corresponding to the multidimensional time series data set, the anomaly detection detection model is used to obtain the anomaly detection results corresponding to the multidimensional time series data set;
[0224] According to the anomaly detection results, the preset maximum pooling encoder is used to output the final representation vector corresponding to the anomaly detection results;
[0225] According to the final characterization vector corresponding to the anomaly detection result, the anomaly score of the final characterization vector corresponding to the anomaly detection result is calculated.
[0226] In the above-mentioned pre-training module, data preprocessing is performed on the multidimensional time series data set to obtain a preprocessed multidimensional time series data set, including:
[0227] Use z-score to standardize the multidimensional time series data set to obtain a standardized multidimensional time series data set;
[0228] Perform variable division on the standardized multidimensional time series data set to obtain the corresponding univariate data set and multivariate data set in the standardized multidimensional time series data set;
[0229] The principal component analysis method is used to reduce the dimension of multivariate data sets to obtain the reduced dimension feature data sets;
[0230] The univariate dataset and the dimension-reduced feature dataset are used as the preprocessed multidimensional time series dataset.
[0231] In the above pre-training module, based on the data embedding vector corresponding to the multi-dimensional time series data set, the anomaly detection model is used to obtain the anomaly detection results corresponding to the multi-dimensional time series data set, including:
[0232] Input the univariate data set into the anomaly detection model to obtain the anomaly detection result corresponding to the univariate data set;
[0233] The time series corresponding to each variable in the dimension reduction feature data set is taken as a univariate time series and input into the anomaly detection model respectively to obtain the anomaly detection result corresponding to each univariate time series.
[0234] The multidimensional time series datasets in the above-mentioned pre-training module include one or more of the following: safe water treatment dataset, water distribution dataset, network intrusion dataset, soil moisture active and passive satellite dataset, and Mars Science Laboratory rover dataset.
[0235] Embodiment 4:
[0236] like Figure 6As shown, the present invention also provides an electronic device, which may be a computer device, a single-chip device, an intelligent mobile device, etc. The electronic device in this embodiment may include a processor, a memory, a transceiver component, etc. The memory, the processor, and the transceiver component are connected via a bus; the memory may be used to store an execution program, and an exemplary execution program may include instructions; the processor is used to execute the instructions stored in the memory. The memory may also be used to store data, which may be called and / or modified when the instructions are executed.
[0237] The processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. It is the computing core and control core of the terminal, which is suitable for implementing one or more instructions, specifically suitable for loading and executing one or more instructions in a storage medium to implement the corresponding method flow or corresponding functions, so as to implement the steps of a feature-aware pre-training method for time series anomaly detection in the above embodiment.
[0238] Embodiment 5:
[0239] Based on the same inventive concept, the present invention also provides a readable storage medium, specifically an electronic device readable storage medium (Memory), which is a memory device in an electronic device for storing programs and data. It can be understood that the storage medium here can include both built-in storage media in electronic devices and, of course, extended storage media supported by electronic devices. The storage medium provides a storage space that stores the operating system of the terminal. In addition, one or more instructions suitable for being loaded and executed by a processor are also stored in the storage space, and these instructions can be one or more execution programs (including program codes). It should be noted that the storage medium here can be a high-speed RAM memory or a non-volatile memory, such as at least one disk storage. The processor loads and executes one or more instructions stored in the storage medium, which can implement the steps of a feature perception pre-training system for time series anomaly detection in the above embodiment.
[0240] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0241] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0242] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0243] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0244] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit its protection scope. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in the field should understand that after reading the present invention, those skilled in the art can still make various changes, modifications or equivalent substitutions to the specific implementation methods of the application, but these changes, modifications or equivalent substitutions are all within the protection scope of the claims to be approved.
Claims
1. A feature-aware pre-training method for time series anomaly detection, characterized in that: include: Get single-dimensional time series data; Generate a data embedding vector according to the one-dimensional time series data and a preset convolution encoder; The convolution encoder is pre-trained according to the data embedding vector, and the parameters in the convolution encoder are optimized by using a layered contrast loss method to obtain an anomaly detection model.
2. The method according to claim 1, characterized in that The step of generating a data embedding vector according to the one-dimensional time series data and a preset convolution encoder includes: Performing high-dimensional feature mapping on the single-dimensional time series data through a fully connected layer to obtain a high-dimensional feature vector; Obtaining an embedded representation vector according to the high-dimensional feature vector and the attribute features corresponding to the one-dimensional time series data; According to the preset convolutional encoder, obtaining a dimension axis of a hidden layer in the convolutional encoder; The embedding representation vectors are concatenated along the dimension axis of the hidden layer to generate a data embedding vector.
3. The method according to claim 2, characterized in that The step of obtaining an embedded representation vector according to the high-dimensional feature vector and the attribute features corresponding to the one-dimensional time series data includes: Using the attribute features corresponding to the one-dimensional time series data as feature labels; Based on a pre-constructed embedding vector space, the feature label is encoded, and the encoded feature label is embedded in the high-dimensional feature vector to obtain an embedded representation vector.
4. The method according to claim 1, characterized in that The method of pre-training the convolution encoder according to the data embedding vector and optimizing the parameters in the convolution encoder by using a layered contrast loss method to obtain an anomaly detection model includes: Inputting the data embedding vector as an input item into the convolution encoder to obtain representation information of the data embedding vector at each timestamp; Calculating a hierarchical contrast loss function value of the convolution encoder based on representation information of the data embedding vector at each timestamp; According to the layered contrast loss function value of the convolutional encoder, the parameters in the convolutional encoder are optimized to obtain an anomaly detection model.
5. The method according to claim 1, characterized in that After acquiring the one-dimensional time series data and before generating the data embedding vector according to the one-dimensional time series data and a preset convolution encoder, the method further includes: The single-dimensional time series data is standardized by using a z-score to obtain the standardized single-dimensional time series data; Performing instance division on the standardized one-dimensional time series data to obtain time instance data of each segment corresponding to the standardized one-dimensional time series data; Randomly cutting each time instance data segment into a plurality of subsequence data including overlapping areas; The subsequence data corresponding to each segment of time instance data is used as new single-dimensional time series data.
6. The method according to claim 1, characterized in that After optimizing the parameters in the convolution encoder by using the layered contrast loss method to obtain the anomaly detection model, the method further includes: Get a multidimensional time series dataset; Performing data preprocessing on the multidimensional time series data set to obtain a preprocessed multidimensional time series data set; Generate a corresponding data embedding vector according to the preprocessed multidimensional time series data set; Based on the data embedding vector corresponding to the multidimensional time series data set, using the anomaly detection model, obtaining an anomaly detection result corresponding to the multidimensional time series data set; According to the anomaly detection result, using a preset maximum pooling encoder, output a final representation vector corresponding to the anomaly detection result; According to the final characterization vector corresponding to the anomaly detection result, an anomaly score of the final characterization vector corresponding to the anomaly detection result is calculated.
7. The method according to claim 6, characterized in that The performing data preprocessing on the multidimensional time series data set to obtain a preprocessed multidimensional time series data set includes: Standardizing the multidimensional time series data set using a z score to obtain a standardized multidimensional time series data set; Performing variable division on the standardized multidimensional time series data set to obtain a univariate data set and a multivariate data set corresponding to the standardized multidimensional time series data set; Performing feature dimensionality reduction on the multivariate data set using principal component analysis to obtain a reduced-dimensional feature data set; The univariate data set and the dimension-reduced feature data set are used as a preprocessed multidimensional time series data set.
8. The method according to claim 7, characterized in that The method of obtaining an anomaly detection result corresponding to the multidimensional time series data set by using the anomaly detection model based on the data embedding vector corresponding to the multidimensional time series data set includes: Inputting the univariate data set into the anomaly detection model to obtain an anomaly detection result corresponding to the univariate data set; The time series corresponding to each variable in the dimension reduction feature data set is taken as a univariate time series and respectively input into the anomaly detection model to obtain an anomaly detection result corresponding to each univariate time series.
9. The method according to claim 6, characterized in that The multidimensional time series dataset includes one or more of the following: a safe water treatment dataset, a water distribution dataset, a network intrusion dataset, a soil moisture active and passive satellite dataset, and a Mars Science Laboratory rover dataset.
10. A feature-aware pre-training system for time series anomaly detection, characterized in that: include: Data acquisition module: used to obtain single-dimensional time series data; Feature perception module: used to generate a data embedding vector according to the one-dimensional time series data and a preset convolution encoder; Pre-training module: used to pre-train the convolution encoder according to the data embedding vector, and optimize the parameters in the convolution encoder by using a layered contrast loss method to obtain an anomaly detection model.
Citation Information
Cited By
Radar interference identification method based on LSTM and variational auto-encoder
CN119226928A
Abnormal content detection method and device and electronic equipment
CN119357641A
A method, apparatus, and electronic device for detecting abnormal content
CN119357641B
ECG anomaly detection method based on AE-GAN
CN119622583A
