Time series data prediction method and device and storage medium
Through the time series data prediction method, the many-to-one hierarchical architecture of the encoder and decoder is used to solve the problem of low efficiency and low accuracy of fine-grained long-period time series data prediction, and achieve efficient and accurate prediction of cloud platforms and traffic flow. , reducing cold starts and resource waste.
Patent Information
- Application Number
- CN202310238123.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-03
- Publication Date
- 2024-09-03
AI Technical Summary
When existing timing prediction technology processes fine-grained long-period timing data, the prediction efficiency is low and the accuracy is not high. It cannot effectively adapt to the needs of container resource scheduling in cloud platforms, resulting in an increase in the number of cold starts and a waste of computing resources.
A time series data prediction method is proposed. By obtaining the time series data of the current time period and multiple historical time periods, and using the many-to-one hierarchical link architecture of the encoder and decoder, the time series data is encoded to retain relative position information and change trend information. , reduce cumulative errors and achieve efficient and accurate fine-grained long-term forecasting.
It achieves efficient and accurate prediction of time series data such as cloud platform request traffic and traffic flow, reduces the number of cold starts of the cloud platform, reduces waste of computing resources, and improves processing efficiency and accuracy.
Smart Images

Figure CN118586536A
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a time series data prediction method, device and storage medium. Background Art
[0002] With the development of cloud computing, more and more developers are deploying their applications to cloud platforms (such as the serverless computing architecture of cloud platforms). This can save a lot of computing resource operation and maintenance costs, and developers can focus more on the code logic of the business without having to consider the complex configuration of the underlying computing resources. In this scenario, since cloud platforms usually use virtual machines or containers to deploy function instances, application code, etc., in order to process user requests from the user end, cloud platforms usually continue to maintain and run related computing resources (containers, code, etc.) for a period of time. If the container waits for a period of time and no user request arrives, the container and the related code and instances in the container will be cleared. Subsequent user requests that arrive again need to wait for the new container to be initialized and the relevant code to be loaded. This process is called cold start. Cold start greatly increases the execution delay of function instances and applications, and also significantly affects the overall performance of the cloud platform.
[0003] Therefore, it is necessary to schedule the number of containers running in the cloud platform to improve the processing performance of the cloud platform while reducing the operating costs. This is because if the number of configured containers is too small, the number of cold starts will increase, thereby reducing the overall processing performance (that is, increasing the request response delay). If too many containers are configured, it will lead to a waste of computing resources, because these excess computing resources will not provide services for received user requests, and will increase energy usage and operation and maintenance costs. Considering that the applications deployed on the cloud platform are usually oriented to user clients or IoT device services, with human participation, some request traffic for user services will show obvious periodic characteristics. Therefore, the traffic data collected historically can be used to predict the request traffic that may occur in the future, and this can be used to deduce the number of containers that the cloud platform needs to maintain in the future, and then the container resources of the cloud platform can be scheduled in advance to adapt to the request traffic in the future.
[0004] In the above traffic prediction scenario, there may be a situation where the granularity of data collection is much lower than the periodic trend of the data. For example, the data collection granularity is 1 data per second, while the data is periodic in "days". There are 86,400 seconds in a day, so the amount of data collected over multiple days is very large. This fine-grained and long-period sequence data arranged in time can be called time series data. However, the existing time series prediction technology is not suitable for the above-mentioned prediction scenarios of fine-grained and long-period time series data with a large amount of data, and there are problems of low prediction efficiency and low prediction accuracy. Summary of the invention
[0005] In view of this, a time series data prediction method, device and storage medium are proposed.
[0006] In a first aspect, an embodiment of the present application provides a method for predicting time series data, the method comprising: for a prediction time window set within a current time period for a target object to be predicted, obtaining current time series data collected within a current time window adjacent to the prediction time window within the current time period, and obtaining multiple groups of historical time series data collected respectively within the same target time window of multiple historical time periods, wherein the target time window includes the prediction time window and the current time window, and the time series data includes behavior data occurring at multiple time points within the time window for the target object; using multiple encoders to encode the multiple groups of historical time series data respectively to obtain multiple historical time series features corresponding to each of the multiple groups of historical time series data, each historical time series feature characterizing the relative position information and change trend information of each group of historical time series data within the target time window; using a decoder to determine the predicted time series data corresponding to the target object in the prediction time window based on the multiple historical time series features and the current time series data, the predicted time series data including the predicted behavior data of the target object at multiple time points within the prediction time window.
[0007] According to the embodiments of the present application, based on the prediction time window and the current time window, it is possible to know a priori which time series data in the historical time period are important; then, multiple encoders are used to respectively use the historical time series data of the target time windows of multiple historical time periods as input, and after encoding, the relative position information and change trend information of the historical time series data are output to different encoding layers of the decoder, so as to provide the decoder with an effective basis for time series prediction for a period of time in the future, that is, to use the important historical sequence data in each past target time window to predict the sequence trend of the prediction time window in the current time period, so that there is no need to use all the historical time series data in multiple historical time periods, and fine-grained long-period time series prediction can be achieved efficiently and accurately.
[0008] According to the first aspect, in a first possible implementation of the time series data prediction method, the decoder includes J decoding layers, each historical time series feature includes J sub-time series features, J is a positive integer, and the use of the decoder to determine the predicted time series data corresponding to the target object in the prediction time window according to the multiple historical time series features and the current time series data includes: inputting the current time series data and the first sub-time series feature of each historical time series feature into the first decoding layer of the decoder, and outputting the first predicted time series feature; inputting the j-1th predicted time series feature output by the j-1th decoding layer and the jth sub-time series feature of each historical time series feature into the jth decoding layer of the decoder, and outputting the jth predicted time series feature, j∈[2,J]; determining the predicted time series data according to the Jth predicted time series feature output by the Jth decoding layer of the decoder and the prediction time window.
[0009] According to an embodiment of the present application, by providing sub-time series features of multiple historical time series features to corresponding decoding layers respectively, that is, the encoder outputs partial feature information of historical time series data to different encoding layers of the decoder respectively, thereby providing an effective basis for the decoder to predict the time series for a period of time in the future, being able to retain the sequence information of the historical time series data, perceive the changing trend of long-term time series data, and reduce the impact of cumulative errors.
[0010] According to a first possible implementation method of the first aspect, the current time series data and the first sub-time series feature of each historical time series feature are input into the first decoding layer of the decoder, and the first predicted time series feature is output, including: encoding the current time series data to obtain the first encoded time series feature; determining the attention weights corresponding to the first sub-time series features of each historical time series feature according to the similarities between the first sub-time series features of each historical time series feature and the first encoded time series feature; and performing weighted summation of the first sub-time series features of each historical time series feature according to the attention weights corresponding to the first sub-time series features of each historical time series feature to obtain the first predicted time series feature.
[0011] According to the embodiments of the present application, the decoder can use historical time series data of shorter lengths for reasoning without using historical time series data of a complete time period as input; it can retain the relative position information and change trend information on the historical time series data, greatly reducing the impact of cumulative errors, making more accurate predictions, and searching and learning the similarities between the current time series data of the current time period and the historical time series data of the historical time period, and predicting the size of future time series data on a larger scale.
[0012] According to a first possible implementation method of the first aspect, the j-1th predicted time series feature output by the j-1th decoding layer and the j-th sub-time series feature of each historical time series feature are input into the j-th decoding layer of the decoder to output the j-th predicted time series feature, including: encoding the j-1th predicted time series feature to obtain the j-th encoded time series feature; determining the attention weights corresponding to the j-th sub-time series features of each historical time series feature according to the similarities between the j-th sub-time series features of each historical time series feature and the j-th encoded time series feature; and performing weighted summation of the j-th sub-time series features of each historical time series feature according to the attention weights corresponding to the j-th sub-time series features of each historical time series feature to obtain the j-th predicted time series feature.
[0013] According to the embodiments of the present application, the decoder can use historical time series data of shorter lengths for reasoning without using historical time series data of a complete time period as input; the relative position information and change trend information on the historical time series data can be retained, greatly reducing the impact of cumulative errors, making more accurate predictions, and searching and learning the similarities between the current time series data of the current time period and the historical time series data of the historical time period, and predicting the size of future time series data on a larger scale.
[0014] According to the first aspect, in a second possible implementation of the time series data prediction method, the encoder includes a feedforward network module and a multi-head self-attention mechanism module, the feedforward network module includes a Fourier transform convolution unit, the Fourier transform convolution unit is used to perform Fourier transform and convolution processing on the input features, and the multi-head self-attention mechanism module is used to generate historical time series features using the multi-head self-attention mechanism; wherein, the multiple encoders are used to encode the multiple groups of historical time series data respectively to obtain multiple historical time series features corresponding to the multiple groups of historical time series data, including: for the encoder corresponding to any group of historical time series data, the historical time series data is input into the feedforward network module of the encoder, and the intermediate time series features are output; the intermediate time series features and the historical time series data are input into the multi-head self-attention mechanism module, and the historical time series features corresponding to the historical time series data are output.
[0015] According to an embodiment of the present application, the use of a Fourier transform convolution unit in the encoder can make the sequence length of the input time series data flexibly variable, while extracting the feature information of the input data in the frequency domain and still maintaining the order information of the input time series data; in particular, the frequency information of the input time series data in the frequency domain can be used to establish connections between similar frequency components, thereby breaking through the limitation of the traditional convolution model that requires fixed input and output sizes.
[0016] According to the first aspect, in a third possible implementation of the time series data prediction method, the obtaining of the current time series data collected in the current time window adjacent to the prediction time window in the current time period includes: obtaining the current original time series data collected in the current time window, and folding the current original time series data into at least two-dimensional current time series data based on a preset folding rate, wherein the folding rate is used to indicate the scale of the folded sequence data in different dimensions, and the dimension of the current time series data is greater than the current original time series data; the obtaining of multiple groups of historical time series data collected respectively in the same target time window of multiple historical time periods includes: obtaining each group of historical original time series data collected in the same target time window in each historical time period, and folding each group of historical original time series data into at least two-dimensional historical time series data based on the preset folding rate, and the dimension of the historical time series data is greater than the historical original time series data.
[0017] According to the embodiments of the present application, the memory footprint of the entire prediction model (including the encoder and decoder) can be improved, allowing the encoder and decoder to process longer time series data and increase the length of the sequence that the model can consume, which is equivalent to increasing the parallel computing capacity of the model, that is, having a larger data throughput, thereby improving the processing efficiency of subsequent encoders and decoders. At the same time, no downsampling operations are required, which is beneficial to ensuring the accuracy of time series prediction.
[0018] According to the first aspect, in a fourth possible implementation of the time series data prediction method, the target object includes a user request; the behavior data includes a request flow of the user request, and the predicted time series data includes the request flow predicted for the user request at multiple time points within the prediction time window; after obtaining the predicted time series data, the method further includes: scheduling computing resources for processing the user request based on the request flow predicted for the user request at multiple time points within the prediction time window, so that the scheduled computing resources adapt to the predicted request flow.
[0019] According to the embodiments of the present application, predictions can be made for the request traffic of user requests, and the changing trends of traffic can be considered in three dimensions: long time series (weeks, months), periodicity (days), and real-time, to achieve more accurate, fine-grained, long-period time series predictions, which can reduce the number of cold starts of the cloud platform, bring low response latency to user requests, and reduce the waste of computing resources on the platform side.
[0020] According to the first aspect, in a fifth possible implementation of the time series data prediction method, the target object includes a traffic area; the behavior data includes the vehicle flow in the traffic area; the predicted time series data includes the vehicle flow predicted for the traffic area at multiple time points within the prediction time window; after obtaining the predicted time series data, the method further includes: adjusting the traffic signal timing scheme of the traffic lights in the traffic area within the prediction time window according to the vehicle flow predicted for the traffic area at multiple time points within the prediction time window, so that the adjusted traffic signal timing scheme adapts to the predicted vehicle flow.
[0021] According to the embodiments of the present application, the traffic flow in the traffic area can be predicted and the traffic signal configuration plan can be adjusted according to the predicted traffic flow, so that the adjusted traffic signal timing plan adapts to the predicted traffic flow, which can make the traffic in the entire traffic area smooth, increase the traffic flow rate and reduce traffic congestion.
[0022] In a second aspect, an embodiment of the present application provides a time series data prediction device, which includes: an acquisition module, which, in a prediction time window set for a target object to be predicted within a current time period, acquires current time series data collected within a current time window adjacent to the prediction time window within the current time period, and acquires multiple groups of historical time series data collected respectively within the same target time window of multiple historical time periods, wherein the target time window includes the prediction time window and the current time window, and the time series data includes behavior data occurring at multiple time points within the time window of the target object; an encoding module, which is used to use multiple encoders to encode the multiple groups of historical time series data respectively to obtain multiple historical time series features corresponding to each of the multiple groups of historical time series data, each historical time series feature characterizing the relative position information and change trend information of each group of historical time series data within the target time window; a decoding module, which is used to use a decoder to determine the predicted time series data corresponding to the target object in the prediction time window according to the multiple historical time series features and the current time series data, and the predicted time series data includes the predicted behavior data of the target object at multiple time points within the prediction time window.
[0023] According to the second aspect, in a first possible implementation of the time series data prediction device, the decoder includes J decoding layers, each historical time series feature includes J sub-time series features, J is a positive integer, and the use of the decoder to determine the predicted time series data corresponding to the target object in the prediction time window according to the multiple historical time series features and the current time series data includes: inputting the current time series data and the first sub-time series feature of each historical time series feature into the first decoding layer of the decoder, and outputting the first predicted time series feature; inputting the j-1th predicted time series feature output by the j-1th decoding layer and the jth sub-time series feature of each historical time series feature into the jth decoding layer of the decoder, and outputting the jth predicted time series feature, j∈[2,J]; determining the predicted time series data according to the Jth predicted time series feature output by the Jth decoding layer of the decoder and the prediction time window.
[0024] According to a first possible implementation method of the second aspect, the current time series data and the first sub-time series feature of each historical time series feature are input into the first decoding layer of the decoder to output the first predicted time series feature, including: encoding the current time series data to obtain the first encoded time series feature; determining the attention weights corresponding to the first sub-time series features of each historical time series feature according to the similarities between the first sub-time series features of each historical time series feature and the first encoded time series feature; and performing weighted summation of the first sub-time series features of each historical time series feature according to the attention weights corresponding to the first sub-time series features of each historical time series feature to obtain the first predicted time series feature.
[0025] According to a first possible implementation method of the second aspect, the j-1th predicted time series feature output by the j-1th decoding layer and the j-th sub-time series feature of each historical time series feature are input into the j-th decoding layer of the decoder to output the j-th predicted time series feature, including: encoding the j-1th predicted time series feature to obtain the j-th encoded time series feature; determining the attention weights corresponding to the j-th sub-time series features of each historical time series feature according to the similarities between the j-th sub-time series features of each historical time series feature and the j-th encoded time series feature; and performing weighted summation of the j-th sub-time series features of each historical time series feature according to the attention weights corresponding to the j-th sub-time series features of each historical time series feature to obtain the j-th predicted time series feature.
[0026] According to the second aspect, in a second possible implementation of the time series data prediction device, the encoder includes a feedforward network module and a multi-head self-attention mechanism module, the feedforward network module includes a Fourier transform convolution unit, the Fourier transform convolution unit is used to perform Fourier transform and convolution processing on the input features, and the multi-head self-attention mechanism module is used to generate historical time series features using the multi-head self-attention mechanism; wherein, the multiple encoders are used to encode the multiple groups of historical time series data respectively to obtain multiple historical time series features corresponding to the multiple groups of historical time series data, including: for the encoder corresponding to any group of historical time series data, the historical time series data is input into the feedforward network module of the encoder, and the intermediate time series features are output; the intermediate time series features and the historical time series data are input into the multi-head self-attention mechanism module, and the historical time series features corresponding to the historical time series data are output.
[0027] According to the second aspect, in a third possible implementation of the time series data prediction device, the obtaining of the current time series data collected in the current time window adjacent to the prediction time window in the current time period includes: obtaining the current original time series data collected in the current time window, and folding the current original time series data into at least two-dimensional current time series data based on a preset folding rate, wherein the folding rate is used to indicate the scale of the folded sequence data in different dimensions, and the dimension of the current time series data is greater than the current original time series data; the obtaining of multiple groups of historical time series data collected respectively in the same target time window of multiple historical time periods includes: obtaining each group of historical original time series data collected in the same target time window in each historical time period, and folding each group of historical original time series data into at least two-dimensional historical time series data based on the preset folding rate, and the dimension of the historical time series data is greater than the historical original time series data.
[0028] According to the second aspect, in a fourth possible implementation of the time series data prediction device, the target object includes a user request; the behavior data includes a request flow of the user request, and the predicted time series data includes the request flow predicted for the user request at multiple time points within the prediction time window; after obtaining the predicted time series data, the device further includes: a scheduling module for scheduling computing resources for processing the user request according to the request flow predicted for the user request at multiple time points within the prediction time window, so that the scheduled computing resources adapt to the predicted request flow.
[0029] According to the second aspect, in a fifth possible implementation of the time series data prediction device, the target object includes a traffic area; the behavior data includes the vehicle flow in the traffic area; the predicted time series data includes the vehicle flow predicted for the traffic area at multiple time points within the prediction time window; after obtaining the predicted time series data, the device further includes: an adjustment module for adjusting the traffic signal timing scheme of the traffic lights in the traffic area within the prediction time window according to the vehicle flow predicted for the traffic area at multiple time points within the prediction time window, so that the adjusted traffic signal timing scheme adapts to the predicted vehicle flow.
[0030] In a third aspect, an embodiment of the present application provides a time series data prediction device, which includes: a processor; a memory for storing processor executable instructions; wherein the processor is configured to implement the above-mentioned first aspect or one or more of the multiple possible implementation methods of the first aspect when executing instructions.
[0031] In a fourth aspect, an embodiment of the present application provides a non-volatile computer-readable storage medium having computer program instructions stored thereon. When the computer program instructions are executed by a processor, the method for predicting time series data of the above-mentioned first aspect or one or more of the multiple possible implementation methods of the first aspect is implemented.
[0032] In a fifth aspect, an embodiment of the present application provides a terminal device that can execute the time series data prediction method of the above-mentioned first aspect or one or several possible implementation methods of the first aspect.
[0033] In the sixth aspect, an embodiment of the present application provides a computer program product, including a computer-readable code, or a non-volatile computer-readable storage medium carrying a computer-readable code. When the computer-readable code runs in an electronic device, the processor in the electronic device executes the time series data prediction method of the above-mentioned first aspect or one or several of the multiple possible implementation methods of the first aspect.
[0034] These and other aspects of the present application will become more apparent from the following description of the embodiment(s). BRIEF DESCRIPTION OF THE DRAWINGS
[0035] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate exemplary embodiments, features, and aspects of the present application and, together with the description, serve to explain the principles of the present application.
[0036] FIG. 1( a ), FIG. 1( b ) and FIG. 1( c ) are schematic diagrams showing application scenarios according to an embodiment of the present application.
[0037] Figure 2 A flowchart of a time series data prediction method according to an embodiment of the present application is shown.
[0038] Figure 3 A schematic diagram showing the changing trends of multiple groups of historical time series data according to an embodiment of the present application.
[0039] Figure 4 A schematic structural diagram of an encoder according to an embodiment of the present disclosure is shown.
[0040] Figure 5 A schematic diagram of the processing process of a Fourier transform convolution unit according to an embodiment of the present application is shown.
[0041] Figure 6 A schematic diagram of the structure of an encoder and a decoder according to an embodiment of the present application is shown.
[0042] Figure 7 A schematic diagram showing the processing process of the long-term attention mechanism module according to an embodiment of the present application is shown.
[0043] Figure 8 A schematic diagram of the framework of a time series data prediction system according to an embodiment of the present application is shown.
[0044] Fig. 9 A structural diagram of a time series data prediction device according to an embodiment of the present application is shown.
[0045] Fig.10 A structural diagram of an electronic device 1300 according to an embodiment of the present application is shown. DETAILED DESCRIPTION
[0046] Various exemplary embodiments, features and aspects of the present application will be described in detail below with reference to the accompanying drawings. The same reference numerals in the accompanying drawings represent elements with the same or similar functions. Although various aspects of the embodiments are shown in the accompanying drawings, the drawings are not necessarily drawn to scale unless otherwise specified.
[0047] The word “exemplary” is used exclusively herein to mean “serving as an example, example, or illustration.” Any embodiment described herein as “exemplary” is not necessarily to be construed as preferred or advantageous over other embodiments.
[0048] In addition, in order to better illustrate the present application, numerous specific details are given in the following specific embodiments. It should be understood by those skilled in the art that the present application can also be implemented without certain specific details. In some examples, methods, means, components and circuits well known to those skilled in the art are not described in detail in order to highlight the subject matter of the present application.
[0049] In order to better understand the solutions of the embodiments of the present application, the relevant terms and concepts that may be involved in the embodiments of the present application are first introduced below.
[0050] (1) Serverless computing Serverless, also known as Function as a Service (FaaS), is a cloud computing model based on Platform as a Service (PaaS). Serverless computing provides a micro-architecture. End users do not need to deploy, configure, or manage servers. The servers required for program operation are all provided by the cloud platform.
[0051] (2) Recurrent Neural Network (RNN) is a type of recursive neural network that takes sequence data as input, recursively in the direction of sequence evolution, and all nodes (recurrent units) are connected in a chain.
[0052] (3) Time series data (also known as time series data) refers to sequence data sorted by time, which can generally be obtained by sampling at preset time intervals and can reflect the changes of data over time. The prediction task of time series data refers to predicting future observations based on the laws contained in the time series data itself.
[0053] (4) Fine-grained and long-periodic time series data: The granularity of time series data collection is much lower than the periodic trend in the time series data (for example, 1 data per second, with a period of day, and 86,400 seconds in a day), that is, the prediction task is fine-grained and has long-periodic time series data.
[0054] (5) Seq2seq is a variant of a recurrent neural network, consisting of an encoder and a decoder. Seq2Seq is an important model in natural language processing and can be used in machine translation, dialogue systems, automatic summarization, and other scenarios.
[0055] (6) Transformer is a classic model for natural language processing (NLP). It uses a self-attention mechanism and does not adopt the sequential structure of RNN, which allows the model to be trained in parallel and has global information.
[0056] (7) Self-Attention Mechanism: This mechanism is mainly composed of three values, K, V, and Q, belonging to each minimum unit in the input sequence (for example, a single value at a certain time point in the time series). The dot product of Q and K represents the similarity between Q and K. Then the softmax function is used to normalize the similarity between Q and K. The normalized result is a weight matrix with all values between 0 and 1 (which can be understood as an attention score matrix). V represents the features after the linear transformation of the input. Then multiplying the weight matrix by V can obtain the filtered V features. In short, the introduction of Q and K is to obtain a weight matrix with all values between 0 and 1, and the introduction of V is to retain the input features. That is, Q, K, and V represent input information, key information, and return information, respectively. The weight of the key information is obtained by vector product in the input information, and the weight matrix of the key information is multiplied by the return information mapped by the key information to obtain the final result.
[0057] (8) Multi-head Self-attention mechanism: Compared with the Self-Attention mechanism, multiple groups of Q, K, and V are used to perform multiple calculations according to the above self-attention mechanism, that is, multiple heads are obtained. Then, the results of multiple calculations are concatenated and a linear transformation is performed to obtain the value as the result of the multi-head self-attention mechanism.
[0058] As mentioned above, in the above traffic prediction scenario, there may be a situation where the granularity of data collection is much lower than the periodic trend of the data. For example, the data collection granularity is 1 data per second, while the data is periodic in "days". There are 86,400 seconds in a day, so the amount of data collected over multiple days is very large. This fine-grained and long-period sequence data arranged in time can be called time series data. However, the existing time series prediction technology is not suitable for the above-mentioned prediction scenarios of fine-grained and long-period time series data with a large amount of data, and there are problems of low prediction efficiency and low prediction accuracy.
[0059] For example, the above-mentioned Transformer model can be used for time series prediction in the prior art, but Transformer is mainly suitable for coarse-grained data (for example, data points of 10s or 100s per period). Because the complexity of the internal attention mechanism of Transformer is usually positively correlated with the square of the sequence length, the effective sequence length that can be input will be greatly increased due to the long sequence length of fine-grained and long-period time series data (that is, the amount of data is large), which affects the processing efficiency of Transformer. Another shortcoming of the transformer-based prediction model is the time invariance of the self-attention mechanism in Transformer. Time invariance means that the inherent order of the input sequence is not retained when calculating attention. This property can be used in natural language processing or computer vision, but for the prediction scenario of time series data, time invariance is a very fatal problem, because the value of the time series at a certain time node in the future is often more correlated with the value of the most recent period of time, and the self-attention model needs to be greatly improved to adapt to the prediction scenario of long time series.
[0060] Another existing technology can also use the AutoFormer model, which is an improved version based on the Transformer model. It mainly performs a series of model optimizations for the prediction problem of periodic time series data. It mainly uses the periodicity of the autocorrelation learning time series, and combines long-term trend prediction to accurately predict the series within a future time window. Although AutoFormer has made certain optimizations for time series data with periodicity, AutoFormer still requires continuous and complete sequence data within multiple periods as input, and the amount of training and reasoning data is huge, which undoubtedly increases the complexity of the model and the delay of training and reasoning. Therefore, the AutoFormer solution is not applicable in the scenario of traffic prediction of the above-mentioned cloud platform, because periodic traffic prediction requires concurrent prediction of traffic data of several functions. If the inference delay of the model is too high, the effective prediction data length that can be used by the scheduler will be shorter (because some time needs to be reserved for network data communication, function instance cold start and data aggregation time), and the accuracy will be lower. A potential solution is to use down-sampling to further aggregate the data, such as aggregating second-level traffic data into minute-level or hour-level data, and then restore the original data accuracy through certain means after the prediction is completed. However, down-sampling is lossy and will inevitably produce lower quality prediction results.
[0061] In summary, current time series prediction technology is not suitable for fine-grained, long-period time series data, which includes the prediction of long-term data trends, and cannot take into account both prediction efficiency and prediction accuracy. For such time series data, existing end-to-end models cannot consider long-term trends, periodicity, and short-term fluctuation details in a unified model. In existing technologies, either the sequence order is maintained through a fixed-length seq2seq model (not suitable for fine-grained long-term data), or RNN is used (prone to error accumulation), or transformers based on attention mechanisms are used. Although transformers have shown superior performance in many tasks (including some prediction tasks), their inherent time invariance is not suitable for continuous or ordered time series data.
[0062] In view of this, the embodiment of the present application provides a time series data prediction method, which can be applicable to fine-grained long-period time series data prediction scenarios. According to the time series data prediction method of the embodiment of the present application, the periodic characteristics of the time series data can be used to calculate the correlation between different historical time periods and the current time period that needs to be predicted. Based on the different weight values of different historical time periods, the traffic trend of a long time span is perceived, and the traffic size for a period of time in the future is predicted; a many-to-one layered link architecture of multiple encoders and decoders is adopted, wherein the multiple encoders respectively use the historical time series data of the target time window in multiple historical time periods as input, and after encoding, they output part of the time series information of the historical time series data to different coding layers of the decoder, so as to provide the decoder with an effective basis for predicting the time series data for a period of time in the future; the low-dimensional time series data is folded into high-dimensional time series data to increase the data throughput of the encoder and decoder, and speed up the calculation and reasoning speed; Fourier transform convolution (FFT) is also used CONV) operation to process the historical time series data in the target time window in the past several historical time periods and the current time series data in the current time window in the current time period (such as the real-time traffic of the day), so as to extract the time series features in the frequency domain dimension without fixedly limiting the size of the input and output.
[0063] The time series data prediction method of the embodiment of the present application can be adapted to, but not limited to, the prediction of various time series data with periodic characteristics, such as the request flow of user requests and the vehicle flow in the traffic area, and can accurately and efficiently predict the request flow and vehicle flow in a certain period of time in the future. The following briefly introduces several application scenarios of the time series data prediction method of the embodiment of the present application. Figure 1(a), Figure 1(b) and Figure 1(c) show schematic diagrams of application scenarios according to an embodiment of the present application.
[0064] Among them, Figure 1(a) represents a prediction scenario of request traffic in a certain cloud platform. As shown in Figure 1(a), the cloud platform includes: a request-level load balancing scheduler, a data storage and aggregation system, a time series data prediction system, and a computing resource-level load balancing scheduler; the time series data prediction method of the embodiment of the present application can be applied to the time series data prediction system of the cloud platform; wherein, the request-level load balancing scheduler is used to distribute user requests to the containers (pods) of each computing node (node) in the computing resource cluster for user requests in the user request queue, generate traffic log data of user requests, etc., the data storage and aggregation system is equivalent to a big data processing platform, which is used to store and aggregate traffic log data of user requests, that is, to store and aggregate historical request traffic at each time point; the time series data prediction system can trigger request traffic prediction at a regular interval, When triggering request traffic prediction, the relevant interface can be called to query the historical request traffic in the target time period of the past few days from the data storage and aggregation system, as well as the current request traffic generated in real time in the current time window. Then, based on the historical request traffic in the past few days and the current request traffic, the request traffic in the future time window can be predicted. For example, the request traffic per second in the next 20 minutes can be predicted. The time series data prediction system can send the predicted request traffic to the load balancing scheduler at the computing resource level. The load balancing scheduler at the computing resource level is used to schedule the number of containers running in the computing node according to the request traffic predicted by the time series data prediction system. For example, if the predicted request traffic increases, more containers can be started in advance to reduce the service response time of user requests. If the predicted request decreases, some containers can be closed in advance to reduce the waste of computing resources on the cloud platform.
[0065] Figure 1(b) represents a prediction scenario of request traffic in another cloud platform. As shown in Figure 1(b), the cloud platform includes: a load balancing system, a data plane cluster system and a time series data prediction system; in addition, the cloud platform can communicate with the storage systems and big data processing systems of other platforms; the time series data prediction method of the embodiment of the present application can be applied to the time series data prediction system of the cloud platform; wherein, the load balancing system is used to record the traffic logs requested by users, the data plane cluster system is used to manage the life cycle of the function instances corresponding to the user requests, the cloud storage system is used to store the traffic logs requested by users, and the big data processing system is used to aggregate the traffic logs stored in the cloud storage module and the traffic data after cache processing.
[0066] The request traffic prediction process of the cloud platform based on the above FIG. 1(b) may include: after the user request reaches the load balancing system of the cloud platform, the load balancing system records the traffic data of the function instance corresponding to the user request in the traffic log (for example, the request traffic per second), and after collecting the traffic data in the traffic log, writes the traffic log into the cloud storage system; the time series data prediction system periodically calls the relevant interface of the big data processing module to query and obtain the time series data in a certain time window in the past few days (including the historical request traffic of the target time window and the current request traffic of the current time window), the big data processing system can aggregate the time series data to be queried by the time series data prediction system, and send the aggregated time series data to the time series data prediction system; the time series data prediction system can also further query the time series data based on the aggregated time series data According to the analysis of the periodic characteristics of the request traffic, function instances whose request traffic does not have periodic characteristics are filtered out, that is, user requests that do not have periodic characteristics are filtered out; the time series data prediction system then uses the time series characteristic prediction method of the embodiment of the present application to predict the request traffic data of a future time window based on the time series data of user requests with periodic characteristics. For example, the request traffic per second in the next 10 minutes can be predicted, and the predicted request traffic data is pushed to the load balancing system. The load balancing system sends a scheduling instruction to the data plane cluster system according to the peak traffic in the future period indicated in the predicted request traffic data, so as to schedule the function instance corresponding to the user request, such as pre-pulling the function instance to reduce the service response time of the user request, or pre-shrinking the function instance to reduce the waste of computing resources of the cloud platform.
[0067] In actual applications, the prediction function of the request traffic in the cloud platform can be displayed in the form of a traffic prediction switch on the configuration page of the cloud platform. Users can choose whether to set the traffic prediction to be turned on. It should be understood that if the user turns on the traffic prediction, the traffic prediction can be performed according to the prediction process of Figure 1 (a) and Figure 1 (b) above. When the traffic prediction is turned on, the time series data prediction system deployed in the above cloud platform can be used to make predictions on the request traffic of the user's request, and at the same time, the traffic change trend is considered in three dimensions: long time series (such as weeks and months), periodicity (days), and real-time, so as to achieve more accurate and fine-grained long-term time series prediction, thereby reducing the number of cold starts of the cloud platform, bringing low response delay to users, and reducing the waste of computing resources on the cloud platform side.
[0068] FIG1(c) represents a prediction scenario of traffic flow in a certain traffic area. As shown in FIG1(c), the time series data prediction system 100 of the embodiment of the present application can be deployed on a terminal device (e.g., a personal computer) or a server (e.g., a cloud server); when a user expects to predict the traffic flow at multiple time points in a certain future time window, for example, the traffic flow per minute within 1 hour after the current time point (e.g., 8:00), that is, the traffic flow per minute from 8:00 to 9:00, the current traffic flow collected in real time within 1 hour before the current time point, that is, the traffic flow per minute between 7:00 and 8:00, and the historical traffic flow per minute from 7:00 to 9:00 for several days can be input into the time series data prediction system 100; the time series data prediction system 100 The time series data prediction method of the embodiment of the present application can be used to predict traffic flow based on the above-mentioned current traffic flow and historical traffic flow, and output the traffic flow prediction for each minute between 8:00 and 9:00 on the same day; then, based on the predicted traffic flow, the traffic signal timing scheme of the traffic lights in the traffic area within the predicted time window can be adjusted. The traffic signal timing scheme is used to control the change timing of different traffic signals in the traffic lights, so that the traffic signal configuration scheme can adapt to the traffic flow changes in the traffic area. For example, for intersections with a large predicted traffic flow, the green light duration of these intersections can be increased (that is, the passage time can be increased), and / or the red light duration can be shortened (that is, the waiting time can be shortened), etc., so as to make the traffic in the entire traffic area smooth, increase the traffic flow rate and reduce traffic congestion.
[0069] The time series data prediction method of the embodiment of the present application can be deployed on various terminal devices through software or hardware modification. The terminal device involved in the present application can refer to a device with a wireless connection function. The function of wireless connection refers to the ability to connect to other terminal devices through wireless connection methods such as wifi and Bluetooth. The terminal device of the present application can also have the function of communicating through a wired connection. The terminal device of the present application can be a touch screen, a non-touch screen, or a screen-free device. The touch screen can control the terminal device by clicking and sliding on the display screen with a finger or a stylus. The non-touch screen device can be connected to an input device such as a mouse, a keyboard, a touch panel, etc., and the terminal device can be controlled by the input device. For example, the device without a screen can be a Bluetooth speaker without a screen. For example, the terminal device of the present application can be a smart phone, a netbook, a tablet computer, a laptop, a wearable electronic device (such as a smart bracelet, a smart watch, etc.), a TV, a virtual reality device, a stereo, an electronic ink, and the like.
[0070] The time series data prediction method of the embodiment of the present application can also be deployed on a server, which can be located in the cloud or locally, and can be a physical device or a virtual device, such as a virtual machine, a container, etc., with a wireless communication function, wherein the wireless communication function can be set in the chip (system) or other parts or components of the server. It can refer to a device with a wireless connection function, and the function of wireless connection refers to the ability to connect to other servers or terminal devices through wireless connection methods such as Wi-Fi and Bluetooth. The server of the present application may also have the function of communicating through a wired connection. For example, the server of the present application can be located in the cloud, communicate with the terminal device, receive the traffic flow data (including the above-mentioned historical traffic flow and current traffic flow) sent by the terminal device, and use the time series data prediction method deployed on the server to output the predicted traffic flow, and return it to the terminal device, so that the user of the terminal device can adjust the traffic signal configuration plan based on the predicted traffic flow.
[0071] The following Figure 2-Figure 8 , a detailed introduction is given to the time series data prediction method provided in the embodiment of the present application.
[0072] Figure 2 A flowchart of a time series data prediction method according to an embodiment of the present application is shown. The method can be used in the above-mentioned time series data prediction system, and the method can be executed by the above-mentioned terminal device or server, such as Figure 2 As shown, the method includes:
[0073] Step S201, for the prediction time window set for the target object to be predicted in the current time period, obtain the current time series data collected in the current time window adjacent to the current time window in the current time period, and obtain multiple groups of historical time series data collected respectively in the same target time window of multiple historical time periods, wherein the target time window includes the prediction time window and the current time window.
[0074] Among them, the target object can be understood as the object of the time series data to be predicted, such as the user request and traffic area in the above-mentioned application scenario, which is not limited in the embodiments of the present application. The time series data includes the behavior data of the target object at multiple time points in the time window, such as the request flow of the user request per second within 10 minutes, the traffic flow per minute in the traffic area within 1 hour, etc. It should be understood that the embodiments of the present application do not limit the collection granularity of the time series data and the statistical method of the time series data. For example, the traffic flow can be collected and counted at the minute level, and the request flow can be collected and counted at the second level.
[0075] Among them, the current time period is also the latest time period. For example, the current time period with "day" as the period unit can be the current day. It should be understood that the embodiment of the present application does not limit the period unit of the time period, which depends on the periodic characteristics of the time series data of the target object. For example, if the request traffic requested by the user shows a periodic change trend in "day" as the unit, then the period unit is "day". If the traffic flow in the traffic area shows a periodic change trend in "12 hours", then the period unit is "12 hours". The current time period is also the latest 12 hours.
[0076] Among them, the prediction time window can be understood as the upcoming future time window. In actual applications, the user can pre-set the length of the prediction time window according to actual needs. The specific range of the prediction time window depends on the current time point to be predicted. For example, the length of the prediction time window can be set to 10 minutes. If the current time point is 8:00, the prediction time window can be 8:00 to 8:10.
[0077] Among them, the current time window is the time window adjacent to the predicted time window in the current time period, that is, the current time window and the predicted time window are in the same current time period, and the length of the current time window can also be pre-set. It should be understood that the length of the current time window and the length of the predicted time window can be the same or different. For example, the length of the current time window can be set to 1 hour. If the predicted time window is 8:00 to 8:10, the current time window can be 7:00 to 8:00. It should be understood that the current time series data collected in the current time window can be understood as the behavior data that has occurred in the current time window, or the behavior data that has occurred in the time window adjacent to the predicted time window. The current time series data can be used to more accurately predict the time series data in any predicted time window.
[0078] The specific number of multiple historical time periods can be set according to actual needs, for example, it can be set to any value between 3 and 10, which is not limited in the embodiment of the present application. It should be understood that the period unit of the historical time period is the same as the period unit of the current time period. For example, if the period unit is "day", multiple groups of historical time series data collected in the same target time window in the past 3 days can be obtained.
[0079] Among them, the length and range of the target time window depend on the length and range of the prediction time window and the predicted time window together. For example, if the prediction time window is 8:00 to 8:10 and the current time window is 7:00 to 8:00, then the target time window is 7:00 to 8:10, and 3 groups of historical request traffic collected from 7:00 to 8:10 in the past 3 days can be obtained. Each group of historical request traffic can include the request traffic generated every minute from 7:00 to 8:10 every day.
[0080] Considering that the original time series data actually collected is usually a one-dimensional sequence, the sequence length of each time series data to be processed is relatively long, which will affect the processing efficiency of subsequent encoders and decoders. In a possible implementation, the current time series data collected in the current time window adjacent to the prediction time window in the current time period is obtained, including: obtaining the current original time series data collected in the current time window, and folding the current original time series data into at least two-dimensional current time series data based on a preset folding rate, wherein the dimension of the current time series data is greater than that of the current original time series data; and,
[0081] The method of obtaining multiple groups of historical time series data collected in the same target time window of multiple historical time periods includes: obtaining each group of historical original time series data collected in the same target time window in each historical time period, and folding each group of historical original time series data into at least two-dimensional historical time series data based on a preset folding rate, and the dimension of the historical time series data is greater than the historical original time series data. In this way, the encoder and decoder can process longer time series data, that is, have a larger data throughput, thereby improving the processing efficiency of subsequent encoders and decoders, and no downsampling operation is required, which is conducive to ensuring the accuracy of time series prediction.
[0082] Among them, the folding rate is used to indicate the scale of the converted sequence data in different dimensions, for example, it can indicate the length or height in a two-dimensional scale, and can also indicate the length, height and / or width in a three-dimensional scale, etc.; folding means using a preset folding rate to convert low-dimensional data into higher-dimensional data, for example, converting one-dimensional data into two-dimensional data, or three-dimensional data, etc.
[0083] Exemplarily, if one-dimensional original sequence data is folded into two-dimensional sequence data with a folding rate F, the scale of the original sequence data can be converted from [original_length] to [original_length / F,F]. For example, if the one-dimensional sequence data {1,2,3,4,5,6} is folded with a folding rate of 3, a two-dimensional sequence data (i.e., a two-dimensional matrix) of [[1,2,3],[4,5,6]] can be obtained. The length of the one-dimensional sequence data is 6, the length of the two-dimensional sequence data is 6 / 3=2, and the height is 3.
[0084] It should be understood that the above-mentioned folding operation can improve the memory footprint of the entire prediction model (including the encoder and decoder), thereby allowing the entire prediction model to allow longer time series data as input. This is because the model includes an attention mechanism based on dot products, and the attention mechanism based on dot products is positively correlated with the square of the sequence length. Therefore, the folding operation can increase the sequence length that the model can consume without losing time series data, which is equivalent to increasing the parallel computing capacity of the model, and will also speed up the training and reasoning speed of the entire prediction model.
[0085] Optionally, if the folded time series data still does not satisfy the dimension that the encoder can process, the folded time series data can be further encoded into a model dimension that the encoder can process, which is not limited in this embodiment of the present application.
[0086] Step S202, using multiple encoders to encode multiple groups of historical time series data respectively, to obtain multiple historical time series features corresponding to each of the multiple groups of historical time series data, each historical time series feature represents the relative position information and change trend information of each group of historical time series data within the target time window.
[0087] The number of encoders may depend on the number of groups of historical time series data. Multiple groups of historical time series data may be encoded simultaneously using multiple encoders, which may improve the encoding efficiency and thus the prediction efficiency of time series data. The encoder may be used to extract and retain the relative position information and change trend information in the historical time series data, so that the decoder may make comprehensive use of the relative position information and change trend information in multiple historical time series features for prediction, and thus obtain more accurate prediction results in long-term time series prediction tasks.
[0088] Among them, the relative position information represents the relative position relationship of the historical time series data at each time point in the target time window, or in other words, it represents the contextual relationship between the historical time series data at each time point; the change trend information represents the change trend of the historical time series data at each time point in the target time window, for example Figure 3 The middle curve shows the changing trends of multiple groups of historical time series data within the target time window, that is, the changing trend information corresponding to each group of historical time series data can represent Figure 3 The curves in each target time window show the changing trend.
[0089] Figure 4 A schematic diagram of the structure of an encoder according to an embodiment of the present application is shown. Figure 4As shown, the encoder may include multiple encoding layers, each encoding layer may include a feedforward network module and a multi-head self-attention mechanism module, wherein the feedforward network module may include at least one of the following: a convolution (CONV) unit, a fully connected unit (also known as dense projection), a Fourier transform convolution (FFT CONV) unit, an inverse Fourier transform (iFFT, also known as inverse Fourier transform) unit, a random inactivation (dropout) unit, and multiple activation function units; the multi-head self-attention mechanism module may include at least one of the following: a skip connection unit, i.e., "+", a normalization (layer norm) unit, and a multi-head self-attention mechanism (Multi-head Self-attention) unit.
[0090] Among them, the convolution unit is used to perform convolution processing on the input, the fully connected unit is used to perform dense mapping processing on the input, the Fourier transform convolution unit is used to perform Fourier transform and convolution processing on the input features, the inverse Fourier transform unit is used to perform inverse Fourier transform on the input, the random deactivation unit is used to randomly deactivate some nodes in the encoder to optimize the encoder to prevent the encoder from overfitting, and the activation function unit is used to activate the input using an activation function (such as Gelu function, Relu function, etc.). It should be understood that other units in the feedforward network module except the Fourier transform convolution unit may be optional units, and those skilled in the art can adaptively adjust the model structure of the feedforward network module under the guidance of the embodiments of the present application, for example, the random deactivation unit can be removed, or any processing unit known in the art can be added, which is not limited to the embodiments of the present application.
[0091] Using FFT CONV in the encoder can make the sequence length of the input time series data flexible and variable, and at the same time, the FFT CONV structure can extract the feature information of the input data in the frequency domain, and still maintain the order information of the original time series data; wherein, the Fourier transform of FFT CONV can transform the input data from the time domain to the frequency domain, and then the one-dimensional convolution operator (including the parameters obtained through training) integrates, enhances and other convolution processes on the data in the frequency domain space, and then the inverse Fourier transform (iFFT) unit can be used to restore the frequency domain features to the time domain features. The feedforward network module using FFT CONV can use the frequency information of the input data in the frequency domain to establish connections between similar frequency components, so as to break through the limitation of the traditional convolution model that requires fixed input and output sizes.
[0092] Among them, Figure 5As shown, the processing process of the FFT CONV unit may include: firstly, Fourier transform FFT processing is performed on the input time domain data, and then the transformed data is input into a standard one-dimensional convolution kernel. The convolution operator using the one-dimensional convolution kernel can realize flexible and variable input and output sequence lengths. Due to the nature of convolution, the FFT CONV unit can be used to capture the relationship between the strengths of similar frequency signals in the frequency domain, and still maintain the order information of the original time series data. Of course, standard time-based convolution can also be used to extract the correlation of the time series within each cycle, so that the correlation information is not lost in the subsequent processing process.
[0093] It should be noted that the Fourier transform mentioned in the embodiments of the present application may include but is not limited to: discrete Fourier transform (such as fast Fourier transform), continuous Fourier transform and other Fourier transform operations. Those skilled in the art can design the Fourier transform operation used in the encoder according to actual needs, and the embodiments of the present application are not limited to this.
[0094] Among them, the multi-head self-attention mechanism module is used to generate historical time series features using the multi-head self-attention mechanism. Specifically, the first jump connection in the module is used to add the input of the encoding layer to the features output by the feedforward network module, and then the features after the jump connection are input to the first normalization unit. The second jump connection is used to add the features output by the first normalization unit to the features output by the multi-head self-attention mechanism unit, and then the features after the jump connection are input to the second normalization unit; each normalization unit is used to normalize the input; the multi-head self-attention mechanism unit is used to perform multi-head self-attention processing on the input. It should be understood that the units other than the multi-head self-attention mechanism unit in the multi-head self-attention mechanism module may be optional units. Those skilled in the art can adaptively adjust the model structure of the multi-head self-attention mechanism module under the enlightenment of the embodiments of the present application, for example, the jump connection unit can be removed, or any processing unit known in the art can be added, which is not limited to the embodiments of the present application.
[0095] It should be understood that the first encoding layer input of each encoder is historical time series data, the second encoding layer input is the output of the first encoding layer, and so on, the i-th encoding layer input is the output of the i-1-th encoding layer, i is greater than or equal to 2 and less than the total number of encoding layers; wherein the encoding process of each encoding layer is similar, and the features of the last encoding layer output of the encoder can be used as historical time series features.
[0096] Based on the above Figure 3The encoder shown uses multiple encoders to encode multiple groups of historical time series data respectively, and obtains multiple historical time series features corresponding to each of the multiple groups of historical time series data, including: for the encoder corresponding to any group of historical time series data, the historical time series data is input into the feedforward network module of the encoder, and the intermediate time series features are output; the intermediate time series features and the historical time series data are input into the multi-head self-attention mechanism module, and the historical time series features corresponding to the historical time series data are output. It should be understood that the encoding process can include the encoding process of the first encoding layer. For other encoding layers, the output features of the i-1th encoding layer can be used as the historical time series data input to the i-th encoding layer, and at least one round of the above encoding process can be performed, and the output features of the last encoding are used as the historical time series features output by the encoder. In this way, the encoder can be used to effectively extract relative position information and change trend information in the historical time series data.
[0097] It should be noted that Figure 4 The encoder shown is a possible implementation method provided by the embodiment of the present application. In fact, those skilled in the art can also use other encoders known in the art to encode historical time series data, as long as the above-mentioned historical time series features can be extracted. This embodiment of the present application does not limit this.
[0098] Step S203, using a decoder to determine the predicted time series data corresponding to the target object in the prediction time window based on multiple historical time series features and current time series data, the predicted time series data includes the predicted behavior data of the target object at multiple time points within the prediction time window.
[0099] In practical applications, a structure in which one decoder corresponds to multiple encoders can be adopted, and one decoder is used to determine the predicted time series data corresponding to the target object in the prediction time window based on multiple historical time series features and current time series data; alternatively, a structure in which multiple decoders correspond to multiple encoders can be adopted, that is, each decoder can be responsible for the prediction of part of the time series data, which is not limited to this embodiment of the present application.
[0100] Among them, the decoder may include multiple decoding layers, and the historical time series features output by each of the above encoders may include multiple sub-time series features, or multiple projections, wherein the total number of sub-time series features in each historical time series feature = the total number of decoding layers in the decoder, and the sub-time series features in the multiple historical time series features can be provided to the corresponding decoding layers respectively, that is, the encoder outputs part of the feature information of the historical time series data to different encoding layers of the decoder respectively, thereby providing an effective basis for the decoder to predict the time series for a period of time in the future, and can retain the order information of the time series data, perceive the change trend of long-term time series data, and reduce the impact of cumulative errors. Exemplarily, if 4 encoders are used to encode the historical time series data of the past D = 4 days, and the decoder has J = 8 decoder layers, then all 4 encoders will output a total of 4*8 = 32 dense projections (that is, sub-time series features).
[0101] Based on this, in a possible implementation, if the encoder is set to include J decoding layers, each historical time series feature includes J sub-time series features, J is a positive integer, and the decoder is used to determine the predicted time series data corresponding to the target object in the predicted time window according to multiple historical time series features and current time series data, including:
[0102] Input the current time series data and the first sub-time series feature of each historical time series feature into the first decoding layer of the decoder, and output the first predicted time series feature;
[0103] Input the j-1th predicted time series feature output by the j-1th decoding layer and the j-th sub-time series feature of each historical time series feature into the j-th decoding layer of the decoder, and output the j-th predicted time series feature, j∈[2,J];
[0104] The predicted time series data is determined according to the J-th predicted time series feature output by the J-th decoding layer of the decoder and the prediction time window.
[0105] by Figure 6 The decoder shown explains the above determination process as Figure 6 As shown, the decoder may include multiple decoding layers, each decoding layer includes a feedforward network module, a multi-head self-attention mechanism module and a long-term attention mechanism module; wherein the feedforward network module and the multi-head self-attention mechanism module in the decoder are the same as the above Figure 4The structure of the encoder shown can be the same and will not be repeated here; wherein, the feedforward network module and the multi-head self-attention mechanism module of the first decoding layer of the decoder input the current time series data, and starting from the second decoding layer, the feedforward network module and the multi-self-attention mechanism of the jth decoding layer input the features output by the j-1th decoding layer; and, the long-term attention mechanism module of each decoding layer inputs the features output by the multi-head self-attention mechanism module and the multiple sub-time series features corresponding to each decoding layer in the multiple historical time series features. For example, the long-term attention mechanism module of the first decoding layer inputs the features output by the multi-head self-attention mechanism module of the first decoding layer (equivalent to Q) and the first sub-time series features of the multiple historical time series features (equivalent to K and V), and so on. Figure 6 Each sub-time series feature of the historical time series feature output by the last decoding layer of a decoder in the decoder is densely mapped (ie, fully connected) and projected to each corresponding decoding layer of the decoder.
[0106] Figure 7 A schematic diagram of the processing process of the long-term attention mechanism module according to an embodiment of the present application is shown as follows: Figure 7 As shown, t represents the current time period, T represents the period unit (such as "day"), tT to t-5T represent 5 historical time periods, and the sub-time series features of the historical sequence features corresponding to each historical time period are used as the key K (key) and value V (value) of the attention mechanism. The encoded time series features obtained after the feedforward network module and the multi-head self-attention mechanism module encode the current time series data corresponding to the current time period t are used for query Q (query), and then the similarity between the query Q and each key K is calculated by the dot product method, and then the softmax function is used to normalize each similarity and output the attention score (that is, attention weight) corresponding to each key K, and then based on the attention weight corresponding to each key K, multiple sub-time series features (that is, multiple values V = key K) are weighted and summed to obtain the predicted time series features output by the long-term attention mechanism module.
[0107] Through the above long-term attention mechanism, it is equivalent to making each encoded historical time series feature be used as K and V of the attention mechanism, and the encoded time series feature of the current time series data is used as the query V, so the output of this long-term attention can be understood as the weighted sum of multiple historical time series features. Each decoding layer of the decoder receives the key K and value V from the encoder as the projection basis, and the attention is calculated based on the historical sequence features of the past few days, rather than the attention calculated using the time series features of each time point in the past, which undoubtedly retains the orderliness of the original time series data. In other words, under the premise that the periodicity of the data is known (for example, periodic data related to people's diurnal activities), by extracting the historical time series feature information of the past several historical periods, the traffic trend over a long period of days or weeks can be obtained, and the key K and value V of each historical time series data can be output. The effective feature information of the current time period (that is, the time period to be predicted) after FFT convolution is used as the Q value, the K value in all historical time periods is queried, and the similarity between the historical time period and the current time period is calculated by the dot product method. After normalization processing by the softmax function, different attention weights based on different historical time periods are obtained, and the values V of multiple historical time periods are weighted and summed using different attention weights to obtain the predicted time series data of a prediction time window in the current time period. By utilizing the above-mentioned long-period attention mechanism, the decoder can use only shorter-length time series for reasoning during reasoning, without using the time series of the entire time period as input; different from the traditional attention mechanism, the long-period attention mechanism retains the relative position information on the time series; different from the traditional autoregressive model, the long-period attention mechanism will greatly reduce the impact of the accumulated error and make more accurate predictions; the long-period attention mechanism can search and learn the similarities between the current time series data sequence of the current time period and the historical time series data of the historical time period, and predict the size of future time series data on a larger scale.
[0108] Based on the above Figure 6 and Figure 7 , input the current time series data and the first sub-time series feature of each historical time series feature into the first decoding layer of the decoder, and output the first predicted time series feature, including: encoding the current time series data to obtain the first encoded time series feature; determining the attention weights corresponding to the first sub-time series features of each historical time series feature according to the similarities between the first sub-time series features of each historical time series feature and the first encoded time series feature; performing weighted summation of the first sub-time series features of each historical time series feature according to the attention weights corresponding to the first sub-time series features of each historical time series feature, to obtain the first predicted time series feature.
[0109] And, the j-1th predicted time series feature output by the j-1th decoding layer and the j-th sub-time series feature of each historical time series feature are input into the j-th decoding layer of the decoder to output the j-th predicted time series feature, including: encoding the j-1th predicted time series feature to obtain the j-th encoded time series feature; determining the attention weights corresponding to the j-th sub-time series features of each historical time series feature according to the similarities between the j-th sub-time series features of each historical time series feature and the j-th encoded time series feature; and performing weighted summation of the j-th sub-time series features of each historical time series feature according to the attention weights corresponding to the j-th sub-time series features of each historical time series feature to obtain the j-th predicted time series feature.
[0110] Among them, the current time series data can be encoded using the feedforward network module and the multi-head self-attention mechanism module of the first decoding layer of the decoder to obtain the first encoded time series feature; and the j-1th predicted time series feature can be encoded using the feedforward network module and the multi-head self-attention mechanism module of the j-th decoding layer to obtain the j-th encoded time series feature. It should be understood that the encoding of the above-mentioned current time series data and the j-1th predicted time series feature can be achieved by referring to the specific encoding method in the feedforward network module and the multi-head self-attention mechanism module in the above-mentioned encoder, which will not be repeated here.
[0111] Among them, each decoding layer can refer to Figure 7 The specific implementation method of the long-term attention mechanism module shown is to determine the attention weights corresponding to the sub-time series features of each historical time series feature according to the similarity between the sub-time series features of each historical time series feature and the encoding time series feature; according to the attention weights corresponding to the sub-time series features of each historical time series feature, the sub-time series features of each historical time series feature are weighted and summed to obtain the predicted time series feature. It should be understood that those skilled in the art can use the similarity calculation method known in the art to calculate the similarity between the encoding time series feature and each sub-time series feature, and the embodiment of the present application is not limited to this. After calculating the similarity between the encoding time series feature and each sub-time series feature, the softmax function can be used to normalize the similarity to the interval [0,1] to obtain the attention weights corresponding to each sub-time series feature, and then based on the attention weights, each sub-time series feature is weighted and summed to obtain the predicted time feature.
[0112] It should be understood that since the attention weight is equivalent to being calculated based on the sub-time series features of the past few days, this retains the orderliness of the historical time series data, so that only shorter-length historical time series data can be used to predict behavioral data in a certain time period in the future, without the need to use the complete historical time series data in the entire historical time period as input. At the same time, it can reduce the impact of cumulative errors, and can search and learn the similarities between the current time series of the current time period and the historical time series of the historical time period, so that time series data in a certain time period in the future can be predicted on a larger time scale.
[0113] In practical applications, since the periodic prediction of long-period time series data inevitably requires the extraction of historical time series features in the past few periods, it is also possible to use variance mean, multi-layer perceptron (MLP, MultilayerPerceptron) and other methods to predict the trend of the next period on a large scale. The long-period attention module of the embodiment of the present application uses the attention mechanism to learn the similarities of several time series data in the historical period, which can obtain better time series prediction accuracy compared with the above methods.
[0114] Taking into account that the size (including scale, dimension, etc.) of the Jth predicted time series feature output by the Jth decoding layer of the decoder may be inconsistent with the original time series data, the Jth predicted time series feature output by the Jth decoding layer can be mapped back to the predicted time series feature of the same size as the historical time series data, for example, the high-dimensional predicted time feature is mapped back to the two-dimensional predicted time series feature, and then based on the above-mentioned preset folding rate, the mapped predicted time series feature is expanded into the predicted time series feature of the same dimension as the original time series data, for example, the two-dimensional predicted time series feature is expanded to the one-dimensional predicted time series feature to match the data format of the original time series data.
[0115] Furthermore, since the historical time series data is selected based on the target time window, the predicted time series features determined using the historical time series features are converted into a one-dimensional sequence, and the sequence length may be the same as the historical time series data, and the user may only need the predicted time series features within the prediction time window as the predicted time series data. Therefore, based on the above prediction time window, the time series features in the predicted time window can be selected as the predicted time series data.
[0116] Based on this, the above-mentioned determination of predicted time series data based on the J-th predicted time series feature output by the J-th decoding layer of the decoder and the predicted time window may include: mapping the J-th predicted time series feature back to a predicted time series feature of the same size as the historical time series data; based on the above-mentioned preset folding rate, expanding the mapped predicted time series feature into a predicted time series feature of the same dimension as the original time series data; based on the prediction time window, selecting part of the predicted time series features within the above-mentioned prediction time window from the expanded predicted time series features as the predicted time series data. It should be understood that if the original time series data is not folded with the folding rate in the above-mentioned step S201, part of the predicted time series features within the above-mentioned prediction time window may be directly selected from the mapped predicted time series features as the predicted time series data based on the prediction time window.
[0117] Based on the above steps S201 to S203, the present application embodiment further provides a method as follows: Figure 8 The framework diagram of the time series data prediction system is shown in Figure 8 As shown, it is assumed that three encoders are used, three decoding layers are used in the decoder, and the current original time series data of today t and the historical original time series data of the past three days (including the data from the t-1 day to the t-3 day) are used; first, based on the preset folding rate, the original time series data (including the historical original time series data of the past three days and the current original time series data of today) are folded respectively to obtain the folded time series data (including the historical time series data of the past three days and the current time series data); the folded time series data can also be encoded into the model dimension that the encoder can process in advance, and then each group of historical data with the model dimension is folded. The time series data is input into the corresponding encoder, each encoder encodes each historical time series data, and outputs the sub-time series features in the encoded historical time series features to different decoding layers of the decoder respectively. The sub-time series features are used as the input of the long-term attention mechanism model in the above decoder, and the current time series data is input into the decoder at the same time, and the decoder is used to complete the prediction of the time series data within the prediction time window; after obtaining the predicted time features output by the decoder, the predicted time series features can also be expanded to the predicted time series features of the same dimension as the original time series data based on the above folding rate to match the data format of the original time series data.
[0118] like Figure 8As shown, the encoder and decoder are a multi-to-one hierarchical link architecture, that is, multiple encoders correspond to one decoder and correspond to each encoding layer in the decoder. Multiple encoders use the historical time series data after folding the target time window of multiple historical time periods as input, and extract the historical time series features through at least Fourier transform convolution (FFTCONV) in the encoder. This process is also encoding. After encoding, part of the feature information of the historical time series features is output to different decoding layers of the decoder as the input of the long-term attention mechanism of each decoding layer. After the historical time series feature information is provided to the decoder, the current time series data sequence in the current time window is input to the decoder to complete the prediction of time series data for a period of time in the future; multiple encoders can learn and retain the local relative position information and global change trend information of the historical time series data of several days in history, and can make a comprehensive judgment on the historical time series features of the historical time series data of the same historical period of multiple days through the decoder, so as to make the prediction of fine-grained time series data of long periods (such as several days or weeks) more accurate and efficient.
[0119] As described above, the target object includes user requests; the behavior data includes the request traffic of the user requests, and the predicted time series data includes the predicted request traffic of the user requests at multiple time points within the predicted time window; in a possible implementation, after obtaining the predicted time series data, the method further includes: scheduling the computing resources used to process the user requests according to the predicted request traffic of the user requests at multiple time points within the predicted time window, so that the scheduled computing resources adapt to the predicted request traffic. Among them, the computing resources can be scheduled in advance before the predicted time window arrives. In this way, the request traffic of the user requests can be predicted, and the changing trend of the traffic can be considered in three dimensions: long time series (weeks, months), periodicity (days), and real-time, so as to achieve more accurate fine-grained long-term time series prediction, reduce the number of cold starts of the cloud platform, bring low response delay to user requests, and reduce the waste of computing resources on the platform side.
[0120] As described above, the target object includes the traffic area; the behavior data includes the traffic volume in the traffic area; the predicted time series data includes the predicted traffic volume of the traffic area at multiple time points within the predicted time window; after obtaining the predicted time series data, the method further includes: according to the predicted traffic volume of the traffic area at multiple time points within the predicted time window, the traffic signal timing scheme of the traffic lights in the traffic area within the predicted time window is adjusted in advance, so that the adjusted traffic signal timing scheme is adapted to the predicted traffic volume. Among them, the traffic signal timing scheme of the traffic lights can be adjusted in advance before the predicted time window arrives. In this way, the traffic volume in the traffic area can be predicted and the traffic signal configuration scheme can be adjusted according to the predicted traffic volume, so that the adjusted traffic signal timing scheme is adapted to the predicted traffic volume, which can make the traffic in the entire traffic area smooth, increase the traffic flow rate and reduce traffic congestion.
[0121] According to the embodiments of the present application, based on the prediction time window and the current time window, it is possible to know a priori which time series data in the historical time period are important; then, multiple encoders are used to respectively use the historical time series data of the target time windows of multiple historical time periods as input, and after encoding, the relative position information and change trend information of the historical time series data are output to different encoding layers of the decoder, so as to provide the decoder with an effective basis for time series prediction for a period of time in the future, that is, to use the important historical sequence data in the same target time window in each past to predict the sequence trend of the prediction time window in the current time period, so that there is no need to use all the historical time series data in the historical time period, and fine-grained long-period time series prediction can be achieved efficiently and accurately.
[0122] According to the time series data prediction method of the embodiment of the present application, it is equivalent to using the historical time series data in the same target time window in multiple historical time periods in the past to predict a time window in the future; wherein, the folding technology of time series data can significantly reduce the training time of the entire prediction model (including encoder and decoder), and improve the data throughput and reasoning efficiency of the entire prediction model in the reasoning process. This means that the time series data folded at a preset folding rate (for example, F=60 of data per second converts a cycle of 86,400 in length per day into a cycle of 1,440) may not be able to support the entire prediction model to ingest all the historical time series data of several historical time periods in the past, so the prediction model can receive short time series data centered on the current time point, and at the same time use the historical time series data in the same target time window of several historical days as the reasoning input of the model.
[0123] According to the time series data prediction method of the embodiment of the present application, the upcoming time series data such as request flow and vehicle flow are predicted through the historical time series data of multiple historical time periods in the same target time window. Among them, folding the original time series data can increase the amount of data (throughput) that can be input to the entire prediction model and speed up the training speed; secondly, multiple encoders are used to encode the historical period data, and the obtained local sequence feature information is transmitted to different encoding layers of the decoder in a dispersed manner; the FFT convolution structure is used inside the encoder and decoder, so that the input time series length is flexible and variable, and the FFT convolution structure can extract all feature information of the input data; finally, the long-term attention mechanism is used, so that the decoder can retain the order information of the input sequence, perceive the long-term traffic trend, and reduce the cumulative error compared to the traditional autoregressive model.
[0124] According to the time series data prediction method of the embodiment of the present application, it can be used for user traffic prediction of various cloud platforms for users. When user requests have a certain periodic regularity, such as the traffic trend is consistent with the work and rest time of human activities, the time series data prediction method of the embodiment of the present application can be used to more accurately predict the traffic size of a future prediction time window, and more accurately prepare function instances, containers and other computing resources based on this data, and can return the processing results required by users with lower processing latency, while reducing the waste of resources caused by multiple expansion of containers.
[0125] The time series data prediction method according to the embodiment of the present application can also be applied to various container management platforms (such as Kubernetes): considering that the platform is user-oriented and the traffic has a periodicity with "days" as the period unit, various management platforms with functions as the minimum granularity or containers as the minimum granularity can deploy the time series data prediction method of the embodiment of the present application, so as to achieve the effect of pulling up function instances in advance to avoid container cold starts and reduce platform reserved instances.
[0126] Fig. 9 FIG. 1 shows a structural diagram of a time series data prediction device according to an embodiment of the present application. The device can be used in the time series data prediction system 100, such as Fig. 9 As shown, the device comprises:
[0127] An acquisition module 901 is used to acquire, for a prediction time window set for a target object to be predicted in a current time period, current time series data collected in a current time window adjacent to the prediction time window in the current time period, and to acquire multiple groups of historical time series data collected in the same target time window of multiple historical time periods, wherein the target time window includes the prediction time window and the current time window, and the time series data includes behavior data of the target object at multiple time points in the time window;
[0128] The encoding module 902 is used to encode the multiple groups of historical time series data using multiple encoders to obtain multiple historical time series features corresponding to the multiple groups of historical time series data, each of which represents the relative position information and change trend information of each group of historical time series data in the target time window;
[0129] The decoding module 903 is used to use a decoder to determine the predicted time series data corresponding to the target object in the prediction time window according to the multiple historical time series features and the current time series data, and the predicted time series data includes the predicted behavior data of the target object at multiple time points within the prediction time window.
[0130] According to the embodiments of the present application, based on the prediction time window and the current time window, it is possible to know a priori which time series data in the historical time period are important; then, multiple encoders are used to respectively use the historical time series data of the target time windows of multiple historical time periods as input, and after encoding, the relative position information and change trend information of the historical time series data are output to different encoding layers of the decoder, so as to provide the decoder with an effective basis for time series prediction for a period of time in the future, that is, to use the important historical sequence data in each past target time window to predict the sequence trend of the prediction time window in the current time period, so that there is no need to use all the historical time series data in multiple historical time periods, and fine-grained long-period time series prediction can be achieved efficiently and accurately.
[0131] In one possible implementation, the decoder includes J decoding layers, each historical time series feature includes J sub-time series features, J is a positive integer, and the decoder is used to determine the predicted time series data corresponding to the target object in the predicted time window according to the multiple historical time series features and the current time series data, including: inputting the current time series data and the first sub-time series feature of each historical time series feature into the first decoding layer of the decoder, and outputting the first predicted time series feature; inputting the j-1th predicted time series feature output by the j-1th decoding layer and the jth sub-time series feature of each historical time series feature into the jth decoding layer of the decoder, and outputting the jth predicted time series feature, j∈[2,J]; determining the predicted time series data according to the Jth predicted time series feature output by the Jth decoding layer of the decoder and the prediction time window.
[0132] According to an embodiment of the present application, by providing sub-time series features of multiple historical time series features to corresponding decoding layers respectively, that is, the encoder outputs partial feature information of historical time series data to different encoding layers of the decoder respectively, thereby providing an effective basis for the decoder to predict the time series for a period of time in the future, being able to retain the sequence information of the historical time series data, perceive the changing trend of long-term time series data, and reduce the impact of cumulative errors.
[0133] In a possible implementation, the current time series data and the first sub-time series feature of each historical time series feature are input into the first decoding layer of the decoder to output the first predicted time series feature, including: encoding the current time series data to obtain the first encoded time series feature; determining the attention weights corresponding to the first sub-time series features of each historical time series feature according to the similarities between the first sub-time series features of each historical time series feature and the first encoded time series feature; and performing weighted summation of the first sub-time series features of each historical time series feature according to the attention weights corresponding to the first sub-time series features of each historical time series feature to obtain the first predicted time series feature.
[0134] According to the embodiments of the present application, the decoder can use only a shorter length of time series for reasoning, without using a complete time period time series as input; it can retain the relative position information on the time series, greatly reduce the impact of cumulative errors, and make more accurate predictions. It can search and learn the similarity between the current time series data sequence of the current time period and the historical time series data of the historical time period, and predict the size of future time series data on a larger scale.
[0135] In a possible implementation, the j-1th predicted time series feature output by the j-1th decoding layer and the j-th sub-time series feature of each historical time series feature are input into the j-th decoding layer of the decoder to output the j-th predicted time series feature, including: encoding the j-1th predicted time series feature to obtain the j-th encoded time series feature; determining the attention weights corresponding to the j-th sub-time series features of each historical time series feature according to the similarities between the j-th sub-time series features of each historical time series feature and the j-th encoded time series feature; and performing weighted summation of the j-th sub-time series features of each historical time series feature according to the attention weights corresponding to the j-th sub-time series features of each historical time series feature to obtain the j-th predicted time series feature.
[0136] According to the embodiments of the present application, the decoder can use only a shorter length of time series for reasoning, without using a complete time period time series as input; the relative position information on the time series can be retained, greatly reducing the impact of cumulative errors, making more accurate predictions, and searching and learning the similarity between the current time series data sequence of the current time period and the historical time series data of the historical time period, and predicting the size of future time series data on a larger scale.
[0137] In one possible implementation, the encoder includes a feedforward network module and a multi-head self-attention mechanism module, the feedforward network module includes a Fourier transform convolution unit, the Fourier transform convolution unit is used to perform Fourier transform and convolution processing on the input features, and the multi-head self-attention mechanism module is used to generate historical time series features using the multi-head self-attention mechanism; wherein, the multiple encoders are used to encode the multiple groups of historical time series data respectively to obtain multiple historical time series features corresponding to the multiple groups of historical time series data, including: for the encoder corresponding to any group of historical time series data, the historical time series data is input into the feedforward network module of the encoder, and the intermediate time series features are output; the intermediate time series features and the historical time series data are input into the multi-head self-attention mechanism module, and the historical time series features corresponding to the historical time series data are output.
[0138] According to an embodiment of the present application, the use of Fourier transform convolution processing in the encoder can make the sequence length of the input time series data flexible and variable, while extracting the characteristic information of the input data in the frequency domain and still maintaining the order information of the input time series data; in particular, the frequency information of the input time series data in the frequency domain can be used to establish connections between similar frequency components, thereby breaking through the limitation of the traditional convolution model that requires fixed input and output sizes.
[0139] In a possible implementation, the obtaining of current time series data collected in the current time window adjacent to the prediction time window in the current time period includes: obtaining the current original time series data collected in the current time window, and folding the current original time series data into at least two-dimensional current time series data based on a preset folding ratio, wherein the folding ratio is used to indicate the scale of the folded sequence data in different dimensions, and the dimension of the current time series data is greater than the current original time series data; the obtaining of multiple groups of historical time series data collected in the same target time window of multiple historical time periods includes: obtaining each group of historical original time series data collected in the same target time window in each historical time period, and folding each group of historical original time series data into at least two-dimensional historical time series data based on the preset folding ratio, and the dimension of the historical time series data is greater than the historical original time series data.
[0140] According to the embodiments of the present application, the memory footprint of the entire prediction model (including the encoder and decoder) can be improved, allowing the encoder and decoder to process longer time series data and increase the length of the sequence that the model can consume, which is equivalent to increasing the parallel computing capacity of the model, that is, having a larger data throughput, thereby improving the processing efficiency of subsequent encoders and decoders. At the same time, no downsampling operations are required, which is beneficial to ensuring the accuracy of time series prediction.
[0141] In one possible implementation, the target object includes a user request; the behavior data includes the request traffic of the user request, and the predicted time series data includes the request traffic predicted for the user request at multiple time points within the prediction time window; after obtaining the predicted time series data, the device also includes: a scheduling module, which is used to schedule the computing resources used to process the user request according to the request traffic predicted for the user request at multiple time points within the prediction time window, so that the scheduled computing resources adapt to the predicted request traffic.
[0142] According to the embodiments of the present application, predictions can be made for the request traffic of user requests, and the changing trends of traffic can be considered in three dimensions: long time series (weeks, months), periodicity (days), and real-time, to achieve more accurate, fine-grained, long-period time series predictions, which can reduce the number of cold starts of the cloud platform, bring low response latency to user requests, and reduce the waste of computing resources on the platform side.
[0143] In a possible implementation, the target object includes a traffic area; the behavior data includes the vehicle flow in the traffic area; the predicted time series data includes the vehicle flow predicted for the traffic area at multiple time points within the prediction time window; after obtaining the predicted time series data, the device further includes: an adjustment module for adjusting the traffic signal timing scheme of the traffic lights in the traffic area within the prediction time window according to the vehicle flow predicted for the traffic area at multiple time points within the prediction time window, so that the adjusted traffic signal timing scheme adapts to the predicted vehicle flow.
[0144] According to the embodiments of the present application, the traffic flow in the traffic area can be predicted and the traffic signal configuration plan can be adjusted according to the predicted traffic flow, so that the adjusted traffic signal timing plan adapts to the predicted traffic flow, which can make the traffic in the entire traffic area smooth, increase the traffic flow rate and reduce traffic congestion.
[0145] An embodiment of the present application provides a time series data prediction device, comprising: a processor and a memory for storing processor executable instructions; wherein the processor is configured to implement the above method when executing the instructions.
[0146] An embodiment of the present application provides a non-volatile computer-readable storage medium on which computer program instructions are stored. When the computer program instructions are executed by a processor, the above method is implemented.
[0147] An embodiment of the present application provides a computer program product, including a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the above method.
[0148] Fig.10 FIG. 1 shows a structural diagram of an electronic device 1300 according to an embodiment of the present application. Fig.10 As shown, the electronic device 1300 may be a server or a terminal device, and executes the above Figure 2-Figure 8 The electronic device 1300 includes at least one processor 1801, at least one memory 1802, and at least one communication interface 1803. In addition, the electronic device may also include common components such as an antenna, which will not be described in detail here.
[0149] Combine the following Fig.10 Each component of the electronic device 1300 is introduced in detail.
[0150] Processor 1801 may be a general-purpose central processing unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits for controlling the execution of the above program. Processor 1801 may include one or more processing units, for example: processor 110 may include an application processor (application processor, AP), a modem processor, a graphics processor (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), a controller, a video codec, a digital signal processor (digital signal processor, DSP), a baseband processor, and / or a neural-network processing unit (neural-network processing unit, NPU), etc. Among them, different processing units may be independent devices or integrated in one or more processors.
[0151] The communication interface 1803 is used to communicate with other electronic devices or communication networks, such as Ethernet, Radio Access Network (RAN), core network, Wireless Local Area Networks (WLAN), etc.
[0152] The memory 1802 may be a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM) or other types of dynamic storage devices that can store information and instructions, or an electrically erasable programmable read-only memory (EEPROM), a compact disc (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical disc, laser disc, optical disc, digital versatile disc, Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory may exist independently and be connected to the processor via a bus. The memory may also be integrated with the processor.
[0153] The memory 1802 is used to store application code for executing the above solution, and the execution is controlled by the processor 1801. The processor 1801 is used to execute the application code stored in the memory 1802.
[0154] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0155] A computer-readable storage medium may be a tangible device that can hold and store instructions used by an instruction execution device. A computer-readable storage medium may be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. More specific examples of computer-readable storage media (a non-exhaustive list) include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disc read-only memory (CD-ROM), a digital versatile disc (DVD), a memory stick, a floppy disk, a mechanical encoding device, such as a punch card or a raised structure in a groove on which instructions are stored, and any suitable combination of the foregoing.
[0156] The computer-readable program instructions or codes described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.
[0157] The computer program instructions for performing the operation of the present application may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages, such as Smalltalk, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. Computer-readable program instructions may be executed completely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or completely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect via the Internet). In some embodiments, by utilizing the state information of computer-readable program instructions to personalize an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA) or a programmable logic array (PLA), the electronic circuit can execute the computer-readable program instructions to implement various aspects of the present application.
[0158] Various aspects of the present application are described herein with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present application. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer-readable program instructions.
[0159] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processor of the computer or other programmable data processing device, a device that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0160] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operating steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0161] The flow chart and block diagram in the accompanying drawings show the possible architecture, function and operation of the device, system, method and computer program product according to multiple embodiments of the present application. In this regard, each square frame in the flow chart or block diagram can represent a part of a module, program segment or instruction, and a part of the module, program segment or instruction includes one or more executable instructions for realizing the logical function of the specification. In some alternative implementations, the functions marked in the square frame can also occur in a sequence different from that marked in the accompanying drawings. For example, two continuous square frames can actually be executed substantially in parallel, and they can also be executed in reverse order sometimes, depending on the functions involved.
[0162] It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart, can be implemented by hardware (such as a circuit or ASIC (Application Specific Integrated Circuit)) that performs the corresponding function or action, or can be implemented by a combination of hardware and software, such as firmware.
[0163] Although the present invention is described herein in conjunction with various embodiments, in the process of implementing the claimed invention, those skilled in the art may understand and implement other variations of the disclosed embodiments by viewing the drawings, the disclosure, and the appended claims. In the claims, the word "comprising" does not exclude other components or steps, and "one" or "an" does not exclude multiple situations. A single processor or other unit may implement several functions listed in the claims. Certain measures are recorded in different dependent claims, but this does not mean that these measures cannot be combined to produce good results.
[0164] The embodiments of the present application have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and changes are obvious to those of ordinary skill in the art without departing from the scope of the described embodiments. The selection of terms used herein is intended to best explain the principles of the embodiments, practical applications, or improvements to the technology in the market, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein.
Claims
1. A time series data prediction method, It is characterized in that include: For a prediction time window set for a target object to be predicted within a current time period, obtain current time series data collected within a current time window located before and adjacent to the prediction time window within the current time period, and obtain multiple groups of historical time series data collected respectively within the same target time window of multiple historical time periods, wherein the target time window includes the prediction time window and the current time window, and the time series data includes behavior data of the target object at multiple time points within the time window; Using multiple encoders to encode the multiple groups of historical time series data respectively, to obtain multiple historical time series features corresponding to the multiple groups of historical time series data, each historical time series feature represents the relative position information and change trend information of each group of historical time series data within the target time window; The decoder is used to determine the predicted time series data corresponding to the target object in the predicted time window based on the multiple historical time series features and the current time series data. The predicted time series data includes the predicted behavior data of the target object at multiple time points within the predicted time window.
2. The method according to claim 1, It is characterized in that The decoder includes J decoding layers, each historical time series feature includes J sub-time series features, J is a positive integer, and the decoder is used to determine the predicted time series data corresponding to the target object in the predicted time window according to the multiple historical time series features and the current time series data, including: Inputting the current time series data and the first sub-time series feature of each historical time series feature into the first decoding layer of the decoder, and outputting the first predicted time series feature; Input the j-1th predicted time series feature output by the j-1th decoding layer and the j-th sub-time series feature of each historical time series feature into the j-th decoding layer of the decoder, and output the j-th predicted time series feature, j∈[2,J]; The predicted time series data is determined according to the J-th predicted time series feature output by the J-th decoding layer of the decoder and the prediction time window.
3. The method according to claim 2, It is characterized in that The step of inputting the current time series data and the first sub-time series feature of each historical time series feature into the first decoding layer of the decoder and outputting the first predicted time series feature comprises: Encode the current time series data to obtain a first encoded time series feature; Determining the attention weights corresponding to the first sub-temporal features of each historical temporal feature according to the similarities between the first sub-temporal features of each historical temporal feature and the first encoded temporal feature; According to the attention weights corresponding to the first sub-time series features of each of the historical time series features, the first sub-time series features of each of the historical time series features are weighted summed to obtain the first predicted time series feature.
4. The method according to claim 2, It is characterized in that The step of inputting the j-1th predicted time series feature output by the j-1th decoding layer and the j-th sub-time series feature of each historical time series feature into the j-th decoding layer of the decoder, and outputting the j-th predicted time series feature, comprises: Encoding the j-1th predicted time series feature to obtain a jth encoded time series feature; Determine the attention weight corresponding to each j-th sub-time series feature of each historical time series feature according to the similarity between the j-th sub-time series feature of each historical time series feature and the j-th encoding time series feature; According to the attention weights corresponding to the j-th sub-time series features of the various historical time series features, the j-th sub-time series features of the various historical time series features are weighted summed to obtain the j-th predicted time series feature.
5. The method according to claim 1, It is characterized in that The encoder includes a feedforward network module and a multi-head self-attention mechanism module, the feedforward network module includes a Fourier transform convolution unit, the Fourier transform convolution unit is used to perform Fourier transform and convolution processing on input features, and the multi-head self-attention mechanism module is used to generate historical time series features using the multi-head self-attention mechanism; The method of encoding the multiple sets of historical time series data using multiple encoders to obtain multiple historical time series features corresponding to the multiple sets of historical time series data includes: For an encoder corresponding to any set of historical time series data, the historical time series data is input into a feedforward network module of the encoder, and intermediate time series features are output; The intermediate time series features and the historical time series data are input into the multi-head self-attention mechanism module, and the historical time series features corresponding to the historical time series data are output.
6. The method according to claim 1, It is characterized in that The acquiring the current time series data collected in the current time window adjacent to the prediction time window in the current time period includes: Acquire the current original time series data collected within the current time window, and fold the current original time series data into at least two-dimensional current time series data based on a preset folding ratio, wherein the folding ratio is used to indicate the scale of the folded sequence data in different dimensions, and the dimension of the current time series data is greater than that of the current original time series data; The step of obtaining multiple groups of historical time series data collected respectively in the same target time window of multiple historical time periods includes: Acquire each group of historical original time series data collected within the same target time window in each historical time period, and based on the preset folding rate, fold each group of historical original time series data into at least two-dimensional historical time series data, wherein the dimension of the historical time series data is greater than that of the historical original time series data.
7. The method according to any one of claims 1 to 6, It is characterized in that The target object includes a user request; the behavior data includes the request flow of the user request, and the predicted time series data includes the predicted request flow of the user request at multiple time points within the predicted time window; After obtaining the predicted time series data, the method further includes: According to the request traffic predicted by the user request at multiple time points within the prediction time window, the computing resources used to process the user request are scheduled so that the scheduled computing resources adapt to the predicted request traffic.
8. The method according to any one of claims 1 to 6, It is characterized in that The target object includes a traffic area; the behavior data includes the traffic volume in the traffic area; the predicted time series data includes the predicted traffic volume of the traffic area at multiple time points within the prediction time window; after obtaining the predicted time series data, the method further includes: According to the traffic volume predicted in the traffic area at multiple time points in the prediction time window, the traffic signal timing scheme of the traffic lights in the traffic area in the prediction time window is adjusted so that the adjusted traffic signal timing scheme adapts to the predicted traffic volume.
9. A time series data prediction device, It is characterized in that The device comprises: An acquisition module, for acquiring, for a prediction time window set for a target object to be predicted within a current time period, current time series data collected within a current time window adjacent to the prediction time window within the current time period, and multiple groups of historical time series data collected respectively within the same target time window of multiple historical time periods, wherein the target time window includes the prediction time window and the current time window, and the time series data includes behavior data of the target object at multiple time points within the time window; An encoding module, used to encode the multiple groups of historical time series data using multiple encoders to obtain multiple historical time series features corresponding to the multiple groups of historical time series data, each of which represents the relative position information and change trend information of each group of historical time series data within the target time window; A decoding module is used to use a decoder to determine the predicted time series data corresponding to the target object in the predicted time window based on the multiple historical time series features and the current time series data, and the predicted time series data includes the predicted behavior data of the target object at multiple time points within the predicted time window.
10. A time series data prediction device, It is characterized in that include: processor; a memory for storing processor-executable instructions; Wherein, the processor is configured to implement the method according to any one of claims 1 to 8 when executing the instructions.
11. A non-volatile computer-readable storage medium having computer program instructions stored thereon, It is characterized in that When the computer program instructions are executed by a processor, the method according to any one of claims 1 to 8 is implemented.
12. A computer program product, comprising a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code, wherein when the computer-readable code is executed in an electronic device, a processor in the electronic device executes the method according to any one of claims 1 to 8.
Citation Information
Cited By
Hospital outpatient patient waiting time prediction method and system
CN119028545A
State prediction method and head-mounted display device
CN120744328A
Time sequence data prediction method and apparatus, and storage medium
EP4664370A1
Time sequence data prediction method and apparatus, and storage medium
WO2024183565A1
