Long-term time sequence prediction method and system based on time sequence block repair

By dividing time series data into a sequence of time blocks and adopting a multi-head dot product attention mechanism, the problem of loss of semantic and location information within patches is solved, significantly improving the performance and information aggregation capabilities of time series prediction.

CN118862014APending Publication Date: 2024-10-29DALIAN UNIV OF TECH
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202410964672.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-18
Publication Date
2024-10-29

AI Technical Summary

Technical Problem

Existing time series prediction methods suffer from the problem of losing semantic and location information within patches in long-term prediction, resulting in insufficient information aggregation capabilities.

Method used

By dividing long-term time series data into continuous time block sequence Patches, internal temporal relationships and local semantic information are reconstructed, and a multi-head dot product attention mechanism is used to extract global feature information and flatten it into a one-dimensional form to enhance the information of the model. Aggregation ability.

Benefits of technology

It significantly improves the prediction performance, offsets the negative impact of the loss of semantic and positional information between points within the patch, enables the model to better handle the dependencies between time block sequences, and improves the information aggregation capability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118862014A_ABST
    Figure CN118862014A_ABST
Patent Text Reader

Abstract

The invention provides a long-term time sequence prediction method and system based on time sequence block repair, and belongs to the technical field of time sequence prediction. According to the method, Patch repair and Repatches feature extraction are introduced to counteract the negative influence of semantic and position information loss between Patch internal points, so that the model can concentrate on the dependency relationship between time block sequence internal data and different time block sequences, and the information aggregation capability of the model is enhanced; under the condition that the training time and the GPU memory are limited, the Patch is designed to enable the model to see a longer historical sequence, multivariate time sequence data are divided into different channels to perform RevIN operation, time sequence data input distribution is more stable, and the model prediction performance is remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of time series prediction, and in particular to a method and system for predicting long-term time series based on time series block repair. Background Art

[0002] Time series forecasting and analysis technology is based on an ordered observation data set associated with a time sequence. It uses random process theory and mathematical statistics methods to study the statistical laws followed by the data set, thereby inferring the data development trend and guiding the solution of practical problems. Scientific and correct forecasting and analysis of various actual time series can produce huge economic and social benefits. Time series forecasting and analysis technology has been widely used in the fields of industry, geology, ecology, economy, meteorology, medicine, etc.

[0003] In the past, real-time prediction of time series generally used methods such as autoregressive moving average model (ARMA), back propagation natural network (BPNN) or support vector machine (SVM). Among them, the most commonly used are ARMA and its variation model. ARMA is a mixture of autoregressive model AR and moving average model MA. The autoregressive model calculates the relationship between the current value and the historical value, and the moving average model calculates the cumulative error of the autoregressive model. ARMA is often used in the study of changes in consumer behavior patterns. In retail research, it is used to predict sales volume and market size with seasonal changes.

[0004] Recent deep prediction models have made substantial progress, and models based on Transformer and MLP architectures have shown excellent performance in time series prediction. Throughout the research process of deep learning models, scholars have pointed out many challenges and proposed various solutions. For example, during the research process, some people found through research that numerical time series data lacks semantics and Transformer is ineffective for long-term prediction. Although scholars quickly refuted that Transformers have potential prospects in time series prediction, they still need to improve their design and adaptation to fully utilize their potential, such as patch and channel independence.

[0005] Linear layer-based designs show strong performance in short-term prediction, however simple linear layers are insufficient in effectively modeling long-term dependencies. While patch-based designs reduce computational complexity, they also compromise the semantic and positional information in patches, which may lead to accuracy loss.

[0006] Therefore, a time series prediction algorithm is needed that can fully extract internal semantic information and restore the missing semantic information inside the patch. Summary of the invention

[0007] The purpose of the present invention is to provide a long-term time series prediction method and system based on time series block repair, so as to solve the problem of loss of semantic and position information between patches due to the use of patches, thereby improving the information aggregation capability.

[0008] To achieve the above object, the present invention provides the following solutions:

[0009] A long-term time series prediction method based on time series block repair includes the following steps:

[0010] S1. Collect a long-term time series data set and preprocess the historical observation time series data in the long-term time series data set;

[0011] S2, split the preprocessed historical observation time series into multiple continuous time block sequences Patches, each Patches consists of several time block patches;

[0012] S3. In all the continuous Patches, reconstruct the time relationship and local semantic information of each patch in any Patches to obtain a new time block Repatch; connect each Repatch to obtain a new time block sequence Repatches; and finally obtain a plurality of Repatches corresponding to the number of Patches;

[0013] S4, perform multi-head dot product attention mechanism processing on all Repatches to extract rich global feature information between different Repatches;

[0014] S5. Flatten the obtained global feature information into a one-dimensional form; connect the one-dimensional global feature information with the input Repatches to obtain a time series matching the expected length.

[0015] Furthermore, in S1, the long-term time series data set includes four ETT data sets (ETTh1, ETTh2, ETTm1, ETTm2), a Weather data set, an Electricity data set, a Traffic data set and an ILI data set.

[0016] Furthermore, in S1, the preprocessing includes two parts: channel independence and reversible instance normalization (RevIN), which are as follows:

[0017] For a historical observation time series X 1:L ∈RD×L , which is divided into D independent channels, namely the unit time series Y 1:L ∈R 1×L , where D represents the dimension of the historical observation time series, L represents the historical time step, these unit time series share the same system backbone, but the forward data preprocessing is independent;

[0018] For each unit time series Y 1:L ∈R 1×L Perform reversible instance normalization (RevIN): Normalize the original data in the input unit time series according to the mean and variance to fix its distribution, and return the normalized data to the original distribution.

[0019] Furthermore, S2 specifically includes: dividing the unit time series obtained after preprocessing into continuous time block sequences Patches, each Patches is composed of several time block Patches, and these Patches can overlap to provide continuous data information; or not overlap to provide discrete segments for inspection.

[0020] Furthermore, the S3 specifically includes:

[0021] S3.1: Position encoding is performed on the internal data of each patch in any patch, and the time relationship within each patch is reconstructed according to the position encoding;

[0022] S3.2: Reconstruct the rich local semantic information in each encoded patch through a fully connected network, and map each patch to the input dimension required to extract global feature information to obtain a new time block Repatch;

[0023] S3.3: Connect each Repatch to obtain a new time block sequence Repatches;

[0024] S3.4: Repeat S3.1 to S3.3 for all Patches to obtain multiple Repatches corresponding to the number of Patches.

[0025] Furthermore, the S4 specifically includes:

[0026] S4.1: Position encoding of each Repatch in any Repatches obtained in S3;

[0027] S4.2: Use the multi-head dot product attention mechanism to extract the feature information of each Repatch within the Repatches;

[0028] The multi-head dot product attention mechanism includes multiple parallel attention layers; for each parallel attention layer, the initial features of each Repatch after position encoding are extracted using a single-head attention mechanism as the output of each parallel attention layer; the output of each parallel attention layer is connected, and a linear projection model is used to generate the output of the multi-head dot product attention mechanism;

[0029] S4.3: The output of the multi-head dot product attention mechanism is connected using the residual connection normalized by the accompanying layer;

[0030] S4.4: Use the feedforward network to extract richer semantic information for each Repatch;

[0031] The feedforward network includes two linear transformations and a GeLU activation of an intermediate layer; the first linear transformation linearly maps the output of S4.3 to a high-dimensional space, obtains the intermediate weights through GeLU activation, and then obtains the output of the feedforward network through another linear transformation;

[0032] S4.5: The output of the feedforward network is connected with the residual of the accompanying layer normalization to generate feature information of each Repatch, and obtain the global feature information within the Repatches;

[0033] S4.6: Repeat S4.1-S4.5 for all Repatches to extract global feature information between different Repatches.

[0034] Furthermore, the S5 specifically includes:

[0035] S5.1: putting the global feature information obtained in S4 into the Flatten layer for processing, and flattening these features into a one-dimensional form; the Flatten layer extracts each element of the multidimensional array one by one to form a continuous one-dimensional array;

[0036] S5.2: Use a fully connected network to connect these one-dimensional global feature information with the input Repatches to form a new time series;

[0037] S5.3: Linearly map the new time series to obtain a time series that matches the length of the expected time series.

[0038] A long-term time series prediction system based on time series block repair, including a Preprocessing module, a Representor module, an Extractor module and a Predictor module;

[0039] The Preprocessing module is used to preprocess the historical observation time series in the collected long-term time series data set and divide the preprocessed historical observation time series into continuous time block sequences Patches, each of which is composed of a number of time block Patches;

[0040] The Representor module is used to reconstruct the time relationship and local semantic information of each patch in any of the Patches and linearly map them to the input dimension required by the Extractor module to obtain a new time block Repatch, and connect each Repatch to obtain a new time block sequence Repatches;

[0041] The Extractor module is used to process the Repatches obtained by the Representor module using a multi-head dot product attention mechanism to extract rich global feature information between different Repatches;

[0042] The Predictor module is used to flatten the global feature information processed by the Extractor module into a one-dimensional form, and connect the one-dimensional global feature information with the input Repatches, and finally obtain a time series matching the expected length.

[0043] Furthermore, the Extrarator module is composed of several identical parallel layers, each layer includes an attention module and a feedforward network module; the attention module uses a multi-head dot product attention mechanism to extract feature information of each Repatch inside Repatches; the feedforward network module includes two linear transformations and GeLU activation of the intermediate layer, one of which linear transformation linearly maps the features extracted by the attention module to a high-dimensional space, obtains intermediate weights through GeLU activation, and then obtains richer semantic information of each Repatch as the output of the feedforward network through another linear transformation, and finally obtains the global feature information inside the Repatches.

[0044] Furthermore, the Predictor module includes a Flatten layer and a fully connected network; the Flatten layer flattens the global feature information processed by the Extractor module into a one-dimensional form; and the fully connected network connects the one-dimensional global feature information with the input Repatches.

[0045] Beneficial effects of the present invention:

[0046] 1) When the training time and GPU memory are limited, the Patch designed by the present invention allows the model to see a longer historical sequence, significantly improving the prediction performance; by dividing the multivariate time series data into different channels for RevIN operation, the input distribution of the time series data is made more stable, significantly improving the model prediction performance;

[0047] 2) The present invention introduces Patch repair and Repatches feature extraction to offset the negative impact of the loss of semantic and position information between points within the Patch, enabling the model to focus on the dependency between the internal data of the time block sequence and different time block sequences, thereby enhancing the information aggregation capability of the model. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] Figure 1 This is a general architecture diagram of a long-term time series prediction system based on time block sequence repair according to an embodiment of the present invention.

[0049] Figure 2 This is an architecture diagram of the network backbone Representor module, Extractor module and Predictor module provided in an embodiment of the present invention.

[0050] Figure 3 A flow chart of time block sequence repair and internal information extraction provided by an embodiment of the present invention.

[0051] Figure 4 A flowchart of deep-level feature extraction of time series provided by an embodiment of the present invention.

[0052] Figure 5 Flowchart of the multi-head dot-product attention mechanism provided for an embodiment of the present invention.

[0053] Figure 6 A flow chart of a feedforward network provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0054] The following is a detailed description of the embodiments of the present invention in conjunction with the accompanying drawings and technical solutions.

[0055] like Figure 1 As shown, this embodiment provides a long-term time series prediction method based on time series block repair, comprising the following steps:

[0056] Step 1: Collect a long-term time series data set and preprocess the historical observation time series data in the long-term time series data set.

[0057] The long-term time series datasets are obtained from various public websites and have been widely used for benchmarking. There are 8 popular benchmark datasets, including 4 ETT datasets (ETTh1, ETTh2, ETTm1, ETTm2), Weather dataset, Electricity dataset, Traffic dataset and ILI dataset. Among them, the ETT dataset contains 2 years of data on power transformers in two counties in China, including load and oil temperature; the Weather dataset collects 21 meteorological indicators for each date in 2020, with a sampling frequency of 10 minutes; the Electricity dataset contains the hourly electricity consumption of 321 users from 2012 to 2014; the Traffic dataset is an hourly data collection of the California Department of Transportation, describing the road occupancy measured by different sensors on highways in the San Francisco Bay Area; the ILI dataset collects weekly records of patients with influenza-like illness from the Centers for Disease Control and Prevention in the United States from 2002 to 2021.

[0058] The Preprocessing module performs the following processing:

[0059] First, given a historical observation time series X 1:L ∈R D×L , where D represents the number of dimensions and L represents the historical time step. The D-dimensional multivariate time series data is divided into D independent channels, i.e., the unit time series Y 1:L ∈R 1×L ;

[0060] Second, for each unit time series Y 1:L ∈R 1×L Perform reversible instance normalization (RevIN) operation. Specifically, the original data in the input unit time series is normalized using its own mean and variance, non-stationary information is removed, and the normalized data is returned to the original distribution;

[0061] Third, transform the unit time series Y 1:L ∈R 1×L Split into a sequence of continuous time blocks PatchesP (i) ∈R N×pl , each Patches is composed of several time blocks Patches, these Patches can overlap, providing information of continuous data; or they can not overlap, providing discrete fragments for inspection; where N is the number of patches in each Patches, and pl is the length of each Patch.

[0062] Step 2: Reconstruct the temporal relationship and local semantic information within each patch in the continuous patches; Figure 2 and Figure 3As shown, the Representor module specifically performs the following steps:

[0063] Step 2.1: Positionally encode the internal data of each patch in any patch, and reconstruct the time relationship within each patch according to the position encoding;

[0064] Step 2.2: Reconstruct rich local semantic information for each encoded patch through a fully connected network;

[0065] Step 2.3: At the end of the fully connected network, a linear mapping is used to map Patch to the input dimension required to extract global feature information, and a new time block Repatch is obtained;

[0066] Step 2.4: Connect each Repatch to get a new time block sequence Repatches;

[0067] Step 2.5: Repeat steps 2.1 to 2.4 for all Patches to obtain multiple time block sequences Repatches corresponding to the number of Patches.

[0068] Step 3: Extract rich global feature information within each Repatches.

[0069] like Figure 4 As shown, the Extrator module is composed of N identical parallel layers, each of which includes an attention module and a feedforward network module; the rich global feature information inside the Repatches is obtained jointly by the attention module and the feedforward network module.

[0070] In order to effectively capture the global feature information within Repatches, the present invention introduces a position encoding mechanism between Repatches before entering the attention module and the feedforward network module. Specifically, each Repatch in Repatches is position encoded, and the formula is as follows:

[0071] P re-pos =P re +Encoding inter-patch (1)

[0072] Among them, P re-pos Indicates the sequence that has completed the position encoding and is about to be input into the attention module; P re Represents the vector obtained by the input Repatches through the regular Embedding layer, whose dimension is dmodel; Encoding inter-patchrepresents the position code calculated according to the position of Repatch, and its dimension is also dmoel; therefore, the input P of the attention module re-pos The dimension is dmodel.

[0073] The Embedding layer is used to convert discrete data (such as words, characters, etc.) into continuous vector representation.

[0074] In the attention module, a multi-head dot product attention mechanism is used to extract the feature information of each Repatch within Repatches; specifically:

[0075] like Figure 2 , Figure 5 As shown, the multi-head dot product attention mechanism includes h parallel attention layers, each of which is called a "head"; for each parallel attention layer head j , using different linear projections to encode the position P re-pos Projected to different linear subspaces with dimensions Q, K, and V Then and The inner product of the two spaces is used to obtain the cosine similarity of the two. The cosine similarity is put into the softmax function to obtain multiple non-negative weights that sum to 1, and the above weights are applied to Get head j The dot product attention output of each parallel attention layer is then concatenated and subjected to another learned linear projection to produce the final output, which is expressed as follows:

[0076] MultiHead(Q,K,V)=Concat(head 1 ,…,head j ,…,head h )W O (2)

[0077]

[0078] Among them, MultiHead(Q,K,V) represents the output of the multi-head dot product attention mechanism, W O Represents the dot product attention mechanism output of each head, head j Represents the operation of extracting features from the j-th parallel attention layer using a single-head attention mechanism.

[0079] like Figure 4 As shown, after the attention module, residual connections with layer normalization are used.

[0080] Finally, the output of the attention module is AS As the input of the feedforward network module, it is expressed as:

[0081] Output AS =LayerNorm(x+Dropout AS (MultiHead(x))) (4)

[0082] In the formula, Dropout AS represents the residual connection operation, LayerNorm represents the normalization operation, and x represents the P obtained by position encoding. re-pos The initial features of , MultiHead(x) represents the multi-head dot product attention mechanism operation on the initial features of the input.

[0083] like Figure 6 As shown, the feedforward network module is applied to each Repatch in the same manner, including two linear transformations and GeLU activation of the intermediate layer; the specific process is expressed by the following formula:

[0084] FFN 1 (y) = Gelu (yW 1 +b1) (5)

[0085] FFN 2 (y) = FFN 1 (y)W 2 +b 2 (6)

[0086] Among them, FFN 1 (y) is the GeLU activation operation, and y is the feature Output extracted by the multi-head dot product attention mechanism AS ,FFN 2 (y) is the linear transformation of the feedforward network, W 1 , b1, W 2 、b 2 are the linear network parameters respectively.

[0087] After the feed-forward network module, residual connections with layer normalization are also used.

[0088] Finally, the output of the feedforward network module is FFS It is expressed as:

[0089] Output FFS =LayerNorm(y+Dropout FFS (FFN 2 (y))) (7)

[0090] Step 4: Predict the expected length T of the global information extracted in step 3.

[0091] The Predictor module receives global feature information of dimension dmodel and puts it into the Flatten layer for processing, flattening these features into one-dimensional form; uses a fully connected network to connect these one-dimensional feature information with the input Repatches to form a new time series; at this time, the length of the new time series does not match the expected length T, and the above new time series is linearly mapped to obtain a time series that matches the expected length T.

[0092] Finally, it should be noted that the above embodiments are intended to illustrate the technical solutions of the present invention and do not constitute any form of limitation on the present invention. Those skilled in the art should fully understand that it is completely feasible to modify the technical solutions described in the above embodiments or to perform equivalent replacements on any part or all of the technical features therein. These modifications or replacements, as long as they do not deviate from the scope of protection determined by the claims of the present invention, should be regarded as reasonable extensions of the present invention.

Claims

1. A long-term time series prediction method based on time series block repair, characterized in that: include: S1. Collect a long-term time series data set and preprocess the historical observation time series data in the long-term time series data set; S2, split the preprocessed historical observation time series into multiple continuous time block sequences Patches, each Patches consists of several time block patches; S3. In all the continuous Patches, reconstruct the time relationship and local semantic information of each patch in any Patches to obtain a new time block Repatch; connect each Repatch to obtain a new time block sequence Repatches; and finally obtain a plurality of Repatches corresponding to the number of Patches; S4, perform multi-head dot product attention mechanism processing on all Repatches to extract rich global feature information between different Repatches; S5. Flatten the obtained global feature information into a one-dimensional form; connect the one-dimensional global feature information with the input Repatches to obtain a time series matching the expected length.

2. The long-term time series prediction method based on time series block repair according to claim 1 is characterized in that: In S1, the preprocessing includes channel-independent and reversible instance normalization: For a historical observation time series X 1:L ∈R D×L , which is divided into D independent channels, namely the unit time series Y 1:L ∈R 1×L , where D represents the dimension of the historical observation time series and L represents the historical time step; For each unit time series Y 1:L ∈R 1×L Perform reversible instance normalization: normalize the original data in the input unit time series according to the mean and variance to fix its distribution, and return the normalized data to the original distribution.

3. The long-term time series prediction method based on time series block repair according to claim 2 is characterized in that: The S2 specifically includes: dividing the unit time series obtained after preprocessing into a continuous time block sequence Patches, each Patches is composed of a number of time block Patches, and these Patches overlap to provide information of continuous data, or do not overlap to provide discrete segments for inspection.

4. A long-term time series prediction method based on time series block repair according to any one of claims 1 to 3, characterized in that: The S3 specifically includes: S3.1: Position encoding is performed on the internal data of each patch in any patch, and the time relationship within each patch is reconstructed according to the position encoding; S3.2: Reconstruct the rich local semantic information in each encoded patch through a fully connected network, and map each patch to the input dimension required to extract global feature information to obtain a new time block Repatch; S3.3: Connect each Repatch to obtain a new time block sequence Repatches; S3.4: Repeat S3.1 to S3.3 for all Patches to obtain multiple Repatches corresponding to the number of Patches.

5. The long-term time series prediction method based on time series block repair according to claim 4 is characterized in that: The S4 specifically includes: S4.1: Position encoding of each Repatch in any Repatches obtained in S3; S4.2: Use the multi-head dot product attention mechanism to extract the feature information of each Repatch within the Repatches; The multi-head dot product attention mechanism includes multiple parallel attention layers; for each parallel attention layer, the initial features of each Repatch after position encoding are extracted using a single-head attention mechanism as the output of each parallel attention layer; the output of each parallel attention layer is connected, and a linear projection model is used to generate the output of the multi-head dot product attention mechanism; S4.3: The output of the multi-head dot product attention mechanism is connected using the residual connection normalized by the accompanying layer; S4.4: Use the feedforward network to extract richer semantic information for each Repatch; The feedforward network includes two linear transformations and a GeLU activation of an intermediate layer; the first linear transformation linearly maps the output of S4.3 to a high-dimensional space, obtains the intermediate weights through GeLU activation, and then obtains the output of the feedforward network through another linear transformation; S4.5: The output of the feedforward network is connected with the residual of the accompanying layer normalization to generate feature information of each Repatch, and obtain the global feature information within the Repatches; S4.6: Repeat S4.1-S4.5 for all Repatches to extract global feature information between different Repatches.

6. The long-term time series prediction method based on time series block repair according to claim 5 is characterized in that: The S5 specifically includes: S5.1: Put the global feature information obtained in S4 into the Flatten layer to flatten these features into a one-dimensional form; S5.2: Use a fully connected network to connect these one-dimensional global feature information with the input Repatches to form a new time series; S5.3: Linearly map the new time series to obtain a time series that matches the length of the expected time series.

7. The long-term time series prediction method based on time series block repair according to claim 1 is characterized in that: The long-term time series datasets include four ETT datasets, a Weather dataset, an Electricity dataset, a Traffic dataset and an ILI dataset.

8. A long-term time series prediction system based on time series block repair, characterized in that: Includes Preprocessing module, Representor module, Extractor module and Predictor module; The Preprocessing module is used to preprocess the historical observation time series in the collected long-term time series data set and divide the preprocessed historical observation time series into continuous time block sequences Patches, each of which is composed of a number of time block Patches; The Representor module is used to reconstruct the time relationship and local semantic information of each patch in any of the Patches and linearly map them to the input dimension required by the Extractor module to obtain a new time block Repatch, and connect each Repatch to obtain a new time block sequence Repatches; The Extractor module is used to process the Repatches obtained by the Representor module using a multi-head dot product attention mechanism to extract rich global feature information between different Repatches; The Predictor module is used to flatten the global feature information processed by the Extractor module into a one-dimensional form, and connect the one-dimensional global feature information with the input Repatches, and finally obtain a time series matching the expected length.

9. The long-term time series prediction system based on time series block repair according to claim 8, characterized in that: The Extrator module is composed of several identical parallel layers, each of which includes an attention module and a feedforward network module; the attention module uses a multi-head dot product attention mechanism to extract the feature information of each Repatch inside Repatches; the feedforward network module includes two linear transformations and GeLU activation of the intermediate layer, one of which linear transformation linearly maps the features extracted by the attention module to a high-dimensional space, obtains the intermediate weights through GeLU activation, and then obtains richer semantic information of each Repatch as the output of the feedforward network through another linear transformation, and finally obtains the global feature information inside the Repatches.

10. The long-term time series prediction system based on time series block repair according to claim 8, characterized in that: The Predictor module includes a Flatten layer and a fully connected network; the Flatten layer flattens the global feature information processed by the Extractor module into a one-dimensional form; the fully connected network connects the one-dimensional global feature information with the input Repatches.

Citation Information

Cited By

  • Electric submersible pump well yield prediction method fusing electric submersible pump mechanism and large language model

    CN119378767A

  • Large model optimization method and system based on sequence-dependent hierarchical propagation mechanism

    CN120066802A

  • Electric power carbon emission factor dynamic uncertainty evaluation method

    CN121481217A