Time sequence classification method based on frequency domain feature extraction
By introducing frequency domain feature extraction and self-attention mechanism into the time series classification model, combined with Fourier transform and seasonal trend decomposition modules, the problem of lack of frequency domain features and high complexity in time series data classification in the existing technology is solved. , significantly improving classification accuracy and resource utilization efficiency.
Patent Information
- Application Number
- CN202410756696.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-13
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2044-06-13
AI Technical Summary
Existing time series classification models based on Transformer have problems such as lack of frequency domain dimension feature extraction and excessive spatiotemporal complexity of the attention layer in time series data classification, resulting in insufficient classification accuracy and increased resource requirements.
Using a method based on frequency domain feature extraction, through Fourier transform and self-attention mechanism, combined with the DR-attention layer and seasonal trend decomposition module, the time-domain and frequency-domain features of the time series data are extracted, and the complexity of the self-attention layer is reduced. degree, and reduce the calculation amount of frequency domain features by selecting operators.
It improves the accuracy of time series classification, reduces resource requirements, solves the problem of lack of frequency domain information learning in time series data classification, and significantly improves the performance of the model.
Smart Images

Figure CN118606844A
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of social data governance, and specifically relates to a time series classification method based on frequency domain feature extraction. Background Art
[0002] Nowadays, users of various applications generate massive amounts of data during their use. Multivariate time series are ubiquitous in applications. They are longitudinally acquired event sequences, each consisting of observations recorded with multiple attributes, usually recorded simultaneously by a set of sensors over time. For example, electrocardiogram (ECG) signals in electronic health records (EHRs) can be represented as multivariate time series data, which are acquired by multiple sensors over time. Since time series data is a popular data type that exists in a wide range of research fields and applications, comprehensive analysis of these data can facilitate decision-making in practical applications, such as human activity recognition, healthcare monitoring, and industry detection. In particular, the multivariate time series classification (MTSC) task, as one of the fundamental problems in time series analysis, has received great attention from academia and industry.
[0003] Nowadays, Transformer-based time series classification models have received widespread attention and have made great progress as a method of sequence modeling. Therefore, training time series data through a Transformer-based time series classification model and making full use of the Transformer's ability to capture long-range dependencies and interactions in the time domain dimension is the mainstream deep learning method for time series data classification models. However, there are still two unavoidable key problems in using this method to perform time series modeling to achieve time series classification: lack of feature extraction in the frequency domain dimension and high spatiotemporal complexity of the attention layer. Lack of feature extraction in the frequency domain dimension means that only features in the time domain dimension are analyzed and extracted in the Transformer-based time series classification model, but time series data can be modeled not only in the time domain dimension, but also in the frequency domain. Lack of feature extraction in the frequency domain dimension will affect the accuracy of time series classification to a certain extent; the problem of high spatiotemporal complexity of attention has always existed because the time and memory complexity of the self-attention mechanism in the Transformer architecture is proportional to the quadratic length of the sequence input. These are all key issues that need to be solved for time series classification. Summary of the invention
[0004] One purpose of the present invention is to address the insufficient accuracy of time series classification in the prior art and the data imbalance phenomenon in the time series classification data set, and propose a time series classification method based on frequency domain feature extraction. The time series is modeled in two different dimensions, time domain and frequency domain, to extract different features, and the frequency domain features of the time series data are effectively extracted through Fourier transform, which supplements the features of the time series data to a certain extent. The Transformer network, self-attention mechanism (Attention), and Fourier transform are used to extract time domain features and frequency domain features, and a complete time series classification model based on frequency domain feature extraction is constructed to improve the accuracy of time series classification.
[0005] The technical solution adopted by the present invention is as follows:
[0006] Step 1: Obtain time series information of different dimensions in the data set, and standardize the time series data set so that each feature of the data has zero mean and unit variance.
[0007] Step 2: Apply standardization to both training data and test data, put the standardized time series information into the time block layer, and decompose it through the time block layer.
[0008] The data is effectively decomposed through the time block layer and put into different stages to learn time series representation methods in different dimensions and lengths, thereby improving the model's ability to understand time series data.
[0009] Step 3: Extract time domain dimension features of time series data: Input the decomposed data into the self-attention layer in Transformer to extract time domain features.
[0010] Transformer uses a variant of the self-attention layer, DR-attention, to reduce the time scale of k and v in the self-attention layer, effectively reducing the computational overhead of q, k, and v, and reducing a certain amount of time and space complexity.
[0011] Step 4: Extract frequency domain dimension features of time series data: Perform Fourier decomposition on the time domain features through the Fourier module, retain the components in the frequency domain by selecting the operator, and then obtain the frequency domain features by inverse Fourier transform and seasonal trend decomposition MOE.
[0012] Step 5: According to the time domain features and frequency domain features, the classifier performs classification to obtain the classification result.
[0013] The technical implementation scheme provided by the present invention has the following beneficial effects:
[0014] The present invention introduces the DR-attention self-attention layer as a time domain modeling method for time series data, supplements the feature representation of time series data in the time domain dimension, and then combines the dot product reduction strategy to effectively reduce the spatiotemporal complexity of the self-attention layer, thereby completing the learning of time domain features while reducing the required resource requirements and improving the accuracy of time series classification.
[0015] The present invention introduces a frequency domain feature extraction model as a frequency domain modeling method for time series data and as a feature representation of time series data in the frequency domain dimension. It performs feature learning on the vector after Fourier transformation and completes frequency domain feature extraction by selecting an operator, thereby solving the lack of learning of frequency domain information in the classification process of time series data and improving the accuracy of time series classification. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 The overall flow chart of the method of the present invention is as follows;
[0017] Figure 2 This is a schematic diagram of the network structure of the present invention. DETAILED DESCRIPTION
[0018] The present invention will be further analyzed below in conjunction with the accompanying drawings.
[0019] A time series classification method based on frequency domain feature extraction, such as Figure 1 and Figure 2 As shown, the following steps are included:
[0020] Step (1) obtains the time series information of different dimensions in the data set, and applies standardization technology to the original time series data so that each feature has zero mean and unit variance, and maintains the consistency of the previous and subsequent dimensions, thereby obtaining the time series vector Where B represents the number of batches, M represents the dimension of the current dataset, and D represents the length of the time series data. The vector is then put into the time block layer to learn the time series representation at different time scales by introducing a hierarchical structure, that is, aggregating continuous neighborhood points through slicing operations.
[0021] E = Concat(B, s j *M, D / s j )
[0022] Where E represents the previous time series vector, (B, s j *M, D / s j ) indicates the current dimension size, Concat indicates concatenating and merging the time block representations and returning the time series representations at different scales, s j is the window slice size. jContinuous points will be grouped into an information time slice. Assuming that the entire model is divided into three stages, the method of each stage is consistent. The fine-grained original time series is concat processed into a new granular version, where the length of each time block is T / 4, and then the time series is flattened and projected into a 4C-dimensional embedding vector. The vector output by the previous stage is used as the input of the next stage. This stage propagation method effectively learns time series representations of different scales.
[0023] Step (2), extracting time-domain features from time series data. Time-domain time series data modeling is mainly done by the self-attention layer in Transformer. The self-attention layer attempts to calculate the similarity between the query and the key, and assigns weights through dot products. The attention weight matrix is multiplied by an output matrix and a bias vector is added to obtain the final output representation matrix, which contains the context-aware representation of each position. This is used as the feature representation of the time series in the time domain dimension for subsequent encoder layers or other related tasks.
[0024] In the Transformer model, the attention layer is its core component. It plays a very important role in processing sequence data. The attention layer can effectively capture the correlation and importance between different positions in the sequence, assign different weights, and use this information in the learning and reasoning process of the model. At the same time, it allows each position to directly access the information before and after the entire sequence, which is why it can directly assign weights. The self-attention mechanism is the core to obtain global context information.
[0025] This paper introduces a new attention calculation strategy called dot product reduced attention (DRA) to replace the traditional temporal self-attention and reduce the temporal and spatial complexity. The core idea of the temporal reduced attention mechanism is to reduce the size of the attention dot product by calculating the attention dot product using the reduced version of the input k and v. The details of the DRA operation in stage j can be expressed as follows:
[0026]
[0027] Concat represents the connection operation, N j is the number of heads in the attention layer, W o is the weight matrix.
[0028]
[0029] in is the linear projection parameter. Thus, the size of each head is equal to C j / N jHere, DR represents the time scale reduction of k and v, thereby reducing the dot product size, which can be written as:
[0030] DR(x)=Norm(Reshape(x,R j )W T )
[0031] in represents the input sequence, R j Reshape(x, R j ) is to reshape the input sequence x into a size of L j / R j The sequence of operations, W T is to reduce the dimension of the input sequence to C j Here, the present invention uses layer normalization operation to implement Norm. Then, like the traditional attention dot product, the dot product operation of q, k, and v is performed. The attention dot product of the present invention can also be expressed as:
[0032]
[0033] The computational cost of the attention operation is 1 / R of the standard self-attention. i , therefore the dot product reduction self-attention mechanism of the present invention can process longer input feature maps or sequences without requiring too many resources.
[0034] Step (3), extracting features from the frequency domain dimension of time series data. After extracting features from the time domain dimension in step (2), the time series data also needs to extract features from the frequency domain dimension. The present invention randomly selects a certain number of Fourier components, including both high-frequency components and low-frequency components, to represent the modeling of the time series in the frequency domain dimension. The following will analyze the reasons for the screening and the rationality of the randomness:
[0035] Assume there are m time series, denoted as X1(t),...,X m (t). Perform Fourier transform on each time series, and the transformed vector is expressed as:
[0036] a i =(a i,1 , ..., a i,d ) T ∈R m×d
[0037] The present invention converts each X i (t) is converted into vector a i, where m represents the number of time series, d represents the length of the time series, each row represents a different time series, and each column corresponds to a different Fourier decomposition component. Although retaining all frequency components can restore all information to the greatest extent, however, completely retaining all components may lead to overfitting of historical data, thereby affecting the final classification effect. Therefore, in order to avoid overfitting and retain most of the historical information as much as possible, the present invention selects a subset of high-frequency components and low-frequency components generated by Fourier transform in the time series data, that is, uniformly selects s components from n Fourier components, where d>s. In this way, the previous overfitting situation is avoided. The above is the rationality analysis of screening and randomization.
[0038] Frequency domain feature extraction is expressed as:
[0039]
[0040] in It represents the output vector of the previous self-attention layer at the current stage. The MOE module is a seasonal trend decomposition MOE module. The MOE module can effectively extract the seasonal trend component of time series data. The frequency domain features of time series data are effectively extracted through the Fourier module. At the same time, the above method is used here to uniformly and randomly retain s components from the generated n components, retaining historical information as much as possible while minimizing overfitting. After full connection, residual connection is performed again to solve the problems of gradient disappearance and gradient explosion and improve the training effect of the model. Then, the seasonal trend decomposition MOE layer is added again and the result is used as the output of frequency domain feature extraction.
[0041] The Fourier module in the frequency domain feature extraction module of the present invention uses discrete Fourier transform. represents Fourier transform, then represents the inverse Fourier transform. Suppose there is a real number sequence X n In the time domain, where n = 1, 2, ..., N, the discrete Fourier transform is defined as where i is the imaginary unit, X l , l = 1, 2, ..., N is a complex sequence in the frequency domain. The inverse discrete Fourier transform is defined as:
[0042]
[0043] Frequency domain feature extraction through discrete Fourier transform and inverse discrete Fourier transform can effectively reduce the computational complexity.
[0044] The specific steps in the Fourier module are as follows:
[0045] The Fourier module takes the input (x∈R N×D ) for linear projection, ω is the weight:
[0046] q=x·ω
[0047] Then q is transformed from the time domain to the frequency domain. The time scale of Q after Fourier transformation is expressed as Q∈C N×D In the frequency domain, only M randomly selected modes are retained, so the present invention uses a selection operator:
[0048]
[0049] in And M<<N, the global Fourier module can be defined as:
[0050]
[0051] where R∈C D×D×M is a randomly initialized parameter kernel, let Y = Q⊙C, where Y∈C M×D . The algorithm ⊙ is defined as where d i is the input channel, and d0 is the output channel. Since the front and back dimensions need to be aligned, the high-frequency components and low-frequency components selected by the selection operator need to be padded to C N×D Finally, an inverse Fourier transform is performed to convert it back into the time domain.
[0052] In order to handle common complex periodic patterns and significant data trends, the seasonal trend decomposition MOE module is introduced in the frequency domain feature extraction module. The seasonal trend decomposition MOE module contains a set of filters of different sizes, which are used to combine the extracted trend components and related weights to form the final trend term.
[0053] Step (4): predict the probability that the event sequence belongs to the jth category based on the vector output from the frequency domain feature extraction module.
[0054]
[0055] in Represents the jth element after the frequency domain feature extraction module.
[0056] The loss function of the training of the present invention is the cross entropy loss function. The calculation method of the cross entropy loss for a batch, a single-label n-classification task is as shown in the formula:
[0057]
[0058] Where batch_size indicates the number of batches. Represents the true category of the time series, and n represents the number of categories in the time series.
[0059] The present invention performs all experiments by experimenting on 13 public datasets, which are selected from the famous UEA Multivariate Time Series Classification (MTSC) archive. In fact, the UEA archive has almost become the most widely used multivariate time series benchmark. We selected a set of 13 multivariate datasets from the UEA archive, which have different characteristics in terms of the number, length and number of categories of time series samples. Specifically, the present invention selects: ArticleyWordRecognition (AWR), AtrialFibrillation (AF), CharacterTrajectories (CT), FaceDetection (FD), HandMovementDirection (HMD), Heartbeat (HB), MotorImagery (MI), NATOPS (NA), PenDigits (PD), PEMS-SF (PEMS), SelfRegulationSCP2 (SRS2), SpokenArabicDigits (SAD), StandWalkJump (SWJ). In these original datasets, both the training set and the test set have been well processed. For fair comparison, the present invention does not perform any processing on these datasets. The present invention summarizes the main features of the datasets in Table 1.
[0060] Table 1: Static data of experimental dataset
[0061]
[0062]
[0063] For each dataset, the classification accuracy is calculated as the evaluation metric. The average rank and the number of wins / ties are also calculated to compare different methods.
[0064] Table 2: Details of the results achieved
[0065] Tapnet MR-PETSC SMATE DANET The present invention AWR 0.987 0.997 0.993 0.98 0.9733 AF 0.333 0.4 0.133 0.414 0.4667 CT 0.997 0.984 0.987 0.998 0.9875 FD 0.556 0.574 0.563 0.645 0.6967 HMD 0.378 0.365 0.527 0.347 0.6622 HB 0.751 0.702 0.727 0.626 0.761 MI 0.59 0.49 0.59 0.55 0.59 NA 0.939 0.917 0.883 0.877 0.9222 PEMS 0.751 0.861 0.763 0.867 0.896 PD 0.98 0.905 0.98 0.989 0.9848 SRS2 0.55 0.533 0.556 0.561 0.5778 SAD 0.983 0.96 0.982 0.99 0.9873 SWJ 0.4 0.4 0.2 0.4 0.5333 Avg 0.707 0.699 0.683 0.711 0.772
[0066] It can be concluded from Table 2 that the present invention conducts comparative tests on the previous time series classification models and the present invention. Compared with Tapnet, MR-PETSC, SMATE, and DANET released in previous years, the overall average accuracy of the present invention is improved by 6.50%, 7.31%, 8.88%, and 6.11%, respectively.
Claims
1. A time series classification method based on frequency domain feature extraction, characterized in that: The following steps are involved: Step 1: Obtain time series information of different dimensions in the data set and perform standardization; Step 2: Put the standardized time series information into the time block layer and decompose it through the time block layer; Step 3: Input the decomposed data into the self-attention layer in Transformer to extract time domain features; Step 4: Perform Fourier decomposition on the time domain features through the Fourier module, and retain the components in the frequency domain by selecting the operator, and then decompose the MOE by inverse Fourier transform combined with seasonal trend to obtain the frequency domain features; Step 5: According to the time domain features and frequency domain features, the classifier performs classification to obtain the classification result.
2. The time series classification method based on frequency domain feature extraction according to claim 1 is characterized in that: The implementation of the time-blocking layer is as follows: Aggregate consecutive neighborhood points via slicing: E=Concat(B,s j *M,D / s j ) Where E represents the previous time series vector, (B,s j *M, D / s j ) indicates the current dimension size, B indicates the number of batches, M indicates the dimension of the current data set, D indicates the length of the time series data, Concat indicates concatenating and merging the time block representations and returning the time series representations at different scales, s j is the window slice size; every s j Consecutive points will be grouped into one information time slice.
3. The time series classification method based on frequency domain feature extraction according to claim 2 is characterized in that: The self-attention layer in the Transformer described in step 3 uses DR-attention to reduce the time scale of k and v in the self-attention layer and reduce the computational overhead of q, k, and v, as follows: The attention calculation strategy of dot product reduced attention DRA is adopted to replace the temporal self-attention, by calculating the attention dot product using the reduction of input k and v; the DRA operation in stage j is expressed as follows: Where N j is the number of heads in the attention layer, W o is the weight matrix; in is the linear projection parameter; the size of each head is equal to C j / N j , DR indicates that the time scale of k and v is reduced: DR(x)=Norm(Reshape(x,R j )W T ) in represents the input sequence, R j Reshape(x,R j ) is to reshape the input sequence x into a size of L j / R j The sequence of operations, W T is to reduce the dimension of the input sequence to C j Linear projection of ; layer normalization operation is used to implement Norm, and then the dot product operation of q, k, and v is performed. The attention dot product is expressed as: The computational cost of the attention operation is 1 / R of the standard self-attention i .
4. The time series classification method based on frequency domain feature extraction according to claim 3 is characterized in that: The frequency domain feature extraction in step 4 is expressed as: in It represents the output vector of the previous self-attention layer at the current stage. The MOE module is the seasonal trend decomposition MOE module. The frequency domain features of time series data are extracted through the Fourier module, and then the generated Full connection After that, residual linking is performed again, and then the seasonal trend decomposition MOE layer is added again, and the result is used as the output of frequency domain feature extraction.
5. The time series classification method based on frequency domain feature extraction according to claim 4 is characterized in that: The Fourier module uses a discrete Fourier transform, represents Fourier transform, then represents the inverse Fourier transform; suppose there is a real number sequence X n In the time domain, where n = 1, 2, ..., N, the discrete Fourier transform is defined as where i is the imaginary unit, X l , l = 1, 2, ..., N is a complex sequence in the frequency domain, and the inverse discrete Fourier transform is defined as The specific steps in the Fourier module are as follows: The Fourier module takes the input x∈R N×D Perform linear projection, ω is the weight: q=x·ω Then q is transformed from the time domain to the frequency domain; the time scale of the Fourier transform of Q is represented by Q∈C N×D ; In the frequency domain, only M randomly selected modes are kept, using the selection operator: in And M<<N, the global Fourier module is defined as: where R∈C D×D×M is a randomly initialized parameter kernel, let Y = Q⊙C, where Y∈C M×D ; where the algorithm ⊙ is defined as where d i is the input channel, d0 is the output channel; the high-frequency component and the low-frequency component selected by the selection operator are filled with zero to C N×D Finally, an inverse Fourier transform is performed to convert it back into the time domain.
Citation Information
Patent Citations
Multi-modal multivariable time sequence automatic classification method and device
CN114722950A
Food classification method and system based on deep learning and readable storage medium
CN116933156A
Time sequence prediction method based on frequency domain information enhancement and multi-scale trend enhancement
CN117807405A
Traffic classification system and method, and program, and abnormal traffic detection system and method
JP2010283668A
Methods and systems for implicit attention with sub-quadratic complexity in artificial neural networks
WO2023039681A1
Cited By
Time sequence classification method based on improved discrete wavelet transform and trend similarity measurement
CN119989128A
