Time sequence prediction method and device
By setting a preset model set in the timing prediction method, selecting the appropriate timing model based on the length of the historical data, and selecting the target model through offline data calculation prediction error, the problem of fixed input length of the traditional timing model is solved, and flexible prediction of multiple data lengths is achieved.
Patent Information
- Application Number
- CN202510681181.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-26
- Publication Date
- 2025-06-24
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Traditional timing models only support a single input length, which cannot meet the diversity of data length requirements of different applications, and do not have the ability to fine-tune online, and require offline training in advance.
A timing prediction method is provided, by selecting a suitable subset of target models by presetting the set of models, selecting a suitable subset of timing models from multiple subsets of the model based on the length of the historical data of the indicator to be predicted, and selecting the target model using offline data to calculate the prediction error.
It breaks through the limitation that the traditional timing model only supports a single input length, can adapt to the prediction needs of multiple historical data lengths, expands the application scenarios of timing model, and improves the flexibility and accuracy of prediction.
Smart Images

Figure CN120196951A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular, to a time series prediction method and device. Background Art
[0002] Time series analysis is an important field in data science and statistics for analyzing time series data (i.e., data points arranged in chronological order), which is common in many fields such as finance, meteorology, sales, and transportation. Time series analysis can help us understand the historical patterns of data, make predictions, and detect anomalies, etc.
[0003] In recent years, significant progress has been made in Transformer technology, leading to a major revolution in the field of AI. Transformer technology can well describe the correlations between data points, extract multi-layer representations of sequences, and can handle long-term dependencies better than traditional algorithms such as CNN and RNN.
[0004] Great progress has also been made in processing time series based on Transformer technology. For example, time series large models such as TimeGPT, TimesFM, PatchTST, and GPT4TS have greatly exceeded most traditional algorithms in terms of prediction accuracy and prediction speed, showing good application advantages. The weight parameters of these time series large models are relatively fewer compared to large language models such as ChatGPT, usually around 200M. Even so, it is still difficult to deploy on many device sides (edge sides).
[0005] And time series small models based on Transformer or other technologies (with fewer weight parameters, such as <1M) have broad application prospects in this scenario. Excellent time series small models include iTransformer, TimesNet, TSMixer, ReFormer, etc. Compared with time series large models, these time series small models have fewer parameter numbers and weaker generalization ability. They often need to be specially trained for different data sets; moreover, they do not have the ability of online fine-tuning and need to be trained in advance using offline data. In addition, these time series small models have a serious limitation, that is, the input length of each time series small model is fixed; if the input length is short, it often cannot reflect the sequence characteristics of a longer time range, and if the input length is too long, it takes a long time to collect so much data and the timeliness will become very poor. That is to say, different applications require different data lengths for prediction, and traditional time series small models cannot meet the needs of many data lengths. Summary of the Invention
[0006] To overcome the problems existing in the related art, this application provides a time series prediction method and device.
[0007] According to the first aspect of the embodiments of the present application, a time series prediction method is provided, and the method includes: Obtain historical data of the metric to be predicted; According to the length of the historical data of the metric to be predicted, select a target model subset from a preset model set, where the preset model set includes multiple model subsets, different model subsets correspond to different input lengths, each model subset includes any number of time series small models with the corresponding input length, and the input length corresponding to the target model subset is less than or equal to the length of the historical data of the metric to be predicted; Calculate the prediction errors of each time series small model in the target model subset by using the offline data of the metric to be predicted, and use the time series small model with the smallest prediction error as the target model; Use the target model to generate a prediction result according to the historical data of the metric to be predicted.
[0008] According to the second aspect of the embodiments of the present application, a time series prediction device is provided, and the device includes: An input module, configured to obtain historical data of the metric to be predicted; A subset determination module, configured to select a target model subset from a preset model set according to the length of the historical data of the metric to be predicted, where the preset model set includes multiple model subsets, different model subsets correspond to different input lengths, each model subset includes any number of time series small models with the corresponding input length, and the input length corresponding to the target model subset is less than or equal to the length of the historical data of the metric to be predicted; A model determination module, configured to calculate the prediction errors of each time series small model in the target model subset by using the offline data of the metric to be predicted, and use the time series small model with the smallest prediction error as the target model; An output module, configured to use the target model to generate a prediction result according to the historical data of the metric to be predicted.
[0009] According to the third aspect of the embodiments of the present application, an electronic device is provided, including: A memory and one or more processors; the memory is coupled to the processor; wherein, computer program code is stored in the memory, and the computer program code includes computer instructions, and when the computer instructions are executed by the processor, the electronic device executes the method as described above.
[0010] According to the fourth aspect of the embodiments of the present application, a computer-readable storage medium is provided, including computer instructions, and when the computer instructions run on an electronic device, the electronic device is enabled to execute the method as described above.
[0011] According to a fifth aspect of the embodiments of the present application, there is provided a computer program product, which, when running on a computer, causes the computer to execute the method described above.
[0012] The technical solutions provided by the embodiments of the present application may include the following beneficial effects: In the embodiments of the present application, a preset model set including the above-mentioned time series small models covering various input lengths is set. Therefore, the embodiments of the present application can realize the prediction of the to-be-predicted indicators with various historical data lengths. For the to-be-predicted indicators with different historical data lengths, the embodiments of the present application can select a suitable time series small model for prediction from the preset model set, breaking through the limitation that traditional time series small models only support a single input length and greatly expanding the application scenarios of time series small models.
[0013] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and cannot limit the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] The drawings here are incorporated into the specification and constitute a part of the present application, showing embodiments consistent with the present application and used together with the specification to explain the principles of the present application.
[0015] Figure 1 The first flowchart of the time series prediction method provided by the embodiments of the present application; Figure 2 The second flowchart of the time series prediction method provided by the embodiments of the present application; Figure 3 The third flowchart of the time series prediction method provided by the embodiments of the present application; Figure 4 The fourth flowchart of the time series prediction method provided by the embodiments of the present application; Figure 5 The fifth flowchart of the time series prediction method provided by the embodiments of the present application; Figure 6 The schematic diagram of the time series prediction device provided by the embodiments of the present application; Figure 7 The schematic diagram of the structure of the electronic device provided by the embodiments of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0016] Next, the technical solutions in the embodiments of the present application will be described with reference to the drawings in the embodiments of the present application. Among them, in the description of the embodiments of the present application, the terms used in the following embodiments are only for the purpose of describing specific embodiments and are not intended to limit the present application.
[0017] It should be noted that in this application, "at least one" means one or more, and "a plurality" means two or more than two. "And / or" describes the association relationship of associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist simultaneously, and B exists alone, where A and B can be singular or plural. The terms "first", "second", "third", etc. (if any) in the specification, claims and drawings of this application are used to distinguish similar objects, rather than to describe a specific order or sequence.
[0018] In the embodiments of this application, words such as "exemplary" or "for example" are used to give examples, illustrations or explanations. Any embodiment or design solution described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or having more advantages than other embodiments or design solutions. Rather, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific manner. Next, the embodiments of this application will be described in detail.
[0019] The embodiments of this application provide a time series prediction method, as Figure 1 shown, the method may include the following steps: Step 110: Obtain the historical data of the index to be predicted; Step 120: Select a target model subset from a preset model set according to the length of the historical data of the index to be predicted, where the input length corresponding to the target model subset is less than or equal to the length of the historical data of the index to be predicted; Step 130: Calculate the prediction errors of each time series small model in the target model subset by using the offline data of the index to be predicted, and use the time series small model with the smallest prediction error as the target model; Step 140: Use the target model to generate a prediction result according to the historical data of the index to be predicted.
[0020] Specifically, the preset model set of the embodiments of this application includes multiple model subsets, different model subsets correspond to different input lengths, and each model subset includes any number of time series small models with the corresponding input lengths.
[0021] In the embodiments of this application, the length of the historical data of the index to be predicted refers to the length of the data used for prediction, the input length of the time series small model refers to the length of the data actually input into the model, and the input length corresponding to the model subset is the input length of the time series small models within the model subset.
[0022] It is worth mentioning that the input length of the time series small model is generally less than or equal to the historical data length of the target indicator to be predicted, because the model may only need part of the data to learn the pattern. Therefore, in step 120, a target model subset is selected from the preset model set, and the input length corresponding to the target model subset is less than or equal to the historical data length of the target indicator to be predicted.
[0023] In addition, in the embodiments of the present application, the prediction length of the target indicator to be predicted refers to the data length expected to be predicted, and the output length of the time series small model refers to the data length actually output by the model.
[0024] In the embodiments of the present application, the time series small model refers to a model with a relatively small number of parameters and a relatively low computational complexity in time series analysis and prediction tasks. Its number of parameters is usually between several million and several hundred million, and the computational complexity is relatively low, and it can run efficiently on a single GPU or CPU, and supports deployment on mobile devices or embedded systems. In practical applications, the time series small model can be implemented based on classical time series models (such as ARIMA, exponential smoothing method) or lightweight deep learning architectures (such as small-scale LSTM, GRU or Transformer), and the embodiments of the present application do not limit this.
[0025] It can be seen that the embodiments of the present application provide a time series prediction method, which sets a preset model set. The preset model set includes multiple model subsets, and each model subset includes any number of time series small models with a single input length. The input lengths of the time series small models in different model subsets are different. Therefore, after obtaining the historical data of the target indicator to be predicted, an appropriate target model subset can be selected from the preset model set according to the historical data length of the target indicator to be predicted, and a target model for prediction can be further selected from the target model subset by using the offline data of the target indicator to be predicted. Finally, the final prediction result is obtained based on the historical data of the target indicator to be predicted by using the target model.
[0026] Since the embodiments of the present application set the preset model set including time series small models with various input lengths as described above, the embodiments of the present application can realize the prediction of target indicators with various historical data lengths. For target indicators with different historical data lengths, the embodiments of the present application can select appropriate time series small models for prediction from the preset model set, breaking through the limitation that traditional time series small models only support a single input length, and greatly expanding the application scenarios of time series small models. As described in step 130, after determining the target model subset, the embodiments of the present application can calculate the prediction errors of each time series small model in the target model subset by using the offline data of the target indicator to be predicted, and use the time series small model with the smallest prediction error as the final target model for prediction.
[0027] Specifically, for the to-be-predicted metric, a time series model with the smallest average prediction error is selected from a subset of target models using a set of offline data, i.e., the target model. During prediction inference, the target model is used to provide prediction services for the to-be-predicted metric.
[0028] Furthermore, to avoid repeatedly screening for the time series model with the smallest prediction error from a subset of models for the same to-be-predicted metric, the corresponding relationship between the to-be-predicted metric and the time series model can be recorded after the time series model with the smallest prediction error is first screened out. For example, record the corresponding relationship between the identifier of the to-be-predicted metric and the identifier of the time series model for subsequent query.
[0029] In this case, as Figure 2 shown, step 130 of the embodiment of the present application can specifically determine the target model in the following manner: Step 210: Determine whether there is a time series model corresponding to the to-be-predicted metric in the subset of target models; if the judgment result is yes, go to step 220, otherwise go to step 230; Step 220: Use the time series model corresponding to the to-be-predicted metric in the subset of target models as the target model; Step 230: Calculate the prediction errors of each time series model in the subset of target models using the offline data of the to-be-predicted metric, and use the time series model with the smallest prediction error as the target model.
[0030] In step 210, the time series model corresponding to the to-be-predicted metric in the subset of target models refers to the time series model determined in advance for predicting the to-be-predicted metric. The specific determination method can be: calculate the prediction errors of each time series model in the subset of target models using the offline data of the to-be-predicted metric, and use the time series model with the smallest prediction error as the time series model for predicting the to-be-predicted metric. In practical applications, other determination methods can also be selected, and the embodiments of the present application do not limit this.
[0031] Even further, step 120 can be skipped, that is, skip the step of selecting a subset of target models from the preset model set according to the historical data length of the to-be-predicted metric, and directly query whether there is a time series model corresponding to the to-be-predicted metric in the preset model set. If found, directly use this time series model as the target model for prediction. If not found, then execute step 120. As mentioned above, the input length corresponding to the subset of target models selected from the preset model set is less than or equal to the historical data length of the to-be-predicted metric. Therefore, as Figure 3 shown, step 120 of the embodiment of the present application can specifically select a subset of target models from the preset model set in the following manner: Step 310: If there is a subset of models in the preset model set whose input length is equal to the length of the historical data of the to-be-predicted indicator, then use the subset of models whose input length is equal to the length of the historical data of the to-be-predicted indicator as the target model subset; Step 320: If there is no subset of models in the preset model set whose input length is equal to the length of the historical data of the to-be-predicted indicator, then use the subset of models whose input length is less than and closest to the length of the historical data of the to-be-predicted indicator as the target model subset.
[0032] It is worth mentioning that, on the premise of ensuring that the input length is less than the length of the historical data of the to-be-predicted indicator, as a preferred implementation manner, the embodiments of the present application select the input length closest to the length of the historical data of the to-be-predicted indicator. Therefore, it can be ensured that the historical data input into the model reflects the sequence characteristics in a longer time range, thereby obtaining a more reliable prediction result. It can be understood that after the target model is selected through Step 130, the output length of the target model can be obtained. Considering that the to-be-predicted indicator may also have its own prediction length requirement, as a preferred implementation manner, the embodiments of the present application can ensure that the data length of the finally obtained prediction result is equal to the prediction length of the to-be-predicted indicator. That is, Step 140 of the embodiments of the present application specifically generates the prediction result through the following method: Generate a prediction result with a data length equal to the prediction length of the to-be-predicted indicator.
[0033] Specifically, as Figure 4 shown, the embodiments of the present application can generate a prediction result with a data length equal to the prediction length of the to-be-predicted indicator through the following method: Step 410: If the output length of the target model is less than the prediction length of the to-be-predicted indicator, then perform a splicing operation on the output data of the target model multiple times to obtain a prediction result with a data length equal to the prediction length of the to-be-predicted indicator; Step 420: If the output length of the target model is equal to the prediction length of the to-be-predicted indicator, then directly use the output data of the target model as the prediction result; Step 430: If the output length of the target model is greater than the prediction length of the to-be-predicted indicator, then perform an interception operation on the output data of the target model to obtain a prediction result with a data length equal to the prediction length of the to-be-predicted indicator. The above describes the usage process of the preset model set. Next, the preparation work of the preset model set will be introduced. The following preparation work of the preset model set is only used as an example and does not limit the present application.
[0034] First, set a set of combined model parameter configurations. Each model parameter configuration includes an input length and a number of models, and may further include an output length.
[0035] As a preferred implementation, in order to save computing resources and reduce performance consumption, the number of time-series small models with a large input length in the preset model set can be set to be small, and the number of time-series small models with a small input length can be set to be large. That is, when configuring the preset model set, the following quantitative relationship is ensured: In the preset model set, the number of time-series small models with the first length as the input length is greater than the number of time-series small models with the second length as the input length, where the first length is less than the second length.
[0036] Therefore, according to the requirements of different time-series prediction scenarios for the historical data length and prediction length, 4 sets of combined model parameter configurations can be set as follows: Input length = 720, output length = 72, number of models = 8; Input length = 360, output length = 36, number of models = 16; Input length = 180, output length = 18, number of models = 24; Input length = 60, output length = 6, number of models = 32.
[0037] Based on the above configuration, the preset model set includes 80 time-series small models, supporting 4 historical data lengths, namely 720, 360, 180, and 60, which can cover the requirements of most time-series prediction and other scenarios.
[0038] The time-series small models need to be obtained through training with a large amount of data. Therefore, for the target field, a large amount of data is first collected, after cleaning it, clustering operations are performed according to the similarity of the time series.
[0039] Specifically, for each data length, according to the configuration of the preset model set as described above, the clustering number of the data with this data length is set to be equal to the number of models with the same input length. For example, for the data with a data length of 720, its clustering number is set to be the number of models with an input length of 720, that is, the clustering number is set to 8. Each clustering result is a training data set, which is used to train the time-series small model with this input length. The training data set corresponds to the time-series small model one by one, and the time-series small models obtained by training form a model subset. Thus, for different input lengths, a model subset can be correspondingly obtained.
[0040] Therefore, the time series prediction method based on the preset model set supports multiple input lengths, and each input length corresponds to a model subset, which includes multiple time series small models. According to the configuration described above, 80 time series models can be finally obtained, among which 8 models have an input length of 720 and support a historical data length of 720; 16 models have an input length of 360 and support a historical data length of 360; 24 models have an input length of 24 and support a historical data length of 24; 32 models have an input length of 60 and support a historical data length of 60.
[0041] The clustering operation according to the time series similarity described here is an unsupervised learning method, which aims to cluster time series data points with similar behavior patterns together. Its core goal is to discover the internal structure in the data for more in-depth analysis or decision support. Common clustering algorithms include K-means, hierarchical clustering, DBSCAN, spectral clustering, etc. The clustering algorithm needs to select an appropriate distance metric method to measure the similarity between time series. Here, the embodiment of the present application adopts the Dynamic Time Warping (DTW) algorithm. The DTW algorithm allows two sequences to be elastically matched on the time axis to find the best alignment between them. Usually, a distance metric method is used to measure the similarity between time series.
[0042] In summary, as Figure 5 shown, the embodiment of the present application can implement model training in the following manner: Step 510: Determine the number of models configured for time series small models with different input lengths; Step 520: For the target input length, obtain the original data with a data length equal to the target input length; where the target input length is any input length; Step 530: Set the number of clusters equal to the number of time series small models with the input length of the target input length, and perform a clustering operation on the original data to obtain the training data sets for each time series small model with the input length of the target input length; Step 540: Use the training data set to train the corresponding time series small model to obtain a model subset corresponding to the target input length. The following is an example description of the time series prediction process based on the preset model set.
[0043] After preparing the preset model set, for the user's time series prediction requirements, it is necessary to first determine parameters such as the required historical data length and prediction length according to the application scenario and the characteristics of the index data. Here, it is required that the user selects from 4 sets of pre-set model parameter configurations, so as to well adapt to the corresponding time series small models.
[0044] It should be noted that the model parameters do not need to meet fixed requirements. Generally, similar parameter settings can meet the time series prediction needs. Therefore, the method of selecting appropriate model parameters from the preset model parameter configurations is also reasonable and highly practical.
[0045] It is worth mentioning that if the length of the historical data required by the user is too short to even meet the minimum input length of 60, then traditional statistical learning algorithms such as HoltWinters and MovingAverage can be considered. This can further expand the adaptability of the algorithm and meet more time series prediction needs.
[0046] After determining the length of the historical data of the target prediction indicator, a model subset with the same input length (referred to as the target model subset) can be determined. This model subset contains several different time series small models. Therefore, it is also necessary to select a specific model for the target prediction indicator for prediction. Here, a set of offline data of the target prediction indicator is selected, and the prediction errors of each time series small model in the target model subset are calculated. The time series small model with the smallest average prediction error is selected as the target model finally used to predict the target prediction indicator.
[0047] Furthermore, an identifier called UUID is assigned to each target prediction indicator. Similarly, identifiers called ModelID are also assigned to the 80 time series small models in the preset model set. In this way, for each target prediction indicator, a mapping relationship can be established: UUID ---> ModelID. During actual prediction and inference, the ModelID corresponding to the UUID of the target prediction indicator is found according to the UUID, and the time series small model corresponding to the ModelID is used to provide prediction services for the target prediction indicator.
[0048] In summary, in view of the limitation that traditional time series small models only support fixed input lengths, this application provides a time series prediction method based on a preset model set. This method first sets a combined model parameter configuration, including input length + output length + number of models. Then, a large amount of data in the target domain is collected. For each target input length, the number of clusters of the original data is set to be equal to the number of models corresponding to the target input length in the configuration. The original data with this data length (i.e., data length = target input length) is subjected to cluster analysis according to time series correlation to obtain a training data set, which is used to train the corresponding time series small model to obtain a model subset corresponding to this target input length. Finally, the preset model set includes time series small models with multiple input lengths, and the time series small models of each input length are combined into a model subset. Therefore, this preset model set supports multiple historical data lengths and covers most time series prediction needs.
[0049] In actual prediction, for each index to be predicted, first determine the length of the historical data to be used, then determine the subset of models with the corresponding input length, and then use the offline data of the index to be predicted to select a time series small model with the smallest average prediction error from the subset of models, which is called the target model. During prediction inference, use this target model to provide prediction services for the index to be predicted.
[0050] Through these measures, the limitation of the fixed input length of traditional time series small models can be effectively avoided, greatly expanding the application scenarios of time series small models, which is conducive to improving the competitiveness of time series prediction products in the AIGC field. Based on the same inventive concept, the present application also provides a time series prediction device, the structural schematic diagram of which is as Figure 6 shown, specifically including: An input module 610, configured to obtain historical data of the index to be predicted; A subset determination module 620, configured to select a target model subset from a preset model set according to the length of the historical data of the index to be predicted, where the preset model set includes multiple model subsets, different model subsets correspond to different input lengths, each model subset includes any number of time series small models with the corresponding input length, and the input length corresponding to the target model subset is less than or equal to the length of the historical data of the index to be predicted; A model determination module 630, configured to calculate the prediction error of each time series small model in the target model subset by using the offline data of the index to be predicted, and use the time series small model with the smallest prediction error as the target model; An output module 640, configured to use the target model to generate a prediction result according to the historical data of the index to be predicted.
[0051] In some specific embodiments, the model determination module 630 determines the target model in the following specific manner: Judge whether there is a time series small model corresponding to the index to be predicted in the target model subset; if the judgment result is yes, use the time series small model corresponding to the index to be predicted in the target model subset as the target model; if the judgment result is no, calculate the prediction error of each time series small model in the target model subset by using the offline data of the index to be predicted, and use the time series small model with the smallest prediction error as the target model.
[0052] In some specific embodiments, the subset determination module 620 selects the target model subset from the preset model set in the following specific manner: If there is a model subset with an input length equal to the historical data length of the to-be-predicted metric in the preset model set, then use the model subset with an input length equal to the historical data length of the to-be-predicted metric as the target model subset; and / or, if there is no model subset with an input length equal to the historical data length of the to-be-predicted metric in the preset model set, then use the model subset with an input length less than and closest to the historical data length of the to-be-predicted metric as the target model subset.
[0053] In some specific embodiments, the output module 640 generates the prediction result in the following specific manner: Generate a prediction result with a data length equal to the prediction length of the to-be-predicted metric.
[0054] In some specific embodiments, the output module 640 generates the prediction result with a data length equal to the prediction length of the to-be-predicted metric in the following specific manner: If the output length of the target model is less than the prediction length of the to-be-predicted metric, then perform a splicing operation on the output data of the target model multiple times to obtain a prediction result with a data length equal to the prediction length of the to-be-predicted metric; and / or, if the output length of the target model is equal to the prediction length of the to-be-predicted metric, then use the output data of the target model as the prediction result; and / or, if the output length of the target model is greater than the prediction length of the to-be-predicted metric, then perform a truncation operation on the output data of the target model to obtain a prediction result with a data length equal to the prediction length of the to-be-predicted metric.
[0055] In some specific embodiments, in the preset model set, the number of time series small models with an input length of the first length is greater than the number of time series small models with an input length of the second length, where the first length is less than the second length.
[0056] In some specific embodiments, the device further includes: A training module, configured to determine the number of models configured for time series small models with different input lengths; for a target input length, obtain raw data with a data length equal to the target input length; set the number of clusters equal to the number of models of the time series small models with the input length of the target input length, perform a clustering operation on the raw data to obtain a training data set for each time series small model with the input length of the target input length; and use the training data set to train the corresponding time series small model to obtain a model subset corresponding to the target input length. An embodiment of the present application provides an electronic device, which may include: a memory and one or more processors. The memory is used to store computer program code, and the computer program code includes computer instructions. When the processor executes the computer instructions, the electronic device can perform each function or step of the above method embodiment.
[0057] The structure of the electronic device may refer to Figure 7 the structure of the electronic device 100 shown.
[0058] The above-mentioned processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0059] An embodiment of the present application further provides a computer-readable storage medium, which includes computer instructions. When the computer instructions run on an electronic device, the electronic device is enabled to perform each function or step of the above method embodiment.
[0060] The above-mentioned computer-readable storage medium includes, but is not limited to, any one of the following: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disc, etc., which are various media that can store program code.
[0061] An embodiment of the present application further provides a computer program product. When the computer program product runs on a computer, the computer is enabled to perform each function or step of the above method embodiment.
[0062] Among them, the electronic device, the computer-readable storage medium, and the computer program product provided by the embodiments of the present application are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding methods provided above, and will not be elaborated here. Through the description of the above embodiments, those skilled in the art can clearly understand that for the convenience and brevity of description, only the division of the above functional modules is used as an example. In actual applications, the above functions can be allocated to different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above.
[0063] In several embodiments provided in the present application, it should be understood that the disclosed method can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of the modules or units is only a logical function division, and there can be other division methods in actual implementation; for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the displayed or discussed coupling or direct coupling or communication connection to each other can be through some interfaces, and the indirect coupling or communication connection of the modules or units can be in electrical, mechanical or other forms.
[0064] In addition, each functional unit in the various embodiments of the present application can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
[0065] The above is only the specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application should be covered by the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
Claims
1. A time series prediction method, characterized in that, The method includes: Obtaining historical data of the to-be-predicted metric; Selecting a target model subset from a preset model set according to the length of the historical data of the to-be-predicted metric, where the preset model set includes multiple model subsets, different model subsets correspond to different input lengths, each model subset includes any number of time-series small models with corresponding input lengths, and the input length corresponding to the target model subset is less than or equal to the length of the historical data of the to-be-predicted metric; Calculating the prediction errors of each time-series small model in the target model subset by using the offline data of the to-be-predicted metric, and taking the time-series small model with the smallest prediction error as the target model; Generating a prediction result according to the historical data of the to-be-predicted metric by using the target model.
2. The method according to claim 1, wherein The method specifically determines the target model in the following manner: Judging whether there is a time-series small model corresponding to the to-be-predicted metric in the target model subset; If the judgment result is yes, taking the time-series small model corresponding to the to-be-predicted metric in the target model subset as the target model; If the judgment result is no, calculating the prediction errors of each time-series small model in the target model subset by using the offline data of the to-be-predicted metric, and taking the time-series small model with the smallest prediction error as the target model.
3. The method according to claim 1, characterized in that, The method specifically selects the target model subset from the preset model set in the following manner: If there is a model subset in the preset model set whose input length is equal to the length of the historical data of the to-be-predicted metric, taking the model subset whose input length is equal to the length of the historical data of the to-be-predicted metric as the target model subset; and / or, If there is no model subset in the preset model set whose input length is equal to the length of the historical data of the to-be-predicted metric, taking the model subset whose input length is less than and closest to the length of the historical data of the to-be-predicted metric as the target model subset.
4. The method according to claim 1, wherein The method specifically generates the prediction result in the following manner: Generating a prediction result with a data length equal to the prediction length of the to-be-predicted metric.
5. The method according to claim 4, wherein The method specifically generates the prediction result with a data length equal to the prediction length of the to-be-predicted metric in the following manner: If the output length of the target model is less than the prediction length of the to-be-predicted metric, performing a splicing operation on the output data of the target model multiple times to obtain a prediction result with a data length equal to the prediction length of the to-be-predicted metric; and / or, If the output length of the target model is equal to the prediction length of the to-be-predicted metric, taking the output data of the target model as the prediction result; and / or, If the output length of the target model is greater than the prediction length of the to-be-predicted metric, performing a truncation operation on the output data of the target model to obtain a prediction result with a data length equal to the prediction length of the to-be-predicted metric.
6. The method according to claim 1, characterized in that, In the preset model set, the number of time-series small models with the first length as the input length is greater than the number of time-series small models with the second length as the input length, where the first length is less than the second length.
7. The method according to claim 6, wherein The method further includes: Determining the number of models configured for time-series small models with different input lengths; For the target input length, obtaining the original data with a data length equal to the target input length. Set the number of clusters equal to the number of models of the temporal small model with the input length being the target input length, and perform a clustering operation on the original data to obtain the training data sets of the respective temporal small models with the input length being the target input length; Use the training data sets to train the corresponding temporal small models to obtain a model subset corresponding to the target input length.
8. A timing prediction device, characterized in that, The device includes: An input module, configured to obtain historical data of an index to be predicted; A subset determination module, configured to select a target model subset from a preset model set according to the length of the historical data of the index to be predicted, where the preset model set includes multiple model subsets, different model subsets correspond to different input lengths, each model subset includes any number of temporal small models with the corresponding input length, and the input length corresponding to the target model subset is less than or equal to the length of the historical data of the index to be predicted; A model determination module, configured to calculate the prediction errors of the respective temporal small models in the target model subset by using the offline data of the index to be predicted, and use the temporal small model with the smallest prediction error as the target model; An output module, configured to generate a prediction result according to the historical data of the index to be predicted by using the target model.
9. An electronic device, characterized in that, Includes: A memory and one or more processors; the memory is coupled to the processor; wherein, computer program code is stored in the memory, and the computer program code includes computer instructions, and when the computer instructions are executed by the processor, the electronic device executes the method according to any one of claims 1-7.
10. A computer-readable storage medium, comprising computer instructions, characterized in that, When the computer instructions run on an electronic device, the electronic device is caused to execute the method according to any one of claims 1-7.
11. A computer program product, characterized in that, When the computer program product runs on a computer, the computer is caused to execute the method according to any one of claims 1-7.
Citation Information
Cited By
A method and apparatus for predicting network indicators
CN122679057A