Time sequence prediction method and device, storage medium and electronic equipment

By using linear network blocks of encoders and decoders in the time series prediction model for feature processing and fusing historical and future features, the error accumulation problem is solved and the accuracy and efficiency of time series prediction are improved.

CN118708971APending Publication Date: 2024-09-27BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1

Patent Information

Application Number
CN202410869324.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-28
Publication Date
2024-09-27

AI Technical Summary

Technical Problem

There is an error accumulation problem in existing time series prediction models, resulting in insufficient prediction accuracy.

Method used

A time series prediction model including an encoder and a decoder is adopted. The encoder includes multiple linear network blocks, and the decoder also includes multiple linear network blocks. By fusing historical features with future features, the number of network parameters is reduced and the model is reduced. cumulative error.

Benefits of technology

The prediction efficiency and accuracy of the time series prediction model are improved, error accumulation is reduced, and the reliability of the prediction results is enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118708971A
    Figure CN118708971A
Patent Text Reader

Abstract

The invention discloses a time sequence prediction method and apparatus, a storage medium and an electronic device. The method comprises the steps of obtaining historical features and future features of a target object; and inputting the historical features and the future features into a time sequence prediction model to obtain a target prediction result of the target object in a prediction time, the time sequence prediction model comprising an encoder and a decoder, and the encoder and the decoder respectively comprising a plurality of linear network blocks. And more comprehensive feature information is provided for time sequence prediction of the target object by fusing future features and historical features. A plurality of linear network blocks are respectively arranged in an encoder and a decoder for realizing a prediction model, so that the number of network parameters is reduced and the accumulated error of the model is reduced on the basis of ensuring the prediction precision, and the prediction efficiency and the prediction precision of the time sequence prediction model are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of deep learning technology, and in particular to a time series prediction method, device, storage medium and electronic device. Background Art

[0002] Time series forecasting is used to predict the value of a certain indicator in the future based on its historical data, and to provide a reference for future operations or processing methods through the predicted indicator data. Currently, time series forecasting can be achieved through machine learning models.

[0003] In the process of implementing the present invention, it is found that there are at least the following technical problems in the prior art: the machine learning model used for time series prediction is generally LSTM (Long Short Term Memory), RNN (Recurrent Neural Networks) or transformer model. Among them, models such as LSTM or RNN belong to "iterative multi-step prediction models", that is, the model only outputs the result of one time point each time, and the prediction of the result of the next time point depends on the result of the previous time point, and the final result is obtained by step-by-step prediction and iteration. Therefore, errors and error accumulation are generated in the iterative process. The transformer model uses a decoder to perform decoding prediction of future time series, and the decoding process of the decoder is also an iterative process, so error accumulation is also inevitable. Summary of the invention

[0004] The present invention provides a time series prediction method, device, storage medium and electronic equipment to reduce the error accumulation in the time series prediction process and improve the accuracy of time series prediction.

[0005] According to one aspect of the present invention, a time series prediction method is provided, comprising:

[0006] Obtain the historical and future characteristics of the target object;

[0007] The historical features and the future features are input into a time series prediction model to obtain a target prediction result of the target object within a prediction time, wherein the time series prediction model includes an encoder and a decoder, the encoder includes a plurality of linear network blocks connected in sequence, and the decoder includes a plurality of linear network blocks connected in sequence; wherein the plurality of linear network blocks in the encoder are used to process the historical features to obtain intermediate features; and the plurality of linear network blocks in the decoder are used to process the intermediate features and the future features to obtain a target prediction result of the target object within a prediction time.

[0008] Optionally, the time series prediction model further includes a first encoding module and a second encoding module, wherein the first encoding module is connected to the encoder, the second encoding module is connected to the decoder, and the encoder is connected to the decoder;

[0009] The first encoding module is used to encode the historical features and input the obtained first encoding features into the encoder; the second encoding module is used to encode the future features and input the obtained second encoding features into the decoder.

[0010] Optionally, the historical features include discrete features and continuous features; the first encoding module includes a discrete feature encoding submodule and a continuous feature encoding submodule; the encoding features respectively output by the discrete feature encoding submodule and the continuous feature encoding submodule are concatenated to obtain the first encoding feature.

[0011] Optionally, the number of the discrete feature encoding submodules in the first encoding module is multiple, and the number of the continuous feature encoding submodule is one; each of the discrete feature encoding submodules is used to encode a type of discrete feature; and the continuous feature encoding submodule encodes at least one continuous feature.

[0012] Optionally, the linear network block includes a linear network and a residual connection and a normalization network.

[0013] Optionally, the future features include category features corresponding to the prediction time, and / or initial prediction results corresponding to the prediction time; the method for obtaining the initial prediction results includes: inputting the historical features of the target object into a pre-trained initial prediction model to obtain the initial prediction results corresponding to the prediction time.

[0014] The optional training method of the time series prediction model includes:

[0015] Obtain a sample data set, where the sample data set includes multiple sample data, and the sample data includes historical features, future features, and predicted labels of a target object;

[0016] Iteratively train the time series prediction model based on the sample data set: In any iteration process, the historical features and future features in the sample data are input into the time series prediction model in training to obtain the training target prediction result, generate a loss function based on the training target prediction result and the prediction label, and adjust the parameters of the time series prediction model in training based on the loss function;

[0017] The time series prediction model includes a first encoding module, a second encoding module, an encoder and a decoder, wherein the first encoding module includes a plurality of discrete feature encoding submodules and a continuous feature encoding submodule, different discrete features in the historical features correspond to different discrete feature encoding submodules; at least one continuous feature in the historical features corresponds to the continuous feature encoding submodule; the encoding features output by the plurality of discrete feature encoding submodules and the continuous feature encoding submodule form a first encoding feature, and the first encoding feature is used as an input feature of the encoder;

[0018] The second encoding module is used to encode the future feature to obtain a second encoding feature, and the second encoding feature and the intermediate feature output by the encoder are used as input features of the decoder.

[0019] According to another aspect of the present invention, there is provided a time series prediction device, comprising:

[0020] A feature acquisition module is used to acquire historical features and future features of the target object;

[0021] A prediction module is used to input the historical features and the future features into a time series prediction model to obtain a target prediction result of the target object within a prediction time, wherein the time series prediction model includes an encoder and a decoder, the encoder includes a plurality of linear network blocks connected in sequence, and the decoder includes a plurality of linear network blocks connected in sequence; wherein the plurality of linear network blocks in the encoder are used to process the historical features to obtain intermediate features; and the plurality of linear network blocks in the decoder are used to process the intermediate features and the future features to obtain a target prediction result of the target object within a prediction time.

[0022] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:

[0023] at least one processor; and

[0024] a memory communicatively connected to the at least one processor; wherein,

[0025] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the time series prediction method described in any embodiment of the present invention.

[0026] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the timing prediction method described in any embodiment of the present invention when executed.

[0027] The technical solution of the embodiment of the present invention provides more comprehensive feature information for the time series prediction of the target object by fusing future features with historical features. By setting multiple linear network blocks in the encoder and decoder of the prediction model, the number of network parameters is reduced while ensuring the prediction accuracy, and the cumulative error of the model is reduced, so as to improve the prediction efficiency and prediction accuracy of the time series prediction model.

[0028] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0030] Figure 1 is a flow chart of a time series prediction method provided by an embodiment of the present invention;

[0031] Figure 2 is a structural schematic diagram of a time series prediction model provided by an embodiment of the present invention;

[0032] Figure 3 is a schematic diagram of the structure of a continuous feature encoding submodule provided in an embodiment of the present invention;

[0033] Figure 4 is a structural schematic diagram of a time series prediction model provided by an embodiment of the present invention;

[0034] Figure 5 is a schematic diagram of the structure of a linear network block in an encoder provided by an embodiment of the present invention;

[0035] Figure 6 is a schematic diagram of the structure of a linear network block in a decoder provided by an embodiment of the present invention;

[0036] Figure 7 is a schematic diagram of the structure of a time series prediction device provided by an embodiment of the present invention;

[0037] Figure 8 It is a structural schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0038] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0039] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0040] Time series forecasting is used to predict the value of a certain indicator in the future based on the historical data of the indicator, and to provide a reference for the operation or processing method in the future through the predicted indicator data. Among them, the above-mentioned indicator can be the target object to be predicted. The target object can be set according to the forecast demand, and the forecast demand can be the forecast demand of different business scenarios. Exemplarily, in a transaction scenario, the target object can be the order volume of a certain transaction item, wherein the transaction item can be a physical item (such as clothing, food, daily necessities, etc.) or a service (such as beauty, film and television, travel), etc. By predicting the order volume in the future, it is possible to provide data references for the stocking and replenishment process of the provider of the transaction item in the future, or to provide data references for the transportation planning of the logistics party in the future.

[0041] For example, in a network access scenario, the target object may be the number of visits to a target system, which may be a trading system, a news browsing system, etc. By predicting the number of visits in the future, data can be provided to the system maintainer to perform maintenance or upgrades on the target system.

[0042] In this embodiment, the target object for prediction is not limited and can be determined according to the test requirements of the business scenario. Accordingly, the time series prediction model for predicting the target object is trained based on sample data related to the target object, and a corresponding time series prediction model can be trained for each target object. When the prediction demand of the target object is detected (for example, a prediction request for the target object is received, or the regular prediction conditions of the target object are met), the time series prediction model corresponding to the target object is called, and the prediction processing is performed based on the time series prediction model.

[0043] It is understandable that the time series prediction model can be updated regularly, and the time series prediction model can be optimized and trained based on the newly added sample data to improve the prediction accuracy of the time series prediction model.

[0044] Figure 1 This is a flowchart of a time series prediction method provided by an embodiment of the present invention. This embodiment is applicable to the case of time series prediction by integrating historical data and future data. The method can be executed by a time series prediction device. The time series prediction device can be implemented in the form of hardware and / or software. The time series prediction device can be configured in electronic devices such as mobile phones, computers, servers, etc. Figure 1 As shown, the method includes:

[0045] S110: Acquire historical features and future features of the target object.

[0046] S120. Input the historical features and the future features into a time series prediction model to obtain a target prediction result of the target object within a prediction time, wherein the time series prediction model includes an encoder and a decoder, the encoder includes a plurality of linear network blocks connected in sequence, and the decoder includes a plurality of linear network blocks connected in sequence.

[0047] Among them, the multiple linear network blocks in the encoder are used to process the historical features to obtain intermediate features; the multiple linear network blocks in the decoder are used to process the intermediate features and the future features to obtain the target prediction results of the target object within the prediction time.

[0048] In this embodiment, a time series prediction is performed on the target object according to the prediction requirements of the business scenario to obtain a target prediction result of the target object at a preset time. The prediction time may be a preset time period after the current moment, such as one day, three days, or one week after the current moment. Optionally, the prediction time may also be multiple prediction time points within a preset time period after the current moment, such as a target prediction result corresponding to each hour after the current moment.

[0049] Optionally, the prediction trigger conditions of the target object are obtained in advance. Exemplarily, the prediction trigger conditions of the target object may be periodic trigger conditions, and the prediction period may be, for example, 1 day. Accordingly, when the duration between the current moment and the previous prediction moment satisfies the prediction period, the prediction task for the target object is triggered, and the embodiment of the present invention is executed to realize the prediction task.

[0050] In the process of executing the prediction task, the historical features and future features associated with the target object are obtained, and the time series prediction model corresponding to the target object is called. The above historical features and future features are predicted and processed by the time series prediction model to obtain the target prediction results in the future time. By integrating historical features and future features, the comprehensiveness and diversity of input features are improved to improve the accuracy of target prediction results.

[0051] Among them, the historical features associated with the target object may be historical features associated with a preset historical time period before the current time. The historical features include, but are not limited to, category features corresponding to the historical time in the historical time period and data features determined based on the historical data of the target object in the historical time period. Exemplarily, the category features corresponding to the historical time include, but are not limited to, the year, month, and day information of the historical time, whether it is a festival, whether it is a holiday, whether it is a specific date in the business scenario (for example, an agreed trading day such as 11.11 in the transaction scenario), etc. The data features determined based on the historical data of the target object in the historical time period include, but are not limited to, historical data that changes over time in the historical time period, daily average data, weekly average data, data change rate that changes over time in the historical time period, and data related to the same period of the historical time (for example, yesterday's same period value, last week's same period value, last year's same period value, etc.). Taking the transaction scenario as an example, the data features determined by the historical data of the target object may be the historical transaction volume corresponding to the historical time in the historical time period, the average transaction volume, the transaction volume change rate that changes over time, etc. It can be understood that the historical features in different business scenarios may be different and determined according to the forecasting needs.

[0052] In some embodiments, the future features associated with the target object include associated features of the predicted time, such as category features corresponding to the predicted time, including, by way of example, but not limited to, year, month, and day information of the predicted time, whether it is a festival, whether it is a holiday, whether it is a specific date in a business scenario, etc. It is understandable that the category features corresponding to the predicted time are of the same feature type as the category features corresponding to the historical time in the historical time period.

[0053] In some embodiments, the future features associated with the target object include an initial prediction result corresponding to the prediction time. The initial prediction result may be obtained based on the prediction of the historical features of the target object. Specifically, a pre-trained initial prediction model is obtained, and the historical features of the target object are input into the initial prediction model to obtain the initial prediction result corresponding to the prediction time. The initial prediction model may be trained based on sample data, and the sample data may include the historical features of the target object and the prediction labels corresponding to the historical features.

[0054] In some embodiments, the target prediction result of the time series prediction model can be the target prediction result of multiple prediction time points in the future time period, such as the target prediction result corresponding to each hour in the future day; the initial prediction result can be the overall prediction data of the future time period, such as the total target prediction result of the target object in the future day; or, the initial prediction result can also be the initial prediction result of multiple prediction time points in the future time period. Among them, the initial prediction model can be a lightweight model with fast processing speed for historical features and small storage resource occupation. The initial prediction model can be a model such as LSTM or RNN, which is not limited here, and can achieve a rough prediction of the target object.

[0055] In some embodiments, the future features associated with the target object include the category features corresponding to the prediction time and the initial prediction results corresponding to the prediction time. By obtaining the future features of the target object at the prediction time, prior information is provided for the target object prediction process, thereby improving the prediction accuracy of the target object.

[0056] The time series prediction model in this embodiment includes an encoder and a decoder, the encoder is connected to the decoder, and the output data of the encoder is used as the input data of the decoder. Accordingly, the historical features and the future features are input into the time series prediction model to obtain the target prediction result of the target object within the prediction time, including: inputting the historical features into the encoder to obtain intermediate features; inputting the future features into the decoder, and inputting the intermediate features into the decoder to obtain the target prediction result of the target object within the prediction time output by the decoder. The encoder extracts the historical features to obtain intermediate features, fuses the intermediate features with the future features, and inputs them into the decoder. The decoder processes the input fused features to obtain the target prediction result of the target object within the prediction time, realizing the prediction process of fusing historical features and future features, and improving the prediction accuracy of the target object.

[0057] Based on the above embodiment, the time series prediction model further includes a first encoding module and a second encoding module, wherein the first encoding module is connected to the encoder, the second encoding module is connected to the decoder, and the encoder is connected to the decoder. Figure 2 , Figure 2 : is a structural diagram of a time series prediction model provided by an embodiment of the present invention. The first encoding module is used to encode the historical features and input the obtained first encoding features to the encoder; the second encoding module is used to encode the future features and input the obtained second encoding features to the decoder.

[0058] The first encoding module and the second encoding module may be Embedding network modules, which are used to convert historical features or future features into Embedding vectors.

[0059] On the basis of the above embodiment, the historical features include discrete features and continuous features, wherein the discrete features are features that are not correlated with time, and the continuous features are features that are correlated with time. Exemplarily, the discrete features include but are not limited to the category information of historical time, such as year, month, day information, whether it is a festival, whether it is a holiday, etc., and the continuous features include but are not limited to historical data that changes with time, daily average data, weekly average data, data change rate that changes with time in a historical time period, and data related to the same period of the historical time. Discrete features and continuous features have different characteristics. In this embodiment, different encoding modules are used to perform targeted processing on discrete features and continuous features, respectively, to improve the accuracy of the encoding features, and to avoid the situation where the same encoding module has the processing capability for only one type of historical features and lacks the processing capability for other types of historical features. By setting different encoding modules, different encoding modules have the processing capability for different features, and it is possible to achieve sufficient feature extraction of each type of historical features and obtain sufficient time series information of historical features.

[0060] Correspondingly, the first encoding module includes a discrete feature encoding submodule and a continuous feature encoding submodule; wherein the discrete feature encoding submodule is used to encode discrete features to obtain discrete encoding features, and the continuous feature encoding submodule is used to encode continuous features, the continuous encoding features. The encoding features respectively output by the discrete feature encoding submodule and the continuous feature encoding submodule are concatenated to obtain the first encoding feature. Optionally, the number of discrete feature encoding submodules and continuous feature encoding submodules can be one respectively. By setting discrete feature encoding submodules respectively suitable for discrete features and continuous feature encoding submodules suitable for continuous features, different encoding submodules are used to encode features of different characteristics, thereby improving encoding accuracy and avoiding the encoding limitations of a single encoding submodel.

[0061] In the above embodiment, the historical features of the target object include multiple different types of discrete features, and different types of discrete features have different characteristics. For example, whether the historical time is a holiday is a discrete type of data 0 and 1, which is used to characterize whether the historical time is a holiday and the historical time is a holiday; the year, month, and day information of the historical time is such as xxxx year x month xx day. Optionally, the number of discrete feature encoding sub-models in the first encoding module is multiple, and each discrete feature encoding sub-model is used to encode a type of discrete feature. By setting multiple discrete feature encoding sub-modules, different types of discrete features are encoded independently, and sufficient information is extracted for each discrete feature. Specifically, a corresponding number of discrete feature encoding sub-models are set according to the number of types of discrete features in the historical features, and accordingly, the output results of multiple discrete feature encoding sub-models and continuous feature encoding sub-models are model spliced ​​to obtain the first encoding feature. By setting multiple discrete feature encoding sub-models to encode discrete features of different characteristics, the accuracy of encoding different types of discrete features is improved, and the problem that a single discrete feature encoding sub-model is difficult to encode multiple types of discrete features and difficult to train to achieve encoding accuracy is avoided.

[0062] Specifically, multiple discrete features are input into the corresponding discrete feature encoding sub-models to obtain the encoding vector corresponding to the discrete feature. The encoding vector can be 1×d adjacent, where d is the hidden layer dimension of the time series prediction model. After the discrete features are processed by the above discrete feature encoding sub-model, the concatenated feature size is [B, L, M, d], where B is the feature batch, L is the sequence length, M is the number of discrete features, and d is the hidden layer dimension of the model.

[0063] The continuous features are encoded by the continuous feature encoding submodule, for example, see Figure 3 , Figure 3 It is a schematic diagram of the structure of the continuous feature encoding submodule provided by an embodiment of the present invention. Due to the continuous numerical value of the continuous feature, there is no need to design a separate Embedding network for each continuous feature, and all continuous features (at least one type of continuous feature) are encoded and processed by a continuous feature encoding submodule. Among them, the continuous feature encoding submodule includes a normalization network and a linear network. Figure 3Here, fi can represent the i-th continuous feature, and Fi is the continuous coding feature of the i-th output. The normalization network uniformly maps all continuous features to the same standard normal distribution, and then obtains the final continuous coding features through a linear network (i.e., Linear layer). The input and output sizes of the Linear layer are 1 and d, respectively, so after the data about the continuous feature part passes through the continuous feature encoding submodule, the data size will change from [B, L, n] to [B, L, n, d], where n is the number of continuous features. Multiple types of continuous features are encoded through a continuous feature encoding submodule, which simplifies the model structure of the first encoding module and reduces the computational consumption of the time series prediction model.

[0064] Similarly, future features may include discrete features and / or continuous features. Accordingly, the second encoding module may include multiple discrete feature encoding submodules and / or one continuous feature encoding submodule. The output features of multiple discrete feature encoding submodules and / or one continuous feature encoding submodule can be determined based on the feature type and feature quantity included in the future features. The second encoding feature is obtained by concatenating the output features of multiple discrete feature encoding submodules and / or one continuous feature encoding submodule, which will not be repeated here.

[0065] On the basis of the above embodiment, the historical features are input into the first encoding module to obtain the first encoding features, and the first encoding features are input into the encoder to obtain the intermediate features; the future features are input into the second encoding module to obtain the second encoding features, and the second encoding features are concatenated with the intermediate features and input into the decoder to obtain the target prediction result of the target object within the prediction time output by the decoder.

[0066] Optionally, the encoder and decoder in the time series prediction model respectively include multiple linear network blocks, and the linear network blocks include a linear network and a residual connection and a normalized network. For example, see Figure 4 , Figure 4 It is a structural schematic diagram of a time series prediction model provided by an embodiment of the present invention.

[0067] Among them, the linear network in the linear network block includes a small number of network parameters and a fast processing speed. Correspondingly, the encoder and decoder composed of multiple linear network blocks have the effects of few network parameters and high processing efficiency. When the number of linear network blocks meets the model processing requirements (that is, meets the model processing accuracy), the prediction speed is fast and the storage space occupied is small.

[0068] Furthermore, the linear network in the linear network block can be a Linear layer. In the process of time series prediction, the result is output once, and there is no error accumulation problem such as LSTM, RNN and Transformers models, which reduces the error of the target prediction result.

[0069] For example, see Figure 5 and Figure 6 , Figure 5 It is a schematic diagram of the structure of a linear network block in an encoder provided by an embodiment of the present invention. Figure 6 : is a schematic diagram of the structure of a linear network block in a decoder provided by an embodiment of the present invention. The residual connection in the encoder and the normalization layer in the normalization network can be a Batch Norm layer, i.e., a batch normalization layer, which is used for normalization processing. The number of linear network blocks in the encoder can be preset and set according to the prediction accuracy requirement. The number of linear network blocks is positively correlated with the prediction accuracy. Exemplarily, the number of linear network blocks can be 6. Multiple linear network blocks are connected in sequence, such as Figure 5 As shown. Among the n linear network blocks, the input and output dimensions of the first n-1 linear network blocks are the same, both are [B, L, k, d]. The nth linear network block converts the hidden layer data size of the encoder to be consistent with the input size of the decoder, that is, the input data size of the nth linear network block is [B, L, k, d], and the output data size is [B, T, k, d], where T is the sequence length in the decoder. In this embodiment, the size of the feature vector is the same as the size of the network layer in each linear network block.

[0070] Each linear network block in the decoder receives the intermediate features output by the encoder, concatenates the output features of the previous linear network block with the intermediate features and inputs them into the linear network block, or concatenates the second encoded features with the intermediate features and inputs them into the linear network block. The input data size of each linear network block in the decoder is [B, T, k+j, d], where j is the sequence length of the output features of the previous linear network block or the sequence length of the second encoded features.

[0071] After obtaining the decoder output vector (vector size is [B, T, j, d]), it is mapped to the final model output result with a shape of [B, T]. The operation taken here is to first flatten the decoder output vector (i.e. flatten) to obtain a vector with a data size of [B, T, j*d], and then pass it through the last linear layer (input size j*d, output size 1) to obtain the final result with a shape of [B, T].

[0072] The technical solution of this embodiment provides more comprehensive feature information for the time series prediction of the target object by fusing future features with historical features. By setting multiple linear network blocks in the encoder and decoder of the prediction model, the number of network parameters is reduced while ensuring the prediction accuracy, and the cumulative error of the model is reduced, so as to improve the prediction efficiency and prediction accuracy of the time series prediction model.

[0073] On the basis of the above-mentioned embodiment, the training method of the time series prediction model includes: obtaining a sample data set, the sample data set includes a plurality of sample data, and the sample data includes the historical features and future features of the target object and a prediction label. The time series prediction model is iteratively trained based on the sample data set. In any iteration process, the historical features and future features in the sample data are input into the time series prediction model in training to obtain the training target prediction result, a loss function is generated based on the training target prediction result and the prediction label, and the parameters of the time series prediction model in training are adjusted based on the loss function. Optionally, the loss function includes a first loss function and a second loss function. The target loss function is determined according to the range of the loss value. When the absolute value of the difference between the target prediction result and the prediction label is less than or equal to a preset hyperparameter, the loss function is the first loss function; when the absolute value of the difference between the target prediction result and the prediction label is greater than the preset hyperparameter, the loss function is the second loss function. The first loss function is determined based on the square of the difference between the target prediction result and the prediction label, that is, The second loss function is determined based on the absolute value of the difference between the target prediction result and the predicted label and the preset hyperparameter, that is, Among them, the loss function can be expressed by the following formula:

[0074]

[0075] Where y is the prediction label, f(x) is the training target prediction result, and σ is the preset hyperparameter. When the loss value between the training target prediction result and the prediction label is small, that is, the absolute value of the loss value between the target prediction result and the prediction label is less than or equal to σ, the square error function (i.e., the first loss function) is determined as the target loss function. When the loss value between the target prediction result and the prediction label is large, that is, the loss value between the target prediction result and the prediction label is greater than σ, the absolute error function (i.e., the second loss function) is used as the target loss function. By combining different loss functions, the robustness of the time series prediction model can be improved.

[0076] Figure 7 Schematic diagram of the structure of a time series prediction device provided by an embodiment of the present invention. Figure 7 As shown, the device comprises:

[0077] The feature acquisition module 210 is used to acquire the historical features and future features of the target object.

[0078] The prediction module 220 is used to input the historical features and the future features into a time series prediction model to obtain a target prediction result of the target object within a prediction time, wherein the time series prediction model includes an encoder and a decoder, the encoder includes a plurality of linear network blocks connected in sequence, and the decoder includes a plurality of linear network blocks connected in sequence; wherein the plurality of linear network blocks in the encoder are used to process the historical features to obtain intermediate features; and the plurality of linear network blocks in the decoder are used to process the intermediate features and the future features to obtain a target prediction result of the target object within a prediction time.

[0079] The technical solution provided in this embodiment provides more comprehensive feature information for the time series prediction of the target object by fusing future features with historical features. By setting multiple linear network blocks in the encoder and decoder of the prediction model, the number of network parameters is reduced while ensuring the prediction accuracy, and the cumulative error of the model is reduced, so as to improve the prediction efficiency and prediction accuracy of the time series prediction model.

[0080] Based on the above embodiment, optionally, the prediction module 220 is used to: input the historical features into the encoder to obtain intermediate features; input the future features into the decoder, and input the intermediate features into the decoder to obtain the target prediction result of the target object within the prediction time output by the decoder.

[0081] On the basis of the above embodiment, optionally, the time series prediction model further includes a first encoding module and a second encoding module, wherein the first encoding module is connected to the encoder, the second encoding module is connected to the decoder, and the encoder is connected to the decoder;

[0082] Optionally, the historical features include discrete features and continuous features; the first encoding module includes a discrete feature encoding submodule and a continuous feature encoding submodule; the encoding features respectively output by the discrete feature encoding submodule and the continuous feature encoding submodule are concatenated to obtain the first encoding feature.

[0083] Optionally, the number of the discrete feature encoding sub-modules in the first encoding module is multiple, and each discrete feature encoding sub-module is used to encode a type of discrete feature.

[0084] Optionally, the linear network block includes a linear network and a residual connection and a normalization network.

[0085] Optionally, the future features include category features corresponding to the prediction time, and / or initial prediction results corresponding to the prediction time. The initial prediction results corresponding to the prediction time are obtained by inputting historical features of the target object into a pre-trained initial prediction model.

[0086] Optionally, the device further includes a model training module, which is used to obtain a sample data set, wherein the sample data set includes a plurality of sample data, and the sample data includes historical features, future features, and prediction labels of the target object; iteratively train the time series prediction model based on the sample data set: in any iteration process, the historical features and future features in the sample data are input into the time series prediction model in training to obtain a training target prediction result, generate a loss function based on the training target prediction result and the prediction label, and adjust the parameters of the time series prediction model in training based on the loss function;

[0087] The time series prediction model includes a first encoding module, a second encoding module, an encoder and a decoder, wherein the first encoding module includes multiple discrete feature encoding submodules and one continuous feature encoding submodule, different discrete features in the historical features correspond to different discrete feature encoding submodules; at least one continuous feature in the historical features corresponds to the continuous feature encoding submodule; the encoding features output by the multiple discrete feature encoding submodules and the continuous feature encoding submodule form a first encoding feature, and the first encoding feature serves as the input feature of the encoder; the second encoding module is used to encode the future feature to obtain a second encoding feature, and the second encoding feature and the intermediate feature output by the encoder serve as the input feature of the decoder.

[0088] The time series prediction device provided in the embodiment of the present invention can execute the time series prediction method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0089] Figure 8 1 is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. The electronic device 10 is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.

[0090] like Figure 8As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0091] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0092] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as a timing prediction method.

[0093] In some embodiments, the timing prediction method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the timing prediction method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the timing prediction method in any other appropriate manner (e.g., by means of firmware).

[0094] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0095] The computer program for implementing the timing prediction method of the present invention can be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general-purpose computer, a special-purpose computer or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program can be executed entirely on the machine, partially on the machine, partially on the machine as a stand-alone software package and partially on a remote machine, or entirely on a remote machine or server.

[0096] An embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to execute a time series prediction method, the method comprising:

[0097] Acquire historical features and future features of a target object; input the historical features and the future features into a time series prediction model to obtain a target prediction result of the target object within a prediction time, wherein the time series prediction model includes an encoder and a decoder, the encoder includes a plurality of linear network blocks connected in sequence, and the decoder includes a plurality of linear network blocks connected in sequence; wherein the plurality of linear network blocks in the encoder are used to process the historical features to obtain intermediate features; and the plurality of linear network blocks in the decoder are used to process the intermediate features and the future features to obtain a target prediction result of the target object within a prediction time.

[0098] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, 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), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0099] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).

[0100] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0101] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.

[0102] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.

[0103] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A time series prediction method, It is characterized in that include: Obtain the historical and future characteristics of the target object; Inputting the historical features and the future features into a time series prediction model to obtain a target prediction result of the target object within a prediction time, wherein the time series prediction model includes an encoder and a decoder, the encoder includes a plurality of linear network blocks connected in sequence, and the decoder includes a plurality of linear network blocks connected in sequence; The plurality of linear network blocks in the encoder are used to process the historical features to obtain intermediate features; The multiple linear network blocks of the decoder are used to process the intermediate features and the future features to obtain a target prediction result of the target object within a prediction time.

2. The method according to claim 1, It is characterized in that The time series prediction model also includes a first encoding module and a second encoding module, wherein the first encoding module is connected to the encoder, the second encoding module is connected to the decoder, and the encoder is connected to the decoder; The first encoding module is used to encode the historical features and input the obtained first encoding features into the encoder; The second encoding module is used to encode the future feature and input the obtained second encoding feature into the decoder.

3. The method according to claim 2, It is characterized in that The historical features include discrete features and continuous features; The first encoding module includes a discrete feature encoding submodule and a continuous feature encoding submodule; the encoding features respectively output by the discrete feature encoding submodule and the continuous feature encoding submodule are concatenated to obtain the first encoding feature.

4. The method according to claim 3, It is characterized in that The number of the discrete feature encoding submodules in the first encoding module is multiple, and the number of the continuous feature encoding submodule is one; each of the discrete feature encoding submodules is used to encode a type of discrete feature; and the continuous feature encoding submodule encodes at least one continuous feature.

5. The method according to claim 1, It is characterized in that The linear network block includes a linear network and a residual connection and a normalization network.

6. The method according to claim 1, It is characterized in that The future features include category features corresponding to the prediction time, and / or initial prediction results corresponding to the prediction time; The method for obtaining the initial prediction result includes: inputting the historical features of the target object into a pre-trained initial prediction model to obtain the initial prediction result corresponding to the prediction time.

7. The method according to claim 1, It is characterized in that The training method of the time series prediction model includes: Obtain a sample data set, where the sample data set includes multiple sample data, and the sample data includes historical features, future features, and predicted labels of a target object; Iteratively train the time series prediction model based on the sample data set: in any iteration process, input the historical features and future features in the sample data into the time series prediction model in training to obtain the training target prediction result, generate a loss function based on the training target prediction result and the prediction label, and adjust the parameters of the time series prediction model in training based on the loss function; The time series prediction model includes a first encoding module, a second encoding module, an encoder and a decoder, wherein the first encoding module includes a plurality of discrete feature encoding submodules and a continuous feature encoding submodule, different discrete features in the historical features correspond to different discrete feature encoding submodules; at least one continuous feature in the historical features corresponds to the continuous feature encoding submodule; the encoding features output by the plurality of discrete feature encoding submodules and the continuous feature encoding submodule form a first encoding feature, and the first encoding feature is used as an input feature of the encoder; The second encoding module is used to encode the future feature to obtain a second encoding feature, and the second encoding feature and the intermediate feature output by the encoder are used as input features of the decoder.

8. A time series prediction device, It is characterized in that include: A feature acquisition module is used to acquire historical features and future features of the target object; A prediction module, used for inputting the historical features and the future features into a time series prediction model to obtain a target prediction result of the target object within a prediction time, wherein the time series prediction model includes an encoder and a decoder, the encoder includes a plurality of linear network blocks connected in sequence, and the decoder includes a plurality of linear network blocks connected in sequence; The plurality of linear network blocks in the encoder are used to process the historical features to obtain intermediate features; The multiple linear network blocks of the decoder are used to process the intermediate features and the future features to obtain a target prediction result of the target object within a prediction time.

9. An electronic device, It is characterized in that The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can perform the time series prediction method according to any one of claims 1 to 7.

10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the timing prediction method according to any one of claims 1 to 7 when executed.

Citation Information

Patent Citations

  • Article sales prediction method and device, computer equipment and storage medium

    CN114066510A

  • Time series data prediction method and device, electronic equipment, medium and program product

    CN115905351A

  • Prediction method and device, storage medium and electronic equipment

    CN117807384A

Cited By

  • Robot action prediction method and device, equipment and storage medium

    CN120002675A