WO2023020257A1 - Data prediction method and apparatus, and storage medium - Google Patents

Data prediction method and apparatus, and storage medium Download PDF

Info

Publication number
WO2023020257A1
WO2023020257A1 PCT/CN2022/108936 CN2022108936W WO2023020257A1 WO 2023020257 A1 WO2023020257 A1 WO 2023020257A1 CN 2022108936 W CN2022108936 W CN 2022108936W WO 2023020257 A1 WO2023020257 A1 WO 2023020257A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
prediction
level
preset
training
Prior art date
Application number
PCT/CN2022/108936
Other languages
French (fr)
Chinese (zh)
Inventor
耿东阳
张建申
Original Assignee
北京沃东天骏信息技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 北京沃东天骏信息技术有限公司 filed Critical 北京沃东天骏信息技术有限公司
Publication of WO2023020257A1 publication Critical patent/WO2023020257A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/953Querying, e.g. by the use of web search engines
    • G06F16/9535Search customisation based on user profiles and personalisation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/953Querying, e.g. by the use of web search engines
    • G06F16/9537Spatial or temporal dependent retrieval, e.g. spatiotemporal queries
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/214Generating training patterns; Bootstrap methods, e.g. bagging or boosting

Definitions

  • the embodiments of the present application relate to the technical field of prediction models, and relate to a data prediction method, device, and storage medium.
  • Time series forecasting has a wide range of applications, such as financial market forecasting, logistics volume forecasting, and so on. In the process of realizing automation and intelligence in many fields, time series forecasting plays a very important role. Therefore, forecasting technical capabilities will ultimately have an important impact on item transaction volume, inventory costs, etc. At the same time, the logistics volume of large logistics warehouses can reach up to one million, and large-scale time series pose new challenges to modern time series forecasting technology.
  • time series forecasting uses single-level data to make forecasts, and then obtains forecast results of other levels by splitting or aggregating.
  • the existing forecasting methods essentially only use the forecasting results of a single level, and do not use the information contained in the forecasting data of other levels, resulting in the loss of accuracy;
  • the forecasting results are aggregated upward or decomposed downward It also introduces additional prediction error.
  • the results obtained by using different single levels are different, it not only depends on manual experience in the selection of levels, but also leads to loss of accuracy.
  • a data prediction method, device, and storage medium provided in the embodiments of the present application.
  • the embodiment of the present application provides a data prediction method, including:
  • hierarchical time series data are multiple sets of data corresponding to time series of each level, wherein the sum of the data of the sub-levels of each level in each level is equal to the data of the corresponding parent level;
  • the preset data prediction model is based on the hierarchical time series data, the prediction errors of multiple sets of training data in the historical preset time period, and the errors between each level are jointly trained.
  • the method uses the preset data forecasting model to predict the hierarchical time series data, before determining the forecast results in the preset time period after multiple historical time periods, after obtaining the hierarchical time series data, the method also includes :
  • the training set includes: multiple sets of training data;
  • the test set includes: Multiple sets of test data;
  • the loss function of the initial prediction model uses the loss function of the initial prediction model to calculate the prediction error of the training set and the error between each level, and iteratively adjust the model parameters of the initial prediction model according to the prediction error and the error between each level until the training conditions are met.
  • a preset data prediction model is determined by comparing multiple sets of test data with the first prediction data set.
  • the loss function of the initial prediction model uses the loss function of the initial prediction model to calculate the prediction error of the training set and the error between each level, and iteratively adjust the model parameters of the initial prediction model according to the prediction error and the error between each level until it meets the training requirements.
  • the first prediction data set corresponding to the test set is obtained, including:
  • the second forecasting data set includes: forecasting data of various levels in multiple historical time periods;
  • the prediction error and the error between each level are calculated in combination with a loss function
  • the prediction data of each level of each historical time period corresponding to the test set is extracted, and then the first prediction data set in the iterative process is obtained.
  • the prediction error and the error between each level are calculated in combination with the loss function, including:
  • the prediction error is calculated;
  • the first prediction data is the prediction data of each level in multiple first time periods in the second prediction data set;
  • multiple The first time period is a time period before a preset historical time period among the plurality of historical time periods;
  • the second prediction data is the prediction data of each level in a plurality of second time periods in the second prediction data set; a plurality of second time periods The time period after the preset historical time period for multiple historical time periods.
  • the prediction error is calculated based on the first prediction data in the second prediction data set and multiple sets of training data, including:
  • the calculation of the error between each level includes:
  • multiple sets of test data are compared with the first prediction data set to determine a preset data prediction model, including:
  • a preset data prediction model corresponding to the target iteration is determined among multiple prediction models.
  • multiple sets of training data include: multiple sets of first processed data; multiple sets of test data include: multiple sets of second processed data;
  • a preset historical time period is determined in a plurality of historical time periods, and multiple groups of first processed data corresponding to a plurality of first time periods before the preset historical time period are combined into the training set, and the preset historical time period is Multiple groups of second processed data corresponding to multiple second time periods after the first time period are combined into the test set.
  • the method also includes:
  • a preset data forecasting model is used to process multiple sets of logistics cargo volume data to obtain predicted logistics cargo volume data for a preset time period after multiple historical time periods.
  • the embodiment of the present application also provides a data prediction device, including:
  • the data acquisition module is configured to obtain hierarchical time series data;
  • the hierarchical time series data are multiple sets of data corresponding to the time series of each level, wherein the sum of the data of the sub-levels of each level in each level is equal to the data of the corresponding parent level data;
  • the prediction module is configured to use a preset data prediction model to predict hierarchical time series data, and determine the prediction results within a preset time period after multiple historical time periods; wherein,
  • the preset data prediction model is obtained by joint training based on the prediction errors of multiple sets of training data in the historical preset time period in the hierarchical time series data, and the errors between each level.
  • the embodiment of the present application also provides a data prediction device, including a memory and a processor, the memory stores a computer program that can run on the processor, and the processor implements the steps in the above method when executing the program.
  • the embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps in the above method are implemented.
  • FIG. 1 is an optional schematic flow chart of the data prediction method provided by the embodiment of the present application.
  • FIG. 2 is a schematic diagram of an optional effect of the data prediction method provided by the embodiment of the present application.
  • FIG. 3 is a schematic diagram of an optional effect of the data prediction method provided by the embodiment of the present application.
  • FIG. 4 is an optional schematic flow chart of the data prediction method provided in the embodiment of the present application.
  • FIG. 5 is an optional schematic flow chart of the data prediction method provided by the embodiment of the present application.
  • FIG. 6 is an optional schematic flow chart of the data prediction method provided by the embodiment of the present application.
  • FIG. 7 is an optional schematic flow chart of the data prediction method provided by the embodiment of the present application.
  • FIG. 8 is an optional schematic flow chart of the data prediction method provided by the embodiment of the present application.
  • FIG. 9 is an optional schematic flow chart of the data prediction method provided by the embodiment of the present application.
  • FIG. 10 is a schematic structural diagram of a logistics volume forecasting device provided in an embodiment of the present application.
  • FIG. 11 is an optional schematic flow chart of the data prediction method provided by the embodiment of the present application.
  • FIG. 12 is a first structural schematic diagram of a data prediction device provided by an embodiment of the present application.
  • FIG. 13 is a second structural schematic diagram of the data prediction device provided by the embodiment of the present application.
  • FIG. 14 is a schematic diagram of a hardware entity of a data prediction device provided by an embodiment of the present application.
  • first/second in the application documents, add the following explanation.
  • first ⁇ second ⁇ third are only used to distinguish similar objects and do not mean Regarding the specific ordering of objects, it can be understood that “first ⁇ second ⁇ third” can be interchanged with specific order or sequence if allowed, so that the embodiment of the application described here can be used in addition to the performed in an order other than that shown or described.
  • a national fast-moving consumer goods manufacturer needs to predict the future sales of a certain product in the whole country and provinces at the same time in order to formulate inventory layout and stocking plan.
  • the forecasting scheme is to make a single time-series forecast for the sales time series of each province and the whole country, then the forecast results of these different levels often do not automatically meet the consistency, that is, the sales forecast of the whole country is not equal to the sum of the sales forecast of each province. "Inconsistent" prediction results cannot be used in the collaborative decision-making process at all levels.
  • the main forecasting methods include: “Top-Down”, “Bottom-Up”, “Middle-Out” and “Optimal Blending”.
  • top-down refers to forecasting the highest-level time series first, and then splitting the forecast results to lower levels according to a fixed ratio.
  • Bottom-up refers to first predicting the most granular time series, and then The prediction results are aggregated upwards.
  • the "break in the middle” approach combines bottom-up and top-down approaches. First, an “intermediate level” is selected and forecasts are generated for all series at that level. For series above the middle level, a bottom-up approach is used to generate consensus forecasts by aggregating forecasts from the "middle level” upwards.
  • a top-down approach is used to generate consensus forecasts by disaggregating the forecast for the "intermediate level” downwards.
  • the “optimal reconciliation” method is to first obtain the prediction results of all levels, and then process the prediction results through the optimal linear weighted reconciliation method, and then obtain the final result.
  • the embodiment of the present application also provides a data prediction method, please refer to Figure 1, which is an optional schematic flow chart of the data prediction method provided by the embodiment of the present application , will be described in conjunction with the steps shown in FIG. 1 .
  • the hierarchical time series data are multiple sets of data corresponding to the time series of each level, wherein the sum of the data of the sub-levels of each level in each level is equal to the data of the corresponding parent level.
  • the server acquires hierarchical time series data.
  • the hierarchical time series data are multiple sets of data corresponding to each hierarchical time series.
  • the sum of the data of the sub-levels of each level in each level is equal to the data of the corresponding parent level.
  • the server establishes communication connections with clients corresponding to each level in advance.
  • the server obtains multiple sets of data of various levels corresponding to multiple historical time periods from the client through the communication connection with the clients of each level. That is, the server obtains multiple sets of data corresponding to the time series of each level from the clients of each level.
  • the server acquires the pre-stored hierarchical time series data in its own database.
  • any set of data among the multiple sets of data may include: a combination of data corresponding to each level of any time series. That is, any set of data among multiple sets of data may include: a combination of data at various levels corresponding to any one of multiple historical time periods.
  • one data in a group of data may be any one of sales data, logistics data, and user age data of a corresponding level.
  • the logistics flow data may be one of the corresponding total logistics pieces, total logistics weight and total logistics volume.
  • the time series may be three time series respectively corresponding to three months before the current moment.
  • the time series may also be three time series respectively corresponding to the three days before the current moment, and in the embodiment of the present application, the time series are not limited.
  • the sub-level may be the city level, and the parent level may be the provincial level corresponding to the sub-level.
  • a provincial level can correspond to multiple city levels.
  • the parent level can also be a first-level agent, and the sub-level can be multiple second-level agents corresponding to the parent level.
  • One first-level agent can correspond to multiple second-level agents.
  • the sum of the data of multiple sub-levels is the data of the corresponding parent level.
  • the server first collects hierarchical time series data to be predicted.
  • the hierarchical time series data satisfies that the sum of the data of each sub-level is equal to the data of the corresponding parent level.
  • y 1 is the parent level data corresponding to y 2 and y 3
  • y 2 and y 3 are the child level data corresponding to y 1 .
  • y 2 is the parent level data corresponding to y 4 and y 5
  • y 3 is the parent level data corresponding to y 6 and y 7 .
  • the task of hierarchical time series forecasting is to predict the value of all time series in the future period t+h given the observation data at time 1,...,t 0 where y is the data in the time series data. When the time series is a day dimension, it is the daily volume.
  • y_Beijing (10, 20, 30, 40, 50)
  • y_Hebei province (30, 40, 50, 60, 10).
  • the constraint condition is often expressed graphically by the hierarchical structure diagram shown.
  • This type of constraint is the basic feature of hierarchical time series, and it is also the embodiment of the meaning of "layered”.
  • S102 Use the preset data prediction model to predict the hierarchical time series data, and determine the prediction results in the preset time period after multiple historical time periods; wherein, the preset data prediction model is based on the hierarchical time series data Among them, the prediction errors of multiple sets of training data in the historical preset time period, and the errors between the various levels are jointly trained.
  • the server uses the preset data prediction model to predict the hierarchical time series data, and determines the prediction results in the preset time period after multiple historical time periods; wherein, the preset data prediction model is based on In the hierarchical time series data, the prediction errors of multiple sets of training data in the historical preset time period, and the errors between the various levels are jointly trained.
  • the server divides multiple sets of data into a training set and a test set.
  • the server iteratively trains the initial prediction model by combining the training data with the loss function.
  • the server obtains multiple prediction models corresponding to multiple iterations through iterative training.
  • the server compares the forecast data of each iteration with the corresponding real data to obtain the forecast error of each iteration.
  • the server determines that the prediction model corresponding to the number of iterations with the smallest error is the preset data prediction model.
  • hierarchical time series data are multiple sets of data corresponding to time series of each level, wherein the sum of the sub-level data of each level in each level is equal to that of the corresponding parent level Data; use the preset data forecasting model to predict the hierarchical time series data, and determine the forecast results in the preset time period after multiple historical time periods; wherein, the preset data forecasting model is based on the hierarchical time series data Among them, the prediction errors of multiple sets of training data in the historical preset time period, and the errors between the various levels are jointly trained.
  • the preset data prediction model is based on the prediction error of multiple sets of training data in the historical time period and the error training between each level, not only the accuracy of the prediction error but also the difference between each level are taken into account during training. Error, so the pre-set data prediction model trained to predict the data is more accurate.
  • FIG. 4 is an optional flowchart of the data prediction method provided by the embodiment of the present application.
  • S101 shown in FIG. 1 also includes the implementation of S103 to S105, which will be described in conjunction with each step .
  • S103 Standardize the multiple sets of data of the hierarchical time series data, and divide the standardized multiple sets of data into a training set and a test set according to preset historical time periods.
  • the server standardizes multiple sets of data of hierarchical time series data, and divides the multiple sets of standardized data into a training set and a test set according to preset historical time periods.
  • the training set includes: multiple sets of training data.
  • the test set includes: multiple sets of test data.
  • the server can delete redundant data in multiple sets of data and fill them with the average data of the corresponding levels, or the server can fill the blank data of each level in the multiple sets of data with the average data of the corresponding levels to obtain the processed multiple sets of data. Since multiple sets of data correspond to multiple historical time periods.
  • the server determines a preset historical time period in multiple historical time periods, and the server determines several sets of training data corresponding to the preset historical time period as a training set.
  • the server determines the corresponding sets of test data after the preset historical time period as the test set.
  • the training set is the data set used to train the initial prediction model.
  • the test set is the data set used to determine the preset data prediction model.
  • the server uses the loss function of the initial prediction model to calculate the prediction error of the training set and the error between each level, and iteratively adjusts the model parameters of the initial prediction model according to the prediction error and the error between each level. Stop until the training condition is satisfied, and obtain the first prediction data set corresponding to the test set.
  • the first prediction data set includes: multiple prediction data in the iterative process of each level corresponding to each historical time period of the test set.
  • the server inputs multiple sets of training data in the training set into the initial prediction model.
  • a second forecast data set is obtained.
  • the second forecast data set includes: forecast data of various levels in multiple historical time periods.
  • the server calculates the prediction errors of the multiple sets of training data and the errors between levels by combining the loss function.
  • the server solves the loss function to obtain the model parameters for this training.
  • the server adjusts the initial prediction model according to the model parameters to obtain a new prediction model.
  • the server continues to train multiple sets of training data through the new prediction model, and stops when the training conditions are met, to obtain the final prediction model.
  • the first prediction data set corresponding to the test set in the iterative process is also obtained.
  • satisfying the training condition may be: reaching a preset number of training times or convergence of a loss function value.
  • the server compares multiple sets of test data with the first prediction data set to determine a preset data prediction model.
  • the first prediction data set includes: multiple prediction data corresponding to multiple iterations of the test set.
  • the server compares the data of each level in each time period in multiple sets of test data with the corresponding data in each forecast data to determine the error of each level, and then adds the errors of each level to obtain the error of each forecast data . Furthermore, multiple errors corresponding to multiple forecast data can be determined.
  • the server determines that the predictive model corresponding to the iteratively adjusted primary predictive data with the smallest error is the preset data predictive model.
  • the server subtracts the data of each level in each time period in multiple sets of test data from the corresponding data in a certain forecast data to obtain the error of the data in each level corresponding to each time period.
  • the server adds the errors of the data of each level in each time period to obtain the error corresponding to the forecast data.
  • the server iteratively adjusts the prediction model through the prediction error and the error between each level, and obtains multiple prediction models in the iterative process.
  • the server compares the multiple sets of test data with the first prediction data set to determine a preset data model. Since the preset data prediction model is based on the prediction error of multiple sets of training data in the historical time period and the error training between each level, not only the accuracy of the prediction error but also the difference between each level are taken into account during training. Error, so the pre-set data prediction model trained to predict the data is more accurate.
  • FIG. 5 is an optional flowchart of the data prediction method provided by the embodiment of the present application.
  • S104 shown in FIG. 4 can also be implemented through S106 to S110, which will be described in conjunction with each step .
  • the server inputs multiple sets of training data into the initial prediction model to obtain the second prediction data set of the first iteration in the iterative process.
  • the second forecast data set includes: forecast data of various levels in multiple historical time periods.
  • the server inputs multiple sets of training data into the initial prediction model to obtain the second prediction data set for the first training.
  • the server calculates the prediction error and the error between each level according to the first second prediction data set and the loss function.
  • the server obtains the model parameters according to the prediction error and the error between each level, adjusts the initial prediction model, and obtains the next updated prediction model.
  • the server again inputs multiple sets of training data into the prediction model to be updated next time, and then executes the above process to complete the iteration.
  • the server calculates the prediction error and the error between each level based on the second prediction data set and multiple sets of training data in combination with a loss function.
  • the loss function is the function corresponding to the initial prediction model.
  • the server calculates prediction errors corresponding to multiple sets of training data in multiple first time periods based on the second prediction data set and multiple sets of training data in combination with a loss function.
  • the multiple first time periods are the time periods before the preset historical time period among the multiple historical time periods.
  • the prediction error characterizes the error between the predicted data and the corresponding data in multiple sets of training data.
  • the server calculates errors between levels in the second prediction data set for multiple second time periods in combination with a loss function.
  • the multiple second time periods are time ends after the preset historical time period among the multiple historical time periods.
  • the error between the various levels represents the error between the data of the parent level and the data of the corresponding child level in the second predicted data set.
  • the server uses the prediction error and the error between each level to solve the gradient of the loss function to obtain the model parameters in the iterative process, thereby obtaining an updated prediction model.
  • the server uses the prediction error and the error between each level to solve the loss function gradient after each iteration, and obtains the model parameters of each iteration in the iterative process.
  • the server adjusts the current forecasting model through each model parameter to obtain an updated forecasting model.
  • the server continues to train multiple sets of training data by using the updated prediction model, and stops when the training conditions are met to obtain the final prediction model, thereby obtaining multiple prediction models in the iterative process.
  • the network structure of the prediction model will be based on the prediction error and the error between each layer through the output layer, and then back-transmit layer by layer to the intermediate layer and input layer, and correct the weights of each layer in the way of gradient descent.
  • a new prediction model is obtained.
  • the network structure of the new prediction model will continue to train the training set until the training conditions are met and stop, and multiple prediction models in the iterative process will be obtained.
  • the server extracts the prediction data of each level in each historical time period of the corresponding test set from each of the corresponding second prediction data sets obtained by using multiple prediction models, and then obtains the first prediction data in the iterative process.
  • a prediction data set obtained by using multiple prediction models.
  • the server extracts the prediction data of each level corresponding to each historical time period of the test set from each second prediction data set, and obtains a prediction data set corresponding to each iteration.
  • the server combines the prediction data set of each iteration to form the first prediction data set.
  • the server inputs multiple sets of training data into the initial prediction model to obtain the second set of prediction data.
  • the server calculates the prediction error and the error between each level through the second prediction data set.
  • the server iteratively adjusted the prediction model through the prediction error and the error between each level, and obtained multiple prediction models in the iterative process.
  • the server may extract the first prediction data set from the multiple second prediction data sets in the iterative process for comparison. Since the preset data prediction model is based on the prediction error of multiple sets of training data in the historical time period and the error training between each level, not only the accuracy of the prediction error but also the difference between each level are taken into account during training. Error, so the pre-set data prediction model trained to predict the data is more accurate.
  • FIG. 6 is an optional flowchart of the data prediction method provided by the embodiment of the present application.
  • S107 shown in FIG. 5 can also be implemented through S111 to S112, which will be described in conjunction with each step .
  • the server calculates the prediction error based on the first prediction data in the second prediction data set and multiple sets of training data.
  • the first forecast data is the forecast data of each level in the plurality of first time periods in the second forecast data set.
  • the multiple first time periods are time periods before the preset historical time period among the multiple historical time periods.
  • the server calculates errors between levels based on the second prediction data in the second prediction data set.
  • the second forecast data is the forecast data of each level in the multiple second time periods in the second forecast data set.
  • the multiple second time periods are time periods after the preset historical time period among the multiple historical time periods.
  • the server builds a DeepAR-based hierarchical time series prediction model.
  • the DeepAR model is a time series forecasting model based on a recurrent neural network, which can be used for general time series forecasting, but cannot be directly used for hierarchical time series forecasting. Therefore, for the hierarchical time series prediction task, the improved loss function (1) designed by the present application for hierarchical time series prediction is:
  • C is a set of constraints derived from the hierarchical structure. is the predicted value of the "parent node” time series in constraint c at time t, is the predicted value of the "leaf node” time series in constraint c at time t, and J(c) is the number of "leaf nodes”.
  • n is the number of each level
  • t0 is the number of multiple first time periods
  • T is the number of multiple second time periods.
  • FIG. 7 is an optional schematic flowchart of the data prediction method provided by the embodiment of the present application.
  • S111 to S112 shown in FIG. 6 can also be realized through S113 to S115, and each step will be combined Be explained.
  • the server calculates the sum of squares of the differences between the first prediction data in the same first time period and the training data of the corresponding level, and then obtains the first sum of each level in the same first time period.
  • the server adds the multiple first sums corresponding to the multiple first time periods to obtain the prediction error.
  • the multiple first time periods include: two first time periods.
  • Each level includes: a parent level (a first-level agent) and two corresponding sub-levels (two second-level agents).
  • the server calculates the sum of the squares of the difference between the data of the parent level and the corresponding forecast data in the first first time period, calculates the sum of the squares of the differences between the data of the two sub-levels and the corresponding forecast data, and then the server calculates the sum of the squares of the difference between the data of the parent level and the corresponding forecast data
  • the sum of squares is added to the sum of squares of the differences corresponding to the two sublevels, resulting in a first sum corresponding to the first first time period.
  • the server uses the same method to calculate the first sum corresponding to the second time period.
  • the server adds the two first sums to get the prediction error.
  • the server calculates the sum of the squares of the differences between the forecast data of each parent level of each layer in the second forecast data in the same second time period and the sum of the forecast data of the corresponding sub-levels, and combines the multiple The multiple sums of squares for the two time periods are added to obtain a second sum.
  • the multiple second time periods include: two second time periods.
  • Each level includes: a parent level (a first-level agent) and two corresponding sub-levels (two second-level agents).
  • the server calculates the sum of squares of differences between the data of the parent level and the sum of predicted data of corresponding sub-levels in the first second time period. Similarly, the server uses the same method to calculate the sum of squares corresponding to the second time period. The server adds the two sums of squares to get the second sum.
  • the server obtains the error between various levels by using multiple hyperparameters of the second sum and harmonic error penalty term.
  • the harmonic error penalty hyperparameter can be any positive number.
  • hierarchical time series forecasting essentially adds consistency constraints between levels to the final forecasting results, namely:
  • the hierarchical structure deviation term in the loss function is essentially a lower bound of the prediction error.
  • Intuitive understanding means that although the prediction results that satisfy the consistency between levels do not necessarily guarantee the highest prediction accuracy, since the future The real data must meet the consistency, then if the error between the levels of the prediction results is large, then the prediction accuracy rate must not be very high, so adding this item to the loss function can help improve the layering time Predictive Performance for Sequence Forecasting.
  • the server calculates the prediction error and the error between levels respectively by using the first prediction data and the second prediction data in the second prediction data set. Since the server considers the error between each level in the process of calculating the error in combination with the loss function, the prediction model adjusted by the model parameters of the loss function is more accurate in predicting the data.
  • FIG. 8 is an optional flowchart of the data prediction method provided by the embodiment of the present application.
  • S103 shown in FIG. 3 can be implemented through S116 to S118 , which will be described in conjunction with each step.
  • the server uses the average data of each level to update the abnormal value in each level.
  • the average data is the average value of the data of multiple levels in multiple historical time periods of the level corresponding to the abnormal value.
  • the server uses the average data corresponding to the levels with blank data to fill the blank data corresponding to each level in multiple sets of data, and then obtain multiple sets of processed data corresponding to the time series of each level.
  • S118 Determine a preset historical time period in a plurality of historical time periods, combine multiple sets of first processed data corresponding to a plurality of first time periods before the preset historical time period into a training set, and combine the preset historical time period Multiple groups of second processed data corresponding to multiple second time periods after the period are combined into a test set.
  • the server determines a preset historical time period in a plurality of historical time periods, and combines multiple sets of first processed data corresponding to a plurality of first time periods before the preset historical time period into a training set, Multiple groups of second processed data corresponding to multiple second time periods after the preset historical time period are combined into a test set.
  • the multiple historical time periods may include: 12 time periods corresponding to January to December.
  • the server may determine September as the preset historical time period.
  • the multiple first time periods are 8 time periods corresponding to January-August, and the multiple second time periods can also be 3 corresponding to October-December period.
  • the server standardizes multiple sets of data, deletes outliers and fills in blank data, thereby making the data structure of multiple sets of data more complete, which is beneficial to model training.
  • FIG. 8 is an optional flowchart of the data prediction method provided by the embodiment of the present application.
  • S105 shown in FIG. 3 can be implemented through S119 to S122 , which will be described in conjunction with each step.
  • the server compares multiple sets of test data with multiple prediction data in the first prediction data set, and determines multiple comparison errors corresponding to the multiple prediction data.
  • Each prediction data is the prediction data of each level of each historical time period obtained in each iteration training process.
  • the server compares the test data of each level in each time period in multiple sets of test data with the corresponding forecast data in a certain forecast data set of the first forecast data set.
  • the server determines the errors corresponding to the test data of each level in each time period.
  • the server adds the errors corresponding to the test data of each level in each time period to obtain the error corresponding to each time period, that is, the error of each set of test data is obtained.
  • the server then adds the errors corresponding to each set of test data to obtain the error corresponding to the predicted data. Furthermore, multiple comparison errors of multiple prediction data can be obtained.
  • the server determines a target comparison error within a preset error range from the multiple comparison errors.
  • the server determines the target iteration number corresponding to the target number of prediction data corresponding to the target comparison error.
  • multiple prediction models are formed in the iterative process.
  • the server determines a preset data prediction model corresponding to the target iteration number among multiple prediction models.
  • the server determines the preset data prediction model corresponding to the target iteration number with the smallest error of multiple sets of test data, and because the preset data prediction model does not affect the test set
  • the prediction accuracy is high, and then the hierarchical time series data can be processed through the preset data prediction model, and the prediction result with high prediction accuracy can be obtained.
  • FIG. 9 is an optional schematic flowchart of the data prediction method provided in the embodiment of the present application, which will be described in combination with various steps.
  • the server acquires multiple sets of logistics cargo volume data corresponding to multiple historical time periods.
  • multiple sets of logistics cargo volume data include: shipment volume data and hierarchical relationships of the whole country, each region, and each province.
  • the server uses a preset data prediction model to process multiple sets of logistics cargo volume data to obtain predicted logistics cargo volume data for preset time periods after multiple historical time periods.
  • the server uses the preset data prediction model to process multiple sets of logistics cargo data. Since the preset data prediction model is based on the prediction errors of multiple sets of training data in the historical preset time period, and the The error between them is obtained by training together. Furthermore, by using the preset data prediction model to predict multiple sets of logistics cargo volume data, a prediction result with high accuracy can be obtained.
  • the embodiment of the present application also provides a logistics cargo volume forecasting device 600 for implementing the data forecasting method provided in FIG. 9 .
  • a logistics cargo volume forecasting device 600 for implementing the data forecasting method provided in FIG. 9 .
  • FIG. 10 is a schematic structural diagram of the logistics cargo volume forecasting device provided in the embodiment of the present application.
  • the embodiment of the present application provides a logistics volume forecasting device 600 , including: a data acquisition module 601 , a data preprocessing module 602 , a target prediction model training module 603 and a data prediction model 604 .
  • the data acquisition module 601 is used to acquire the hierarchical relationship between the historical time series data of logistics cargo volume and time series. For example, the shipment data and hierarchical relationship of the whole country, each region, and each province.
  • the data acquisition module 601 is used to execute S123.
  • the data preprocessing module 602 is used for preprocessing the data, removing outliers and filling missing values, and standardizing the data. Then the preprocessed data is divided into training set and test set.
  • the target prediction model training module 603 is used to train the initial network model by using the historical time series data to obtain the target prediction model of the time series data.
  • the data prediction module 604 is configured to use the target prediction model to predict the data of the time series data in the future time period to obtain a prediction result, and store and display the prediction result.
  • FIG. 11 is an optional schematic flowchart of the data prediction method provided in the embodiment of the present application, which will be described in combination with each step.
  • S201 Collect hierarchical time series data to be predicted.
  • the data acquisition module 701 in the data prediction device 700 is used to acquire the hierarchical relationship between historical time series data and time series.
  • S202 Data preprocessing, removing outliers and filling in missing values; data segmentation, dividing training set and test set.
  • the data preprocessing module 702 in the data forecasting device 700 is used to preprocess the historical time series data, remove outliers and fill in missing values, and standardize the data. Then the preprocessed data is divided into training set and test set.
  • the target prediction model training module 703 in the data prediction device 700 is configured to use historical time series data to train an initial network model to obtain a target prediction model for time series data. That is the final model.
  • the data prediction module 704 in the data prediction device 700 is used to use the target prediction model (final model) to predict the data of the time series data in the future time period to obtain the prediction results, and store and display the prediction results .
  • target prediction model final model
  • the DeepAR time series prediction model is constructed based on the prediction errors of multiple sets of training data in the hierarchical time series data in the historical time period, and the errors between each level, not only the prediction error is taken into account when training the DeepAR time series prediction model Accuracy also takes into account the errors between the various levels, so the final model trained is more accurate in predicting the data.
  • the embodiment of the present application further provides a data prediction device 700 for executing the data prediction method provided in FIG. 11 .
  • a data prediction device 700 for executing the data prediction method provided in FIG. 11 .
  • FIG. 12 is a first structural diagram of the data prediction device provided in the embodiment of the present application.
  • the embodiment of the present application provides a data prediction device 700 , including: a data acquisition module 701 , a data preprocessing module 702 , a target prediction model training module 703 and a data prediction model 704 .
  • the data acquisition module 701 is used to acquire the hierarchical relationship between historical time series data and time series.
  • the data preprocessing module 702 is used for preprocessing the historical time series data, removing outliers and filling in missing values, and standardizing the data. Then the preprocessed data is divided into training set and test set. Module details are in S202 in the flow of the above prediction method.
  • the target prediction model training module 703 is used to train the initial network model by using the historical time series data to obtain the target prediction model of the time series data. Module details are in S203 to S207 in the flow of the above prediction method.
  • the data prediction module 704 is used to use the target prediction model to predict the data of the time series data in the future time period to obtain a prediction result, and store and display the prediction result. Module details are in S208 in the flow of the above prediction method.
  • FIG. 13 is a second structural schematic diagram of a data prediction device provided by an embodiment of the present application.
  • the embodiment of the present application also provides a data prediction device 800 , including: a data acquisition unit 803 and a prediction unit 804 .
  • the data acquisition unit 803 is used to acquire hierarchical time series data;
  • the hierarchical time series data are multiple sets of data corresponding to the time series of each level, wherein the sum of the sub-level data of each level in each level is equal to that of the corresponding parent level data;
  • the prediction unit 804 is configured to use a preset data prediction model to predict hierarchical time series data, and determine the prediction results within a preset time period after multiple historical time periods; wherein,
  • the preset data prediction model is obtained by joint training based on the prediction errors of multiple sets of training data in the historical preset time period in the hierarchical time series data, and the errors between each level.
  • the data prediction device 800 is used to standardize multiple sets of data of hierarchical time series data, and divide the standardized multiple sets of data into training sets and test sets according to preset historical time periods; training The set includes: multiple sets of training data; the test set includes: multiple sets of test data; use the loss function of the initial prediction model to calculate the prediction error of the training set, and the error between each level, and based on the prediction error, and the error between each level.
  • the model parameters of the initial prediction model are iteratively adjusted until the training conditions are met, and the first prediction data set corresponding to the test set is obtained; the first prediction data set includes: the iterative process of each level of each historical time period corresponding to the test set Multiple prediction data; use multiple sets of test data to compare with the first prediction data set, and determine a preset data prediction model.
  • the data prediction device 800 is used to input multiple sets of training data into the initial prediction model to obtain the second prediction data set;
  • the second prediction data set includes: prediction data of various levels in multiple historical time periods; based on the first Two prediction data sets and multiple sets of training data, combined with the loss function to calculate the prediction error and the error between each level; use the prediction error and the error between each level to solve the gradient of the loss function, and obtain the model parameters in the iterative process, so as to be updated prediction model; using the updated prediction model, continue to train multiple sets of training data until the training conditions are met, and stop to obtain the final prediction model, thereby obtaining multiple prediction models in the iterative process; when using multiple prediction models, From each corresponding second prediction data set, the prediction data of each level in each historical time period corresponding to the test set is extracted, and then the first prediction data set in the iterative process is obtained.
  • the data prediction device 800 is used to calculate the prediction error based on the first prediction data in the second prediction data set and multiple sets of training data;
  • the first prediction data is a plurality of first prediction data in the second prediction data set.
  • the forecast data of each level in the time period; the multiple first time periods are the time periods before the preset historical time period in the multiple historical time periods; based on the second forecast data in the second forecast data set, calculate the time period between each level
  • the second forecast data is the forecast data of each level in the multiple second time periods in the second forecast data set;
  • the multiple second time periods are the time periods after the preset historical time period among the multiple historical time periods.
  • the data prediction device 800 is used to calculate the sum of the squares of the difference between the first prediction data in the same first time period and the training data of the corresponding level, and then obtain the first sum of each level in the same first time period , adding the multiple first sums corresponding to the multiple first time periods to obtain the prediction error.
  • the data prediction device 800 is used to calculate the sum of the squares of the difference between the forecast data of each parent level of each layer in the second forecast data in the same second time period and the sum of the forecast data of the corresponding sub-levels , adding multiple sums of squares in multiple second time periods to obtain the second sum; multiplying the multiple second sums with the hyperparameter of the harmonic error penalty term to obtain the error between levels.
  • the data prediction device 800 is used to compare multiple sets of test data with multiple prediction data in the first prediction data set, and determine multiple comparison errors corresponding to multiple prediction data; Determine the target comparison error within the preset error range from the comparison error; determine the target iteration number corresponding to the target prediction data corresponding to the target comparison error; determine the preset data prediction model corresponding to the target iteration number in multiple prediction models .
  • the multiple sets of training data include: multiple sets of first processed data; multiple sets of test data include: multiple sets of second processed data; the data prediction device 800 is used to update each Outliers in the hierarchy; use the average data corresponding to the hierarchy with blank data to fill in the blank data corresponding to each hierarchy in multiple sets of data, and then obtain multiple sets of processed data corresponding to the time series of each hierarchy; in multiple historical time periods Determine the preset historical time period, combine multiple sets of first processed data corresponding to multiple first time periods before the preset historical time period into a training set, and combine multiple second time periods after the preset historical time period The corresponding sets of second processed data are combined into a test set.
  • the data acquisition unit 803 in the data prediction device 800 is used to obtain multiple sets of logistics cargo volume data corresponding to multiple historical time periods; the prediction unit 804 in the data prediction device 800 is used to use the preset data prediction model Multiple sets of logistics cargo volume data are processed to obtain forecasted logistics cargo volume data for preset time periods after multiple historical time periods.
  • the hierarchical time series data is obtained through the data acquisition unit 803; the hierarchical time series data are multiple sets of data corresponding to the time series of each level, wherein the sum of the sub-level data of each level in each level is equal to Corresponding to the data of the parent level; then use the preset data prediction model to predict the hierarchical time series data through the prediction unit 804, and determine the prediction results in the preset time period after multiple historical time periods; wherein, the preset data The prediction model is based on the hierarchical time series data, the prediction errors of multiple sets of training data in the historical preset time period, and the errors between each level are jointly trained.
  • the preset data prediction model is based on the prediction error of multiple sets of training data in the historical time period and the error training between each level, not only the accuracy of the prediction error but also the difference between each level are taken into account during training. Error, so the pre-set data prediction model trained to predict the data is more accurate.
  • the above-mentioned data prediction method is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.
  • the computer software products are stored in a storage medium and include several instructions to make A data prediction device (which may be a personal computer, etc.) executes all or part of the methods described in the various embodiments of the present application.
  • the aforementioned storage medium includes: various media that can store program codes such as U disk, mobile hard disk, read-only memory (Read Only Memory, ROM), magnetic disk or optical disk.
  • embodiments of the present application are not limited to any specific combination of hardware and software.
  • an embodiment of the present application provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the steps in the above method are implemented.
  • the embodiment of the present application provides a data prediction device, including a memory 802 and a processor 801, the memory 802 stores a computer program that can be run on the processor 801, and the processor 801 implements when executing the program. steps in the method above.
  • FIG. 14 is a schematic diagram of a hardware entity of the data prediction device provided in the embodiment of the present application.
  • the hardware entity of the data prediction device 800 includes: a processor 801 and a memory 802, wherein;
  • the processor 801 generally controls the overall operation of the data prediction device 800 .
  • the memory 802 is configured to store instructions and applications executable by the processor 801, and can also cache data to be processed or processed by each module in the processor 801 and the data prediction device 800 (for example, image data, audio data, voice communication data) and video communication data), which can be implemented by flash memory (FLASH) or random access memory (Random Access Memory, RAM).
  • data prediction device 800 for example, image data, audio data, voice communication data
  • video communication data which can be implemented by flash memory (FLASH) or random access memory (Random Access Memory, RAM).
  • the disclosed devices and methods may be implemented in other ways.
  • the device embodiments described above are only illustrative.
  • the division of the units is only a logical function division.
  • the coupling, or direct coupling, or communication connection between the various components shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be in electrical, mechanical or other forms. of.
  • the units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed to multiple network units; Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
  • each functional unit in each embodiment of the present application can be integrated into one processing unit, or each unit can be used as a single unit, or two or more units can be integrated into one unit; the above-mentioned integration
  • the unit can be realized in the form of hardware or in the form of hardware plus software functional unit.
  • the above-mentioned integrated units of the present application are realized in the form of software function modules and sold or used as independent products, they can also be stored in a computer-readable storage medium.
  • the computer software products are stored in a storage medium and include several instructions to make A computer device (which may be a personal computer, a server, or a network device, etc.) executes all or part of the methods described in the various embodiments of the present application.
  • the aforementioned storage medium includes various media capable of storing program codes such as a removable storage device, ROM, magnetic disk or optical disk.
  • the server obtains hierarchical time series data; the hierarchical time series data is multiple sets of data corresponding to the time series of each level, wherein the sum of the sub-level data of each level in each level is equal to the data of the corresponding parent level ; Use the preset data forecasting model to predict the hierarchical time series data, and determine the forecasting results in the preset time period after multiple historical time periods; wherein, the preset data forecasting model is based on the hierarchical time series data , which is obtained by jointly training the prediction errors of multiple sets of training data within the historical preset time period, and the errors between each level. Since the preset data prediction model not only takes into account the accuracy of the prediction error, but also considers the errors between various levels during training, the preset data prediction model obtained by the server training is more accurate in predicting data.

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Artificial Intelligence (AREA)
  • Evolutionary Computation (AREA)
  • Evolutionary Biology (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The present application provides a data prediction method and apparatus, and a storage medium. The method comprises: acquiring hierarchical time series data, the hierarchical time series data being multiple data sets corresponding to various hierarchical time series, and the sum of data of sub-hierarchical levels of each hierarchical level being equal to data of a corresponding parent hierarchical level; and predicting the hierarchical time series data by using a preset data prediction model, and determining a prediction result within a preset time period after multiple historical time periods, the preset data prediction model being obtained by jointly performing training on the basis of prediction errors of multiple training data sets within a historical preset time period in the hierarchical time series data and errors between the hierarchical levels.

Description

数据预测方法、装置及存储介质Data prediction method, device and storage medium
相关申请的交叉引用Cross References to Related Applications
本申请基于申请号为202110943383.6、申请日为2021年08月17日的中国专利申请提出,并要求该中国专利申请的优先权,该中国专利申请的全部内容在此引入本申请作为参考。This application is based on a Chinese patent application with application number 202110943383.6 and a filing date of August 17, 2021, and claims the priority of this Chinese patent application. The entire content of this Chinese patent application is hereby incorporated by reference into this application.
技术领域technical field
本申请实施例涉及预测模型技术领域,涉及一种数据预测方法、装置及存储介质。The embodiments of the present application relate to the technical field of prediction models, and relate to a data prediction method, device, and storage medium.
背景技术Background technique
时间序列预测有广泛的应用领域,比如金融市场行情预测、物流货量预测等等。在很多领域实现自动化智能化的过程中,时间序列预测起着非常重要的作用。因此预测技术能力会最终对物品交易量、库存成本等产生重要影响。与此同时,大型物流仓库的物流量最高可达百万级,大规模时间序列对现代时序预测技术产生了新的挑战。Time series forecasting has a wide range of applications, such as financial market forecasting, logistics volume forecasting, and so on. In the process of realizing automation and intelligence in many fields, time series forecasting plays a very important role. Therefore, forecasting technical capabilities will ultimately have an important impact on item transaction volume, inventory costs, etc. At the same time, the logistics volume of large logistics warehouses can reach up to one million, and large-scale time series pose new challenges to modern time series forecasting technology.
相关技术中,时间序列预测通过使用单一层级的数据做预测,再通过拆分或者聚合的方式得到其他层级的预测结果,虽然使用起来简单方便,但也导致其在预测准确率上通常相对较低,主要的缺点有:首先,现有的预测方法均实质只使用了单一层级的预测结果,没有利用其它层级预测数据包含的信息,导致准确率损失;其次,将预测结果向上汇总或向下分解时也会额外引入预测误差。另外,由于使用不同的单一层级得到的结果不同,因此不仅在层级的选择上很依赖人工经验,同时也导致准确率损失。In related technologies, time series forecasting uses single-level data to make forecasts, and then obtains forecast results of other levels by splitting or aggregating. Although it is simple and convenient to use, it also leads to relatively low forecasting accuracy , the main disadvantages are: firstly, the existing forecasting methods essentially only use the forecasting results of a single level, and do not use the information contained in the forecasting data of other levels, resulting in the loss of accuracy; secondly, the forecasting results are aggregated upward or decomposed downward It also introduces additional prediction error. In addition, since the results obtained by using different single levels are different, it not only depends on manual experience in the selection of levels, but also leads to loss of accuracy.
发明内容Contents of the invention
本申请实施例提供的一种数据预测方法、装置及存储介质。A data prediction method, device, and storage medium provided in the embodiments of the present application.
本申请的技术方案是这样实现的:The technical scheme of the present application is realized like this:
本申请实施例提供了一种数据预测方法,包括:The embodiment of the present application provides a data prediction method, including:
获取分层时间序列数据;分层时间序列数据为各个层级时间序列对应的多组数据,其中,各个层级中的每层的子层级的数据之和等于对应父层级的数据;Obtain hierarchical time series data; hierarchical time series data are multiple sets of data corresponding to time series of each level, wherein the sum of the data of the sub-levels of each level in each level is equal to the data of the corresponding parent level;
利用预设数据预测模型,对分层时间序列数据进行预测,确定出多个历史时间段之后的预设时间段内的预测结果;其中,Use the preset data forecasting model to predict the hierarchical time series data, and determine the forecast results in the preset time period after multiple historical time periods; among them,
预设数据预测模型是基于分层时间序列数据中的,历史预设时间段内的多组训练数据的预测误差,以及各个层级之间误差共同进行训练得到的。The preset data prediction model is based on the hierarchical time series data, the prediction errors of multiple sets of training data in the historical preset time period, and the errors between each level are jointly trained.
上述方案中,利用预设数据预测模型,对分层时间序列数据进行预测,确定出多个历史时间段之后的预设时间段内的预测结果之前,获取分层时间序列数据之后,方法还包括:In the above scheme, using the preset data forecasting model to predict the hierarchical time series data, before determining the forecast results in the preset time period after multiple historical time periods, after obtaining the hierarchical time series data, the method also includes :
对分层时间序列数据的多组数据进行标准化处理,并将标准化处理后的多组数据按照预设历史时间段分为训练集和测试集;训练集包括:多组训练数据;测试集包括:多组测试数据;Standardize multiple sets of data of hierarchical time series data, and divide the standardized multiple sets of data into training set and test set according to the preset historical time period; the training set includes: multiple sets of training data; the test set includes: Multiple sets of test data;
利用初始预测模型的损失函数计算训练集的预测误差,以及各个层级之间误差,并依据预测误差,及各个层级之间误差对初始预测模型的模型参数进行迭代调整,直至满足训练条件时停止,得到对应测试集的第一预测数据集合;第一预测数据集合包括:对应测试集的各个历史时间段的各个层级的迭代过程中的多次预测数据;Use the loss function of the initial prediction model to calculate the prediction error of the training set and the error between each level, and iteratively adjust the model parameters of the initial prediction model according to the prediction error and the error between each level until the training conditions are met. Obtaining the first prediction data set corresponding to the test set; the first prediction data set includes: multiple prediction data in the iterative process of each level of each historical time period corresponding to the test set;
利用多组测试数据和第一预测数据集合进行比对,确定出预设数据预测模型。A preset data prediction model is determined by comparing multiple sets of test data with the first prediction data set.
上述方案中,利用初始预测模型的损失函数计算训练集的预测误差,以及各个层级之间误差,并依据预测误差,及各个层级之间误差对初始预测模型的模型参数进行迭代调整, 直至满足训练条件时停止,得到对应测试集的第一预测数据集合,包括:In the above scheme, use the loss function of the initial prediction model to calculate the prediction error of the training set and the error between each level, and iteratively adjust the model parameters of the initial prediction model according to the prediction error and the error between each level until it meets the training requirements. When the condition is stopped, the first prediction data set corresponding to the test set is obtained, including:
将多组训练数据输入初始预测模型,得到第二预测数据集合;第二预测数据集合包括:多个历史时间段的各个层级的预测数据;Inputting multiple sets of training data into the initial forecasting model to obtain a second forecasting data set; the second forecasting data set includes: forecasting data of various levels in multiple historical time periods;
基于第二预测数据集合和多组训练数据,结合损失函数计算预测误差和各个层级之间误差;Based on the second prediction data set and multiple sets of training data, the prediction error and the error between each level are calculated in combination with a loss function;
利用所述预测误差和所述各个层级之间误差对损失函数进行梯度求解,得到迭代过程中的模型参数,从而得到更新的预测模型;performing a gradient solution to the loss function by using the prediction error and the errors between the various levels to obtain model parameters in the iterative process, thereby obtaining an updated prediction model;
利用更新的预测模型,继续对多组训练数据进行训练,直至满足训练条件时停止,得到最终的预测模型,从而得到迭代过程中的多个预测模型;Using the updated prediction model, continue to train multiple sets of training data until the training conditions are met, and then obtain the final prediction model, thereby obtaining multiple prediction models in the iterative process;
在采用多个预测模型,得到对应的每个第二预测数据集合中,提取出对应测试集的各个历史时间段的各个层级的预测数据,进而得到迭代过程中的第一预测数据集合。In each of the corresponding second prediction data sets obtained by using multiple prediction models, the prediction data of each level of each historical time period corresponding to the test set is extracted, and then the first prediction data set in the iterative process is obtained.
上述方案中,基于第二预测数据集合和多组训练数据,结合损失函数计算预测误差和各个层级之间误差,包括:In the above scheme, based on the second prediction data set and multiple sets of training data, the prediction error and the error between each level are calculated in combination with the loss function, including:
基于第二预测数据集合中的第一预测数据,及多组训练数据,计算预测误差;第一预测数据为第二预测数据集合中多个第一时间段中的各个层级的预测数据;多个第一时间段为多个历史时间段中预设历史时间段之前的时间段;Based on the first prediction data in the second prediction data set and multiple sets of training data, the prediction error is calculated; the first prediction data is the prediction data of each level in multiple first time periods in the second prediction data set; multiple The first time period is a time period before a preset historical time period among the plurality of historical time periods;
基于第二预测数据集合中第二预测数据,计算各个层级之间误差;第二预测数据为第二预测数据集合中多个第二时间段中的各个层级的预测数据;多个第二时间段为多个历史时间段中预设历史时间段之后的时间段。Based on the second prediction data in the second prediction data set, calculate the error between each level; the second prediction data is the prediction data of each level in a plurality of second time periods in the second prediction data set; a plurality of second time periods The time period after the preset historical time period for multiple historical time periods.
上述方案中,基于第二预测数据集合中的第一预测数据,及多组训练数据,计算预测误差,包括:In the above scheme, the prediction error is calculated based on the first prediction data in the second prediction data set and multiple sets of training data, including:
计算同一第一时间段中第一预测数据,与对应层级的训练数据的差的平方和,进而得到同一第一时间段中各个层级的第一总和,将多个第一时间段对应的多个第一总和相加得到预测误差。Calculate the sum of the squares of the difference between the first prediction data in the same first time period and the training data of the corresponding level, and then obtain the first sum of each level in the same first time period, and combine the multiple first time periods corresponding to The first sums are added to obtain the prediction error.
上述方案中,基于第二预测数据集合中第二预测数据,计算各个层级之间误差,包括:In the above solution, based on the second prediction data in the second prediction data set, the calculation of the error between each level includes:
计算同一第二时间段中第二预测数据中的每层的各个父层级的预测数据,与对应的各个子层级的预测数据和之差的平方和,将多个第二时间段的多个平方和相加得到第二总和;Calculate the sum of the squares of the difference between the forecast data of each parent level in the second forecast data of each layer in the second forecast data in the same second time period, and the forecast data sum of the corresponding sub-levels, and combine multiple squares of multiple second time periods and sum to get the second sum;
将多个第二总和与调和误差惩罚项超参数相乘,得到各个层级之间误差。Multiple second sums are multiplied by the harmonic error penalty hyperparameter to get the error between layers.
上述方案中,利用多组测试数据和第一预测数据集合进行比对,确定出预设数据预测模型,包括:In the above scheme, multiple sets of test data are compared with the first prediction data set to determine a preset data prediction model, including:
将多组测试数据分别与第一预测数据集合中的多次预测数据进行比对,确定出多次预测数据对应的多次对比误差;Comparing the multiple sets of test data with the multiple forecast data in the first forecast data set respectively, and determining the multiple comparison errors corresponding to the multiple forecast data;
在多次对比误差中确定出在预设误差范围内的目标对比误差;Determining a target comparison error within a preset error range among multiple comparison errors;
确定出目标对比误差对应的目标次预测数据对应的目标迭代次;Determine the target iteration times corresponding to the target times forecast data corresponding to the target comparison error;
在多个预测模型中确定目标迭代次对应的预设数据预测模型。A preset data prediction model corresponding to the target iteration is determined among multiple prediction models.
上述方案中,多组训练数据包括:多组第一已处理数据;多组测试数据包括:多组第二已处理数据;In the above solution, multiple sets of training data include: multiple sets of first processed data; multiple sets of test data include: multiple sets of second processed data;
对分层时间序列数据的多组数据进行标准化处理,并将标准化处理后的多组数据按照预设历史时间段分为训练集和测试集,包括:Standardize multiple sets of data of hierarchical time series data, and divide the standardized multiple sets of data into training sets and test sets according to preset historical time periods, including:
利用各个层级的平均数据更新所述各个层级中的异常值;updating the outliers in each stratum with the average data for each stratum;
利用存在空白数据的层级对应的平均数据,填充多组数据中各个层级对应的空白数据,进而得到对应各个层级时间序列的多组已处理数据;Using the average data corresponding to the level with blank data, fill the blank data corresponding to each level in multiple sets of data, and then obtain multiple sets of processed data corresponding to the time series of each level;
在多个历史时间段中确定出预设历史时间段,将预设历史时间段之前的多个第一时间段对应的多组第一已处理数据组合为所述训练集,将预设历史时间段之后的多个第二时间段对应的多组第二已处理数据组合为所述测试集。A preset historical time period is determined in a plurality of historical time periods, and multiple groups of first processed data corresponding to a plurality of first time periods before the preset historical time period are combined into the training set, and the preset historical time period is Multiple groups of second processed data corresponding to multiple second time periods after the first time period are combined into the test set.
上述方案中,方法还包括:In the above scheme, the method also includes:
获取多个历史时间段对应的多组物流货量数据;Obtain multiple sets of logistics volume data corresponding to multiple historical time periods;
利用预设数据预测模型对多组物流货量数据进行处理,得到多个历史时间段之后的预设时间段的预测物流货量数据。A preset data forecasting model is used to process multiple sets of logistics cargo volume data to obtain predicted logistics cargo volume data for a preset time period after multiple historical time periods.
本申请实施例还提供了一种数据预测装置,包括:The embodiment of the present application also provides a data prediction device, including:
数据获取模块,被配置为获取分层时间序列数据;分层时间序列数据为各个层级时间序列对应的多组数据,其中,各个层级中的每层的子层级的数据之和等于对应父层级的数据;The data acquisition module is configured to obtain hierarchical time series data; the hierarchical time series data are multiple sets of data corresponding to the time series of each level, wherein the sum of the data of the sub-levels of each level in each level is equal to the data of the corresponding parent level data;
预测模块,被配置为利用预设数据预测模型,对分层时间序列数据进行预测,确定出多个历史时间段之后的预设时间段内的预测结果;其中,The prediction module is configured to use a preset data prediction model to predict hierarchical time series data, and determine the prediction results within a preset time period after multiple historical time periods; wherein,
预设数据预测模型是基于分层时间序列数据中的历史预设时间段内的多组训练数据的预测误差,以及各个层级之间误差共同进行训练得到的。The preset data prediction model is obtained by joint training based on the prediction errors of multiple sets of training data in the historical preset time period in the hierarchical time series data, and the errors between each level.
本申请实施例还提供了一种数据预测装置,包括存储器和处理器,存储器存储有可在处理器上运行的计算机程序,处理器执行程序时实现上述方法中的步骤。The embodiment of the present application also provides a data prediction device, including a memory and a processor, the memory stores a computer program that can run on the processor, and the processor implements the steps in the above method when executing the program.
本申请实施例还提供了一种计算机可读存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现上述方法中的步骤。The embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps in the above method are implemented.
附图说明Description of drawings
图1为本申请实施例提供的数据预测方法的一个可选的流程示意图;FIG. 1 is an optional schematic flow chart of the data prediction method provided by the embodiment of the present application;
图2为本申请实施例提供的数据预测方法的一个可选的效果示意图;FIG. 2 is a schematic diagram of an optional effect of the data prediction method provided by the embodiment of the present application;
图3为本申请实施例提供的数据预测方法的一个可选的效果示意图;FIG. 3 is a schematic diagram of an optional effect of the data prediction method provided by the embodiment of the present application;
图4为本申请实施例提供的数据预测方法的一个可选的流程示意图;FIG. 4 is an optional schematic flow chart of the data prediction method provided in the embodiment of the present application;
图5为本申请实施例提供的数据预测方法的一个可选的流程示意图;FIG. 5 is an optional schematic flow chart of the data prediction method provided by the embodiment of the present application;
图6为本申请实施例提供的数据预测方法的一个可选的流程示意图;FIG. 6 is an optional schematic flow chart of the data prediction method provided by the embodiment of the present application;
图7为本申请实施例提供的数据预测方法的一个可选的流程示意图;FIG. 7 is an optional schematic flow chart of the data prediction method provided by the embodiment of the present application;
图8为本申请实施例提供的数据预测方法的一个可选的流程示意图;FIG. 8 is an optional schematic flow chart of the data prediction method provided by the embodiment of the present application;
图9为本申请实施例提供的数据预测方法的一个可选的流程示意图;FIG. 9 is an optional schematic flow chart of the data prediction method provided by the embodiment of the present application;
图10为本申请实施例提供的物流货量预测装置的结构示意图;FIG. 10 is a schematic structural diagram of a logistics volume forecasting device provided in an embodiment of the present application;
图11为本申请实施例提供的数据预测方法的一个可选的流程示意图;FIG. 11 is an optional schematic flow chart of the data prediction method provided by the embodiment of the present application;
图12为本申请实施例提供的数据预测装置的结构示意图一;FIG. 12 is a first structural schematic diagram of a data prediction device provided by an embodiment of the present application;
图13为本申请实施例提供的数据预测装置的结构示意图二;FIG. 13 is a second structural schematic diagram of the data prediction device provided by the embodiment of the present application;
图14为本申请实施例提供的数据预测装置的一种硬件实体示意图。FIG. 14 is a schematic diagram of a hardware entity of a data prediction device provided by an embodiment of the present application.
具体实施方式Detailed ways
为了使本申请的目的、技术方案和优点更加清楚,下面结合附图和实施例对本申请的技术方案进一步详细阐述,所描述的实施例不应视为对本申请的限制,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其它实施例,都属于本申请保护的范围。In order to make the purpose, technical solution and advantages of the application more clear, the technical solution of the application will be further elaborated below in conjunction with the accompanying drawings and embodiments. The described embodiments should not be considered as limiting the application. All other embodiments obtained under the premise of no creative work belong to the scope of protection of this application.
在以下的描述中,涉及到“一些实施例”,其描述了所有可能实施例的子集,但是可以理解,“一些实施例”可以是所有可能实施例的相同子集或不同子集,并且可以在不冲突的情况下相互结合。In the following description, references to "some embodiments" describe a subset of all possible embodiments, but it is understood that "some embodiments" may be the same subset or a different subset of all possible embodiments, and Can be combined with each other without conflict.
如果申请文件中出现“第一/第二”的类似描述则增加以下的说明,在以下的描述中,所涉及的术语“第一\第二\第三”仅仅是区别类似的对象,不代表针对对象的特定排序,可以理解地,“第一\第二\第三”在允许的情况下可以互换特定的顺序或先后次序,以使这里描述的本申请实施例能够以除了在这里图示或描述的以外的顺序实施。If there is a similar description of "first/second" in the application documents, add the following explanation. In the following description, the terms "first\second\third" are only used to distinguish similar objects and do not mean Regarding the specific ordering of objects, it can be understood that "first\second\third" can be interchanged with specific order or sequence if allowed, so that the embodiment of the application described here can be used in addition to the performed in an order other than that shown or described.
除非另有定义,本文所使用的所有的技术和科学术语与属于本申请的技术领域的技术人员通常理解的含义相同。本文中所使用的术语只是为了描述本申请实施例的目的,不是旨在限制本申请。Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the technical field to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of the present application, and are not intended to limit the present application.
相关技术中,比如一家全国性的快消品生产企业需要同时预测某款产品在全国与各省的未来销量以便制定库存布局与备货计划。预测方案是分别对各省和全国的销量时间序列进行单时序预测,那么这些不同层级的预测结果往往不会自动满足一致性,即全国的销量预测与各省的销量预测的总和不相等,这种“不一致”的预测结果是无法用于各层级协同决策流程中的。In related technologies, for example, a national fast-moving consumer goods manufacturer needs to predict the future sales of a certain product in the whole country and provinces at the same time in order to formulate inventory layout and stocking plan. The forecasting scheme is to make a single time-series forecast for the sales time series of each province and the whole country, then the forecast results of these different levels often do not automatically meet the consistency, that is, the sales forecast of the whole country is not equal to the sum of the sales forecast of each province. "Inconsistent" prediction results cannot be used in the collaborative decision-making process at all levels.
目前主要的预测方法包括:“自上而下”(Top-Down)、“自下而上”(Bottom-Up)、“中间突破”(Middle-Out)、“最优调合”。顾名思义,“自上而下”是指先对最高层级的时间序列做预测,然后将预测结果根据固定比例拆分到低层级,“自下而上”是指先预测最细粒度的时间序列,然后将预测结果向上聚合。“中间突破”方法结合了自下而上和自上而下的方法。首先,选择“中间级别”并为该级别的所有序列生成预测。对于中间级别以上的系列,通过向上汇总“中间级别”的预测,使用自下而上的方法生成一致预测。对于“中间级别”以下的序列,通过向下分解“中间级别”的预测,使用自上而下的方法生成一致预测。“最优调和”方法是先得到全部层级的预测结果,然后通过最优线性加权调和的方式来对预测结果进行加工,然后得到最终结果。At present, the main forecasting methods include: "Top-Down", "Bottom-Up", "Middle-Out" and "Optimal Blending". As the name implies, "top-down" refers to forecasting the highest-level time series first, and then splitting the forecast results to lower levels according to a fixed ratio. "Bottom-up" refers to first predicting the most granular time series, and then The prediction results are aggregated upwards. The "break in the middle" approach combines bottom-up and top-down approaches. First, an "intermediate level" is selected and forecasts are generated for all series at that level. For series above the middle level, a bottom-up approach is used to generate consensus forecasts by aggregating forecasts from the "middle level" upwards. For series below the "intermediate level", a top-down approach is used to generate consensus forecasts by disaggregating the forecast for the "intermediate level" downwards. The "optimal reconciliation" method is to first obtain the prediction results of all levels, and then process the prediction results through the optimal linear weighted reconciliation method, and then obtain the final result.
“自上而下”、“自下而上”、“中间突破”三种方法是目前使用最多的方法,这些方法通过仅使用单一层级的数据做预测,再通过拆分或者聚合的方式得到其他层级的预测结果,虽然使用起来简单方便,但也导致其在预测准确率上通常相对较低,主要的缺点有:首先,这三种预测方法均实质只使用了单一层级的预测结果,没有利用其它层级预测数据包含的信息,导致准确率损失;其次,将预测结果向上汇总或向下分解时也会额外引入预测误差。另外,由于使用不同的单一层级得到的结果不同,因此不仅在层级的选择上很依赖人工经验,同时也导致准确率损失。The three methods of "top-down", "bottom-up", and "intermediate breakthrough" are currently the most used methods. These methods use only a single level of data to make predictions, and then obtain other data by splitting or aggregation. Although the hierarchical forecasting results are simple and convenient to use, they usually lead to relatively low forecasting accuracy. The main disadvantages are as follows: First, these three forecasting methods only use the single-level forecasting results, and do not use The information contained in the forecast data of other levels leads to the loss of accuracy; secondly, when the forecast results are aggregated up or decomposed down, additional forecast errors will be introduced. In addition, since the results obtained by using different single levels are different, it not only depends on manual experience in the selection of levels, but also leads to loss of accuracy.
为了解决上述的预测模型预测准确率较低的技术问题,本申请实施例还提供了一种数据预测方法,请参阅图1,为本申请实施例提供的数据预测方法的一个可选的流程示意图,将结合图1示出的步骤进行说明。In order to solve the above-mentioned technical problem of low prediction accuracy of the prediction model, the embodiment of the present application also provides a data prediction method, please refer to Figure 1, which is an optional schematic flow chart of the data prediction method provided by the embodiment of the present application , will be described in conjunction with the steps shown in FIG. 1 .
S101、获取分层时间序列数据;分层时间序列数据为各个层级时间序列对应的多组数据,其中,各个层级中的每层的子层级的数据之和等于对应父层级的数据。S101. Acquire hierarchical time series data; the hierarchical time series data are multiple sets of data corresponding to the time series of each level, wherein the sum of the data of the sub-levels of each level in each level is equal to the data of the corresponding parent level.
本申请实施例中,服务器获取分层时间序列数据。其中,分层时间序列数据为各个层级时间序列对应的多组数据。各个层级中的每层的子层级的数据之和等于对应父层级的数据。In this embodiment of the application, the server acquires hierarchical time series data. Among them, the hierarchical time series data are multiple sets of data corresponding to each hierarchical time series. The sum of the data of the sub-levels of each level in each level is equal to the data of the corresponding parent level.
本申请实施例中,服务器预先与各个层级对应的客户端建立通信连接。服务器通过与各个层级的客户端之间的通信连接,从客户端获取历史多个时间段对应的各个层级的多组数据。也就是服务器从各个层级的客户端获取到了各个层级时间序列对应的多组数据。In this embodiment of the present application, the server establishes communication connections with clients corresponding to each level in advance. The server obtains multiple sets of data of various levels corresponding to multiple historical time periods from the client through the communication connection with the clients of each level. That is, the server obtains multiple sets of data corresponding to the time series of each level from the clients of each level.
本申请实施例中,服务器在自身的数据库中获取预存的分层时间序列数据。In the embodiment of the present application, the server acquires the pre-stored hierarchical time series data in its own database.
其中,多组数据中的任意一组数据可以包括:任意一时间序列的各个层级对应的数据的组合。也就是多组数据中的任意一组数据可以包括:历史多个时间段中的任意一个时间段对应的各个层级的数据的组合。其中,一组数据中的一个数据可以为对应层级的销量数据、物流量数据、用户年龄数据中的任意一个。其中,物流量数据可以为对应的物流总件数、物流总重量和物流总体积中的一个。Wherein, any set of data among the multiple sets of data may include: a combination of data corresponding to each level of any time series. That is, any set of data among multiple sets of data may include: a combination of data at various levels corresponding to any one of multiple historical time periods. Wherein, one data in a group of data may be any one of sales data, logistics data, and user age data of a corresponding level. Wherein, the logistics flow data may be one of the corresponding total logistics pieces, total logistics weight and total logistics volume.
示例性的,时间序列可以为当前时刻之前的三个月分别对应的三个时间序列。时间序列还可以为当前时刻之前的三天分别对应的三个时间序列,本申请实施例中,对时间序列不做限定。Exemplarily, the time series may be three time series respectively corresponding to three months before the current moment. The time series may also be three time series respectively corresponding to the three days before the current moment, and in the embodiment of the present application, the time series are not limited.
本申请实施例中,子层级可以为市层级,父层级可以为该子层级对应的省层级。一个 省层级可以对应多个市层级。父层级还可以为一级代理,子层级可以为父层级对应的多个二级代理。一个一级代理可以对应多个二级代理。多个子层级的数据之和为对应父层级的数据。In this embodiment of the application, the sub-level may be the city level, and the parent level may be the provincial level corresponding to the sub-level. A provincial level can correspond to multiple city levels. The parent level can also be a first-level agent, and the sub-level can be multiple second-level agents corresponding to the parent level. One first-level agent can correspond to multiple second-level agents. The sum of the data of multiple sub-levels is the data of the corresponding parent level.
本申请实施例中,服务器首先采集待预测的分层时间序列数据。服务器在时刻1-T观测到的第i个时间序列取值记为y i=(y t i,…..,y T i) T,i=1,…..,n。其中,y i=(y t i,…..,y T i) T表征1-T个时间段各个层级的数据,1,…..,n为n个层级。 In the embodiment of the present application, the server first collects hierarchical time series data to be predicted. The value of the i-th time series observed by the server at time 1-T is recorded as y i =(y t i ,...,y T i ) T , i=1,...,n. Wherein, y i =(y t i , . . . , y T i ) T represents the data of each level in 1-T time periods, and 1, . . . , n are n levels.
其中,分层时间序列数据满足各个子层级的数据之和等于对应父层级的数据。结合图2,该层次结构满足y 1=y 2+y 3。其中y 1为y 2和y 3对应的父层级数据,y 2和y 3为y 1对应的子层级数据。 Among them, the hierarchical time series data satisfies that the sum of the data of each sub-level is equal to the data of the corresponding parent level. Referring to FIG. 2 , the hierarchical structure satisfies y 1 =y 2 +y 3 . Among them, y 1 is the parent level data corresponding to y 2 and y 3 , and y 2 and y 3 are the child level data corresponding to y 1 .
结合图3,分层时间序列数据的层次结构满足y 1=y 2+y 3,y 2=y 4+y 5,y 3=y 6+y 7。其中y 2为y 4和y 5对应的父层级数据,y 3为y 6和y 7对应的父层级数据。分层时间序列预测的任务是给定时间1,….,t 0的观测数据,预测全部时间序列在未来期t+h的取值
Figure PCTCN2022108936-appb-000001
其中,y是时间序列数据中的数据。当时间序列为天维度时,则为每天的货量。如7月1日~5日,y_北京市=(10,20,30,40,50),y_河北省=(30,40,50,60,10)。在分层时间序列研究与应用中,常用所示层次结构图形象表达该约束条件。此类约束是分层时序的基础特征,也是“分层”含义的体现,此类约束是统计范围内各变量满足的自然规律,如Y_全国=sum(Y_北京,Y_河北,…),Y_北京市=sum(Y_海淀,…,Y_西城)。
Referring to FIG. 3 , the hierarchical structure of hierarchical time series data satisfies y 1 =y 2 +y 3 , y 2 =y 4 +y 5 , and y 3 =y 6 +y 7 . Among them, y 2 is the parent level data corresponding to y 4 and y 5 , and y 3 is the parent level data corresponding to y 6 and y 7 . The task of hierarchical time series forecasting is to predict the value of all time series in the future period t+h given the observation data at time 1,...,t 0
Figure PCTCN2022108936-appb-000001
where y is the data in the time series data. When the time series is a day dimension, it is the daily volume. For example, from July 1st to 5th, y_Beijing = (10, 20, 30, 40, 50), y_Hebei Province = (30, 40, 50, 60, 10). In the research and application of hierarchical time series, the constraint condition is often expressed graphically by the hierarchical structure diagram shown. This type of constraint is the basic feature of hierarchical time series, and it is also the embodiment of the meaning of "layered". This type of constraint is the natural law satisfied by each variable within the statistical range, such as Y_National=sum(Y_Beijing,Y_Hebei,… ), Y_Beijing = sum(Y_Haidian, ..., Y_Xicheng).
S102、利用预设数据预测模型,对分层时间序列数据进行预测,确定出多个历史时间段之后的预设时间段内的预测结果;其中,预设数据预测模型是基于分层时间序列数据中的,历史预设时间段内的多组训练数据的预测误差,以及各个层级之间误差共同进行训练得到的。S102. Use the preset data prediction model to predict the hierarchical time series data, and determine the prediction results in the preset time period after multiple historical time periods; wherein, the preset data prediction model is based on the hierarchical time series data Among them, the prediction errors of multiple sets of training data in the historical preset time period, and the errors between the various levels are jointly trained.
本申请实施例中,服务器利用预设数据预测模型,对分层时间序列数据进行预测,确定出多个历史时间段之后的预设时间段内的预测结果;其中,预设数据预测模型是基于分层时间序列数据中的,历史预设时间段内的多组训练数据的预测误差,以及各个层级之间误差共同进行训练得到的。In the embodiment of the present application, the server uses the preset data prediction model to predict the hierarchical time series data, and determines the prediction results in the preset time period after multiple historical time periods; wherein, the preset data prediction model is based on In the hierarchical time series data, the prediction errors of multiple sets of training data in the historical preset time period, and the errors between the various levels are jointly trained.
本申请实施例中,服务器通过将多组数据分为训练集和测试集。服务器通过训练数据结合损失函数对初始预测模型进行迭代训练。服务器通过迭代训练得到了迭代多次对应的多个预测模型。服务器在将每次迭代的预测数据与对应的真实数据相比,得到每次迭代的预测误差。服务器确定误差最小的迭代次数对应的预测模型为预设数据预测模型。In the embodiment of the present application, the server divides multiple sets of data into a training set and a test set. The server iteratively trains the initial prediction model by combining the training data with the loss function. The server obtains multiple prediction models corresponding to multiple iterations through iterative training. The server compares the forecast data of each iteration with the corresponding real data to obtain the forecast error of each iteration. The server determines that the prediction model corresponding to the number of iterations with the smallest error is the preset data prediction model.
本申请实施例中,通过获取分层时间序列数据;分层时间序列数据为各个层级时间序列对应的多组数据,其中,各个层级中的每层的子层级的数据之和等于对应父层级的数据;利用预设数据预测模型,对分层时间序列数据进行预测,确定出多个历史时间段之后的预设时间段内的预测结果;其中,预设数据预测模型是基于分层时间序列数据中的,历史预设时间段内的多组训练数据的预测误差,以及各个层级之间误差共同进行训练得到的。由于预设数据预测模型是基于历史时间段内的多组训练数据的预测误差,及各个层级之间误差训练得到的,在训练时候不仅考虑到了预测误差的准确性,还考虑到了各个层级间的误差,所以训练得到的预设数据预测模型对数据的预测更加准确。In the embodiment of the present application, by obtaining hierarchical time series data; hierarchical time series data are multiple sets of data corresponding to time series of each level, wherein the sum of the sub-level data of each level in each level is equal to that of the corresponding parent level Data; use the preset data forecasting model to predict the hierarchical time series data, and determine the forecast results in the preset time period after multiple historical time periods; wherein, the preset data forecasting model is based on the hierarchical time series data Among them, the prediction errors of multiple sets of training data in the historical preset time period, and the errors between the various levels are jointly trained. Since the preset data prediction model is based on the prediction error of multiple sets of training data in the historical time period and the error training between each level, not only the accuracy of the prediction error but also the difference between each level are taken into account during training. Error, so the pre-set data prediction model trained to predict the data is more accurate.
在一些实施例中,参见图4,图4为本申请实施例提供的数据预测方法的一个可选的流程示意图,图1示出的S101之后还包括S103至S105实现,将结合各步骤进行说明。In some embodiments, refer to FIG. 4, which is an optional flowchart of the data prediction method provided by the embodiment of the present application. S101 shown in FIG. 1 also includes the implementation of S103 to S105, which will be described in conjunction with each step .
S103、对分层时间序列数据的多组数据进行标准化处理,并将标准化处理后的多组数据按照预设历史时间段分为训练集和测试集。S103. Standardize the multiple sets of data of the hierarchical time series data, and divide the standardized multiple sets of data into a training set and a test set according to preset historical time periods.
本申请实施例中,服务器对分层时间序列数据的多组数据进行标准化处理,并将标准化处理后的多组数据按照预设历史时间段分为训练集和测试集。其中,训练集包括:多组训练数据。测试集包括:多组测试数据。In the embodiment of the present application, the server standardizes multiple sets of data of hierarchical time series data, and divides the multiple sets of standardized data into a training set and a test set according to preset historical time periods. Wherein, the training set includes: multiple sets of training data. The test set includes: multiple sets of test data.
本申请实施例中,服务器可以删除多组数据中的多余数据,并用对应层级的平均数据填充,或者服务器可以对多组数据中各个层级的空白数据通过对应层级的平均数据进行填充,得到处理后的多组数据。由于多组数据对应多个历史时间段。服务器在多个历史时间段中确定出预设历史时间段,服务器将预设历史时间段之前对应的几组训练数据确定为训练集。服务器将预设历史时间段之后对应的几组测试数据确定为测试集。In the embodiment of this application, the server can delete redundant data in multiple sets of data and fill them with the average data of the corresponding levels, or the server can fill the blank data of each level in the multiple sets of data with the average data of the corresponding levels to obtain the processed multiple sets of data. Since multiple sets of data correspond to multiple historical time periods. The server determines a preset historical time period in multiple historical time periods, and the server determines several sets of training data corresponding to the preset historical time period as a training set. The server determines the corresponding sets of test data after the preset historical time period as the test set.
其中,训练集是用来训练初始预测模型的数据集合。测试集是用来确定预设数据预测模型的数据集合。Among them, the training set is the data set used to train the initial prediction model. The test set is the data set used to determine the preset data prediction model.
本申请实施例中,服务器对多组数据进行预处理,删除异常值与缺失值填充,并对数据进行标准化。然后对预处理后的数据取某时刻t 0,根据使用用途划分为训练集(t=1,….,t0)和测试集(t=t0+1,….,T)。 In the embodiment of the present application, the server preprocesses multiple sets of data, deletes outliers and fills in missing values, and standardizes the data. Then take a certain time t 0 for the preprocessed data, and divide it into a training set (t=1, . . . , t0) and a test set (t=t0+1, . . . , T) according to usage.
S104、利用初始预测模型的损失函数计算训练集的预测误差,以及各个层级之间误差,并依据预测误差,及各个层级之间误差对初始预测模型的模型参数进行迭代调整,直至满足训练条件时停止,得到对应测试集的第一预测数据集合。S104. Use the loss function of the initial prediction model to calculate the prediction error of the training set and the error between each level, and iteratively adjust the model parameters of the initial prediction model according to the prediction error and the error between each level until the training conditions are met. Stop, get the first prediction data set corresponding to the test set.
本申请实施例中,服务器利用初始预测模型的损失函数计算训练集的预测误差,以及各个层级之间误差,并依据预测误差,及各个层级之间误差对初始预测模型的模型参数进行迭代调整,直至满足训练条件时停止,得到对应测试集的第一预测数据集合。其中,第一预测数据集合包括:对应测试集的各个历史时间段的各个层级的迭代过程中的多次预测数据。In the embodiment of this application, the server uses the loss function of the initial prediction model to calculate the prediction error of the training set and the error between each level, and iteratively adjusts the model parameters of the initial prediction model according to the prediction error and the error between each level. Stop until the training condition is satisfied, and obtain the first prediction data set corresponding to the test set. Wherein, the first prediction data set includes: multiple prediction data in the iterative process of each level corresponding to each historical time period of the test set.
本申请实施例中,服务器将训练集内的多组训练数据输入初始预测模型。得到了第二预测数据集合。第二预测数据集合包括:多个历史时间段的各个层级的预测数据。服务器基于第二预测数据集合和多组训练数据,结合损失函数计算得到多组训练数据的预测误差和各个层级之间误差。服务器对损失函数进行求解得到本次训练的模型参数。服务器根据该模型参数对初始预测模型进行调整得到了新的预测模型。服务器通过该新的预测模型继续对多组训练数据进行训练,直至满足训练条件时停止,得到最终的预测模型。同时,也得到了迭代过程中对应测试集的第一预测数据集合。In the embodiment of the present application, the server inputs multiple sets of training data in the training set into the initial prediction model. A second forecast data set is obtained. The second forecast data set includes: forecast data of various levels in multiple historical time periods. Based on the second prediction data set and the multiple sets of training data, the server calculates the prediction errors of the multiple sets of training data and the errors between levels by combining the loss function. The server solves the loss function to obtain the model parameters for this training. The server adjusts the initial prediction model according to the model parameters to obtain a new prediction model. The server continues to train multiple sets of training data through the new prediction model, and stops when the training conditions are met, to obtain the final prediction model. At the same time, the first prediction data set corresponding to the test set in the iterative process is also obtained.
其中,满足训练条件可以为:达到预设的训练次数或者损失函数值收敛。Wherein, satisfying the training condition may be: reaching a preset number of training times or convergence of a loss function value.
S105、利用多组测试数据和第一预测数据集合进行比对,确定出预设数据预测模型。S105. Using multiple sets of test data to compare with the first prediction data set, determine a preset data prediction model.
本申请实施例中,服务器利用多组测试数据和第一预测数据集合进行对比,确定出预设数据预测模型。In the embodiment of the present application, the server compares multiple sets of test data with the first prediction data set to determine a preset data prediction model.
本申请实施例中,由于第一预测数据集合内包括:对应测试集的多次迭代的多次预测数据。服务器将多组测试数据中各个时间段中的各个层级的数据与每次预测数据中的对应数据进行对比,确定出各个层级的误差,再将各个层级的误差相加得到每次预测数据的误差。进而可以确定出多次预测数据对应的多次误差。服务器确定出误差最小的一次预测数据对应迭代调整后的预测模型为预设数据预测模型。In the embodiment of the present application, since the first prediction data set includes: multiple prediction data corresponding to multiple iterations of the test set. The server compares the data of each level in each time period in multiple sets of test data with the corresponding data in each forecast data to determine the error of each level, and then adds the errors of each level to obtain the error of each forecast data . Furthermore, multiple errors corresponding to multiple forecast data can be determined. The server determines that the predictive model corresponding to the iteratively adjusted primary predictive data with the smallest error is the preset data predictive model.
示例性的,服务器将多组测试数据中各个时间段中的各个层级的数据与某次预测数据中的对应数据相减,得到对应各个时间段各个层级的数据的误差。服务器将各个时间段各个层级的数据的误差相加,可以得到了对应该次预测数据的误差。Exemplarily, the server subtracts the data of each level in each time period in multiple sets of test data from the corresponding data in a certain forecast data to obtain the error of the data in each level corresponding to each time period. The server adds the errors of the data of each level in each time period to obtain the error corresponding to the forecast data.
本申请实施例中,服务器通过预测误差和各个层级之间误差迭代调整了预测模型,得到了迭代过程中的多个预测模型。服务器再根据多组测试数据和第一预测数据集合进行比对,确定出预设数据模型。由于预设数据预测模型是基于历史时间段内的多组训练数据的预测误差,及各个层级之间误差训练得到的,在训练时候不仅考虑到了预测误差的准确性,还考虑到了各个层级间的误差,所以训练得到的预设数据预测模型对数据的预测更加准确。In the embodiment of the present application, the server iteratively adjusts the prediction model through the prediction error and the error between each level, and obtains multiple prediction models in the iterative process. The server then compares the multiple sets of test data with the first prediction data set to determine a preset data model. Since the preset data prediction model is based on the prediction error of multiple sets of training data in the historical time period and the error training between each level, not only the accuracy of the prediction error but also the difference between each level are taken into account during training. Error, so the pre-set data prediction model trained to predict the data is more accurate.
在一些实施例中,参见图5,图5为本申请实施例提供的数据预测方法的一个可选的流程示意图,图4示出的S104还可以通过S106至S110实现,将结合各步骤进行说明。In some embodiments, refer to FIG. 5, which is an optional flowchart of the data prediction method provided by the embodiment of the present application. S104 shown in FIG. 4 can also be implemented through S106 to S110, which will be described in conjunction with each step .
S106、将多组训练数据输入初始预测模型,得到第二预测数据集合。S106. Input multiple sets of training data into the initial prediction model to obtain a second prediction data set.
本申请实施例中,服务器将多组训练数据输入初始预测模型,得到迭代过程中第一次迭代的第二预测数据集合。其中,第二预测数据集合包括:多个历史时间段的各个层级的预测数据。In the embodiment of the present application, the server inputs multiple sets of training data into the initial prediction model to obtain the second prediction data set of the first iteration in the iterative process. Wherein, the second forecast data set includes: forecast data of various levels in multiple historical time periods.
本申请实施例中,服务器将多组训练数据输入初始预测模型,得到第一次训练的第二预测数据集合。服务器根据第一次的第二预测数据集合,结合损失函数计算预测误差和各个层级间之误差。服务器根据预测误差和各个层级之间误差得到模型参数,调整初始预测模型,得到下一次更新的预测模型。服务器再次将多组训练数据输入该下一次更新的预测模型,进而执行上述过程,完成迭代。In the embodiment of the present application, the server inputs multiple sets of training data into the initial prediction model to obtain the second prediction data set for the first training. The server calculates the prediction error and the error between each level according to the first second prediction data set and the loss function. The server obtains the model parameters according to the prediction error and the error between each level, adjusts the initial prediction model, and obtains the next updated prediction model. The server again inputs multiple sets of training data into the prediction model to be updated next time, and then executes the above process to complete the iteration.
S107、基于第二预测数据集合和多组训练数据,结合损失函数计算预测误差和各个层级之间误差。S107. Based on the second prediction data set and multiple sets of training data, combine the loss function to calculate prediction errors and errors between levels.
本申请实施例中,服务器基于第二预测数据集合和多组训练数据,结合损失函数计算预测误差和各个层级之间误差。其中,损失函数为对应初始预测模型的函数。In the embodiment of the present application, the server calculates the prediction error and the error between each level based on the second prediction data set and multiple sets of training data in combination with a loss function. Among them, the loss function is the function corresponding to the initial prediction model.
本申请实施例中,服务器基于第二预测数据集合和多组训练数据,结合损失函数计算多个第一时间段的多组训练数据对应的预测误差。其中,多个第一时间段为多个历史时间段中预设历史时间段之前的时间段。预测误差表征预测数据和多组训练数据中对应数据之间的误差。In the embodiment of the present application, the server calculates prediction errors corresponding to multiple sets of training data in multiple first time periods based on the second prediction data set and multiple sets of training data in combination with a loss function. Wherein, the multiple first time periods are the time periods before the preset historical time period among the multiple historical time periods. The prediction error characterizes the error between the predicted data and the corresponding data in multiple sets of training data.
本申请实施例中,服务器基于第二预测数据集合,结合损失函数的计算多个第二时间段的第二预测数据集合内的各个层级之间的误差。其中,多个第二时间段为多个历史时间段中预设历史时间段之后的时间端。各个层级之间误差表征第二预测数据集合中的父层级的数据和对应子层级数据和的误差。In the embodiment of the present application, based on the second prediction data set, the server calculates errors between levels in the second prediction data set for multiple second time periods in combination with a loss function. Wherein, the multiple second time periods are time ends after the preset historical time period among the multiple historical time periods. The error between the various levels represents the error between the data of the parent level and the data of the corresponding child level in the second predicted data set.
S108、利用预测误差和各个层级之间误差对损失函数进行梯度求解,得到迭代过程中的模型参数,从而得到更新的预测模型。S108. Perform a gradient solution to the loss function by using the prediction error and the error between each level to obtain model parameters in the iterative process, thereby obtaining an updated prediction model.
本申请实施例中,服务器利用预测误差和各个层级之间误差对损失函数进行梯度求解,得到迭代过程中的模型参数,从而得到更新的预测模型。In the embodiment of the present application, the server uses the prediction error and the error between each level to solve the gradient of the loss function to obtain the model parameters in the iterative process, thereby obtaining an updated prediction model.
本申请实施例中,服务器在迭代的过程中,利用预测误差和各个层级之间误差对每次迭代后的损失函数梯度求解,得到了迭代过程中的每次迭代的模型参数。服务器通过每次的模型参数对本次的预测模型进行调整得到了更新的预测模型。In the embodiment of the present application, during the iterative process, the server uses the prediction error and the error between each level to solve the loss function gradient after each iteration, and obtains the model parameters of each iteration in the iterative process. The server adjusts the current forecasting model through each model parameter to obtain an updated forecasting model.
S109、利用更新的预测模型,继续对多组训练数据进行训练,直至满足训练条件时停止,得到最终的预测模型,从而得到迭代过程中的多个预测模型。S109. Using the updated prediction model, continue to train multiple sets of training data until the training conditions are met, and stop to obtain a final prediction model, thereby obtaining multiple prediction models in the iterative process.
本申请实施例中,服务器利用更新的预测模型,继续对多组训练数据进行训练,直至满足训练条件时停止,得到最终的预测模型,从而得到迭代过程中的多个预测模型。In the embodiment of the present application, the server continues to train multiple sets of training data by using the updated prediction model, and stops when the training conditions are met to obtain the final prediction model, thereby obtaining multiple prediction models in the iterative process.
在本申请实施例中,预测模型的网络结构将基于该预测误差和各个层级之间误差通过输出层,向中间层、输入层逐层反传,按梯度下降的方式修正各层的权值。当预测模型的网络结构各层的权值修正之后,进而得到了新的预测模型。新的预测模型的网络结构会继续对训练集进行训练,直到满足训练条件时停止,得到迭代过程中的多个预测模型。In the embodiment of this application, the network structure of the prediction model will be based on the prediction error and the error between each layer through the output layer, and then back-transmit layer by layer to the intermediate layer and input layer, and correct the weights of each layer in the way of gradient descent. When the weights of each layer of the network structure of the prediction model are corrected, a new prediction model is obtained. The network structure of the new prediction model will continue to train the training set until the training conditions are met and stop, and multiple prediction models in the iterative process will be obtained.
S110、在采用多个预测模型,得到对应的每个第二预测数据集合中,提取出对应测试集的各个历史时间段的各个层级的预测数据,进而得到迭代过程中的第一预测数据集合。S110. From each corresponding second prediction data set obtained by using multiple prediction models, extract the prediction data of each level corresponding to each historical time period of the test set, and then obtain the first prediction data set in the iterative process.
本申请实施例中,服务器在采用多个预测模型,得到对应的每个第二预测数据集合中,提取出对应测试集的各个历史时间段的各个层级的预测数据,进而得到迭代过程中的第一预测数据集合。In the embodiment of the present application, the server extracts the prediction data of each level in each historical time period of the corresponding test set from each of the corresponding second prediction data sets obtained by using multiple prediction models, and then obtains the first prediction data in the iterative process. A prediction data set.
本申请实施例中,服务器在每个第二预测数据集合中,提取出对应测试集的各个历史时间段的各个层级的预测数据,得到了对应每次迭代的一次预测数据集合。服务器将每次迭代的一次预测数据集合进行组合,形成了第一预测数据集合。In the embodiment of the present application, the server extracts the prediction data of each level corresponding to each historical time period of the test set from each second prediction data set, and obtains a prediction data set corresponding to each iteration. The server combines the prediction data set of each iteration to form the first prediction data set.
本申请实施例中,服务器将多组训练数据输入初始预测模型,得到了第二预测数据集合。服务器再通过第二预测数据集合计算得到预测误差和各个层级之间误差。服务器通过 预测误差和各个层级之间误差迭代调整了预测模型,得到了迭代过程中的多个预测模型。同时,服务器可以在迭代过程中的多个第二预测数据集合中提取出第一预测数据集合来进行比对。由于预设数据预测模型是基于历史时间段内的多组训练数据的预测误差,及各个层级之间误差训练得到的,在训练时候不仅考虑到了预测误差的准确性,还考虑到了各个层级间的误差,所以训练得到的预设数据预测模型对数据的预测更加准确。In the embodiment of the present application, the server inputs multiple sets of training data into the initial prediction model to obtain the second set of prediction data. The server then calculates the prediction error and the error between each level through the second prediction data set. The server iteratively adjusted the prediction model through the prediction error and the error between each level, and obtained multiple prediction models in the iterative process. At the same time, the server may extract the first prediction data set from the multiple second prediction data sets in the iterative process for comparison. Since the preset data prediction model is based on the prediction error of multiple sets of training data in the historical time period and the error training between each level, not only the accuracy of the prediction error but also the difference between each level are taken into account during training. Error, so the pre-set data prediction model trained to predict the data is more accurate.
在一些实施例中,参见图6,图6为本申请实施例提供的数据预测方法的一个可选的流程示意图,图5示出的S107还可以通过S111至S112实现,将结合各步骤进行说明。In some embodiments, refer to FIG. 6, which is an optional flowchart of the data prediction method provided by the embodiment of the present application. S107 shown in FIG. 5 can also be implemented through S111 to S112, which will be described in conjunction with each step .
S111、基于第二预测数据集合中的第一预测数据,及多组训练数据,计算预测误差。S111. Calculate a prediction error based on the first prediction data in the second prediction data set and multiple sets of training data.
本申请实施例中,服务器基于第二预测数据集合中的第一预测数据,及多组训练数据,计算预测误差。In the embodiment of the present application, the server calculates the prediction error based on the first prediction data in the second prediction data set and multiple sets of training data.
其中,第一预测数据为第二预测数据集合中多个第一时间段中的各个层级的预测数据。多个第一时间段为多个历史时间段中预设历史时间段之前的时间段。Wherein, the first forecast data is the forecast data of each level in the plurality of first time periods in the second forecast data set. The multiple first time periods are time periods before the preset historical time period among the multiple historical time periods.
S112、基于第二预测数据集合中第二预测数据,计算各个层级之间误差。S112. Calculate errors between levels based on the second prediction data in the second prediction data set.
本申请实施例中,服务器基于第二预测数据集合中的第二预测数据,计算各个层级之间误差。In this embodiment of the present application, the server calculates errors between levels based on the second prediction data in the second prediction data set.
其中,第二预测数据为第二预测数据集合中多个第二时间段中的各个层级的预测数据。多个第二时间段为多个历史时间段中预设历史时间段之后的时间段。Wherein, the second forecast data is the forecast data of each level in the multiple second time periods in the second forecast data set. The multiple second time periods are time periods after the preset historical time period among the multiple historical time periods.
本申请实施例中,服务器构建基于DeepAR的分层时间序列预测模型。DeepAR模型是一种基于循环神经网络的时序预测模型,可用于一般的时间序列预测,但是不能直接用于分层时间预测。因此对于分层时间序列预测任务,本申请设计的改进的用于分层时间序列预测的损失函数(1)为:In the embodiment of this application, the server builds a DeepAR-based hierarchical time series prediction model. The DeepAR model is a time series forecasting model based on a recurrent neural network, which can be used for general time series forecasting, but cannot be directly used for hierarchical time series forecasting. Therefore, for the hierarchical time series prediction task, the improved loss function (1) designed by the present application for hierarchical time series prediction is:
Figure PCTCN2022108936-appb-000002
Figure PCTCN2022108936-appb-000002
其中,
Figure PCTCN2022108936-appb-000003
为预测误差损失,
Figure PCTCN2022108936-appb-000004
为DeepAR模型的损失函数,不失一般性,这里假设
Figure PCTCN2022108936-appb-000005
是层级间调和误差损失,其中λ为调和误差惩罚项超参数。C为由分层结构推导出的约束条件的集合。
Figure PCTCN2022108936-appb-000006
是约束条件c中的“父节点”时间序列在t时刻的预测值,
Figure PCTCN2022108936-appb-000007
是约束条件c中的“叶子节点”时间序列在t时刻的预测值,J(c)为“叶子节点”的个数。如图3中所示结构的分层时间序列数据为例,该层次结构满足的约束是C={y 1=y 2+y 3,y 2=y 4+y 5,y 3=y 6+y 7}。
in,
Figure PCTCN2022108936-appb-000003
is the prediction error loss,
Figure PCTCN2022108936-appb-000004
is the loss function of the DeepAR model, without loss of generality, it is assumed here that
Figure PCTCN2022108936-appb-000005
is the inter-level harmonic error loss, where λ is the harmonic error penalty term hyperparameter. C is a set of constraints derived from the hierarchical structure.
Figure PCTCN2022108936-appb-000006
is the predicted value of the "parent node" time series in constraint c at time t,
Figure PCTCN2022108936-appb-000007
is the predicted value of the "leaf node" time series in constraint c at time t, and J(c) is the number of "leaf nodes". Taking the hierarchical time series data with the structure shown in Figure 3 as an example, the constraints satisfied by the hierarchical structure are C={y 1 =y 2 +y 3 , y 2 =y 4 +y 5 , y 3 =y 6 + y 7 }.
其中,
Figure PCTCN2022108936-appb-000008
为预测值。
Figure PCTCN2022108936-appb-000009
Figure PCTCN2022108936-appb-000010
对应的训练数据。n为各个层级的数量,t 0为多个第一时间段的数量。T为多个第二时间段的数量。
in,
Figure PCTCN2022108936-appb-000008
for the predicted value.
Figure PCTCN2022108936-appb-000009
for
Figure PCTCN2022108936-appb-000010
corresponding training data. n is the number of each level, and t0 is the number of multiple first time periods. T is the number of multiple second time periods.
在一些实施例中,参见图7,图7为本申请实施例提供的数据预测方法的一个可选的流程示意图,图6示出的S111至S112还可以通过S113至S115实现,将结合各步骤进行说明。In some embodiments, refer to FIG. 7, which is an optional schematic flowchart of the data prediction method provided by the embodiment of the present application. S111 to S112 shown in FIG. 6 can also be realized through S113 to S115, and each step will be combined Be explained.
S113、计算同一第一时间段中第一预测数据,与对应层级的训练数据的差的平方和,进而得到同一第一时间段中各个层级的第一总和,将多个第一时间段对应的多个第一总和相加得到预测误差。S113. Calculate the sum of the squares of the differences between the first prediction data in the same first time period and the training data of the corresponding level, and then obtain the first sum of each level in the same first time period, and combine the first sums corresponding to the multiple first time periods A plurality of first sums are added to obtain a prediction error.
本申请实施例中,服务器计算同一第一时间段中第一预测数据,与对应层级的训练数据的差的平方和,进而得到同一第一时间段中各个层级的第一总和。服务器将多个第一时间段对应的多个第一总和相加得到预测误差。In the embodiment of the present application, the server calculates the sum of squares of the differences between the first prediction data in the same first time period and the training data of the corresponding level, and then obtains the first sum of each level in the same first time period. The server adds the multiple first sums corresponding to the multiple first time periods to obtain the prediction error.
示例性的,多个第一时间段包括:两个第一时间段。各个层级包括:父层级(一级代理)和对应的两个子层级(两个二级代理)。服务器计算第一个第一时间段中父层级的数 据与对应预测数据的差的平方和,计算两个子层级的数据与对应预测数据的差的平方和,服务器再将父层级的对应的差的平方和与两个子层级对应的差的平方和相加,得到了对应第一个第一时间段的第一总和。同样的,服务器采用同样的方法计算出第二个时间段对应的第一总和。服务器将两个第一总和相加得到预测误差。Exemplarily, the multiple first time periods include: two first time periods. Each level includes: a parent level (a first-level agent) and two corresponding sub-levels (two second-level agents). The server calculates the sum of the squares of the difference between the data of the parent level and the corresponding forecast data in the first first time period, calculates the sum of the squares of the differences between the data of the two sub-levels and the corresponding forecast data, and then the server calculates the sum of the squares of the difference between the data of the parent level and the corresponding forecast data The sum of squares is added to the sum of squares of the differences corresponding to the two sublevels, resulting in a first sum corresponding to the first first time period. Similarly, the server uses the same method to calculate the first sum corresponding to the second time period. The server adds the two first sums to get the prediction error.
S114、计算同一第二时间段中第二预测数据中的每层的各个父层级的预测数据,与对应的各个子层级的预测数据和之差的平方和,将多个第二时间段的多个平方和相加得到第二总和。S114. Calculate the sum of the squares of the differences between the forecast data of each parent level in the second forecast data of each layer in the same second time period and the forecast data sums of the corresponding sub-levels, and combine the multiple second time periods The sums of squares are added to get the second sum.
本申请实施例中,服务器计算同一第二时间段中第二预测数据中的每层的各个父层级的预测数据,与对应的各个子层级的预测数据和之差的平方和,将多个第二时间段的多个平方和相加得到第二总和。In the embodiment of the present application, the server calculates the sum of the squares of the differences between the forecast data of each parent level of each layer in the second forecast data in the same second time period and the sum of the forecast data of the corresponding sub-levels, and combines the multiple The multiple sums of squares for the two time periods are added to obtain a second sum.
示例性的,多个第二时间段包括:两个第二时间段。各个层级包括:父层级(一级代理)和对应的两个子层级(两个二级代理)。服务器计算第一个第二时间段中父层级的数据与对应的各个子层级的预测数据和之差的平方和。同样的,服务器采用同样的方法计算出第二个时间段对应的平方和。服务器将两个平方和相加得到第二总和。Exemplarily, the multiple second time periods include: two second time periods. Each level includes: a parent level (a first-level agent) and two corresponding sub-levels (two second-level agents). The server calculates the sum of squares of differences between the data of the parent level and the sum of predicted data of corresponding sub-levels in the first second time period. Similarly, the server uses the same method to calculate the sum of squares corresponding to the second time period. The server adds the two sums of squares to get the second sum.
S115、将多个第二总和与调和误差惩罚项超参数相乘得到各层级间误差。S115. Multiply the multiple second sums by the hyperparameter of the harmonic error penalty term to obtain the inter-level error.
本申请实施例中,服务器将多个第二和与调和误差惩罚项超参数得到各个层级之间误差。In the embodiment of the present application, the server obtains the error between various levels by using multiple hyperparameters of the second sum and harmonic error penalty term.
其中,调和误差惩罚项超参数可以为任意正数。Among them, the harmonic error penalty hyperparameter can be any positive number.
相比于普通的时间序列预测来说,分层时间序列预测实质上是对最终预测结果添加了层级间的一致性约束条件,即:Compared with ordinary time series forecasting, hierarchical time series forecasting essentially adds consistency constraints between levels to the final forecasting results, namely:
Figure PCTCN2022108936-appb-000011
Figure PCTCN2022108936-appb-000011
Figure PCTCN2022108936-appb-000012
Figure PCTCN2022108936-appb-000012
而直接解决这样一个大规模优化问题是非常困难的,而通过将约束条件作为惩罚项添加到损失函数中后,我们可以通过随机梯度下降等方法对公式(1)进行求解,对任意给定的差惩罚项超参数λ,各层级间预测结果的不一致会随着训练过程中损失函数值的下降而下降。It is very difficult to directly solve such a large-scale optimization problem, and by adding constraints as penalty items to the loss function, we can solve formula (1) through methods such as stochastic gradient descent, for any given The difference penalty term hyperparameter λ, the inconsistency of prediction results between layers will decrease as the value of the loss function decreases during training.
对于分层时间序列预测来说,未来的各层级时序必然满足层级间的一致性。而通过添加调和误差损失的惩罚项,从参数迭代的过程来看,这相当于要求DeepAR的网络参数会在优化过程中兼顾预测偏差和层级结构偏差。从结果来看,这相当于在优化测试集误差的下界。以图2中的分层时序为例,根据柯西不等式:For hierarchical time series forecasting, the time series of each level in the future must meet the consistency between levels. By adding the penalty term of the harmonization error loss, from the perspective of the parameter iteration process, this is equivalent to requiring the network parameters of DeepAR to take into account both the prediction deviation and the hierarchical structure deviation during the optimization process. From the results, this is equivalent to a lower bound on the optimization test set error. Taking the hierarchical timing in Figure 2 as an example, according to Cauchy's inequality:
Figure PCTCN2022108936-appb-000013
Figure PCTCN2022108936-appb-000013
因此可以看出,损失函数中的层级结构偏差项实质上是一个预测误差的下界,直观理解就是说,虽然满足层级间一致性的预测结果并不一定保证是预测准确率最高的,但是既然未来的真实数据一定是满足一致性的,那么如果预测结果的层级间的误差很大,那么说明预测准确率也一定不会很高,因此在损失函数中加入该项能够有助于提高分层时间序列预测的预测性能。Therefore, it can be seen that the hierarchical structure deviation term in the loss function is essentially a lower bound of the prediction error. Intuitive understanding means that although the prediction results that satisfy the consistency between levels do not necessarily guarantee the highest prediction accuracy, since the future The real data must meet the consistency, then if the error between the levels of the prediction results is large, then the prediction accuracy rate must not be very high, so adding this item to the loss function can help improve the layering time Predictive Performance for Sequence Forecasting.
本申请实施例中,服务器通过第二预测数据集合中的第一预测数据和第二预测数据, 分别计算得到了预测误差,和各个层级之间误差。由于服务器在结合损失函数计算误差的过程中,考虑到了各个层级之间的误差,进而通过损失函数的模型参数调整后的预测模型对数据的预测更加准确。In the embodiment of the present application, the server calculates the prediction error and the error between levels respectively by using the first prediction data and the second prediction data in the second prediction data set. Since the server considers the error between each level in the process of calculating the error in combination with the loss function, the prediction model adjusted by the model parameters of the loss function is more accurate in predicting the data.
在一些实施例中,参见图8,图8为本申请实施例提供的数据预测方法的一个可选的流程示意图,图3示出的S103可以通过S116至S118实现,将结合各步骤进行说明。In some embodiments, refer to FIG. 8 , which is an optional flowchart of the data prediction method provided by the embodiment of the present application. S103 shown in FIG. 3 can be implemented through S116 to S118 , which will be described in conjunction with each step.
S116、利用各个层级的平均数据更新各个层级中的异常值。S116. Utilize the average data of each level to update the abnormal value in each level.
本申请实施例中,服务器利用各个层级的平均数据更新各个层级中的异常值。In the embodiment of the present application, the server uses the average data of each level to update the abnormal value in each level.
其中,平均数据为该异常值对应层级的多个历史时间段的多个该层级的数据的平均值。Wherein, the average data is the average value of the data of multiple levels in multiple historical time periods of the level corresponding to the abnormal value.
S117、利用存在空白数据的层级对应的平均数据,填充多组数据中各个层级对应的空白数据,进而得到对应各个层级时间序列的多组已处理数据。S117. Using the average data corresponding to the levels with blank data, fill the blank data corresponding to each level in the multiple sets of data, and then obtain multiple sets of processed data corresponding to the time series of each level.
本申请实施例中,服务器利用存在空白数据的层级对应的平均数据,填充多组数据中各个层级对应的空白数据,进而得到对应各个层级时间序列的多组已处理数据。In the embodiment of the present application, the server uses the average data corresponding to the levels with blank data to fill the blank data corresponding to each level in multiple sets of data, and then obtain multiple sets of processed data corresponding to the time series of each level.
S118、在多个历史时间段中确定出预设历史时间段,将预设历史时间段之前的多个第一时间段对应的多组第一已处理数据组合为训练集,将预设历史时间段之后的多个第二时间段对应的多组第二已处理数据组合为测试集。S118. Determine a preset historical time period in a plurality of historical time periods, combine multiple sets of first processed data corresponding to a plurality of first time periods before the preset historical time period into a training set, and combine the preset historical time period Multiple groups of second processed data corresponding to multiple second time periods after the period are combined into a test set.
本申请实施例中,服务器在多个历史时间段中确定出预设历史时间段,将预设历史时间段之前的多个第一时间段对应的多组第一已处理数据组合为训练集,将预设历史时间段之后的多个第二时间段对应的多组第二已处理数据组合为测试集。In the embodiment of the present application, the server determines a preset historical time period in a plurality of historical time periods, and combines multiple sets of first processed data corresponding to a plurality of first time periods before the preset historical time period into a training set, Multiple groups of second processed data corresponding to multiple second time periods after the preset historical time period are combined into a test set.
示例性的,多个历史时间段可以包括:1月至12月对应的12个时间段。服务器可以确定9月为预设历史时间段。在服务器确定9月为预设历史时间段的情况下,多个第一时间段为1-8月对应的8个时间段,多个第二时间段还可以为10-12月对应的3个时间段。Exemplarily, the multiple historical time periods may include: 12 time periods corresponding to January to December. The server may determine September as the preset historical time period. When the server determines that September is the preset historical time period, the multiple first time periods are 8 time periods corresponding to January-August, and the multiple second time periods can also be 3 corresponding to October-December period.
本申请实施例中,服务器对多组数据进行标准化处理,删除了异常值和填充了空白数据,进而使得多组数据的数据结构更加完善,有利于模型训练。In the embodiment of the present application, the server standardizes multiple sets of data, deletes outliers and fills in blank data, thereby making the data structure of multiple sets of data more complete, which is beneficial to model training.
在一些实施例中,参见图8,图8为本申请实施例提供的数据预测方法的一个可选的流程示意图,图3示出的S105可以通过S119至S122实现,将结合各步骤进行说明。In some embodiments, refer to FIG. 8 , which is an optional flowchart of the data prediction method provided by the embodiment of the present application. S105 shown in FIG. 3 can be implemented through S119 to S122 , which will be described in conjunction with each step.
S119、将多组测试数据分别与第一预测数据集合中的多次预测数据进行比对,确定出多次预测数据对应的多次对比误差。S119. Comparing multiple sets of test data with multiple prediction data in the first prediction data set respectively, and determining multiple comparison errors corresponding to multiple prediction data.
本申请实施例中,服务器将多组测试数据分别与第一预测数据集合中的多次预测数据进行比对,确定出多次预测数据对应的多次对比误差。每次预测数据是每次迭代训练过程中得到的所述各个历史时间段的所述各个层级的预测数据。In the embodiment of the present application, the server compares multiple sets of test data with multiple prediction data in the first prediction data set, and determines multiple comparison errors corresponding to the multiple prediction data. Each prediction data is the prediction data of each level of each historical time period obtained in each iteration training process.
本申请实施例中,服务器将多组测试数据中每个时间段的各个层级的测试数据分别与第一预测数据集合某一次预测数据中对应的预测数据进行比对。服务器确定出每个时间段各个层级的测试数据对应的误差。服务器将每个时间段各个层级的测试数据对应的误差相加,得到每时间段对应的误差,也就是得到了每组测试数据的误差。服务器再将每组测试数据对应的误差相加,得到了对应该次预测数据的误差。进而,可以得到多次预测数据的多次对比误差。In the embodiment of the present application, the server compares the test data of each level in each time period in multiple sets of test data with the corresponding forecast data in a certain forecast data set of the first forecast data set. The server determines the errors corresponding to the test data of each level in each time period. The server adds the errors corresponding to the test data of each level in each time period to obtain the error corresponding to each time period, that is, the error of each set of test data is obtained. The server then adds the errors corresponding to each set of test data to obtain the error corresponding to the predicted data. Furthermore, multiple comparison errors of multiple prediction data can be obtained.
S120、在多次对比误差中确定出在预设误差范围内的目标对比误差。S120. Determine a target comparison error within a preset error range from the multiple comparison errors.
本申请实施例中,服务器在多次对比误差中确定出在预设误差范围内的目标对比误差。In the embodiment of the present application, the server determines a target comparison error within a preset error range from the multiple comparison errors.
S121、确定出目标对比误差对应的目标次预测数据对应的目标迭代次。S121. Determine the target iteration number corresponding to the target number of prediction data corresponding to the target comparison error.
本申请实施例中,服务器确定出目标对比误差对应的目标次预测数据对应的目标迭代次。In the embodiment of the present application, the server determines the target iteration number corresponding to the target number of prediction data corresponding to the target comparison error.
S122、在多个预测模型中确定目标迭代次对应的预设数据预测模型。S122. Determine a preset data prediction model corresponding to the target iteration number among multiple prediction models.
本申请实施例中,由于迭代过程中形成了多个预测模型。服务器在多个预测模型中确定出目标迭代次对应形成的预设数据预测模型。In the embodiment of the present application, multiple prediction models are formed in the iterative process. The server determines a preset data prediction model corresponding to the target iteration number among multiple prediction models.
本申请实施例中,由于在迭代过程中形成了多个预测模型,服务器确定出与多组测试 数据误差最小的目标迭代次对应的预设数据预测模型,又由于预设数据预测模型对测试集的预测精度较高,进而通过预设数据预测模型对分层时间序列数据进行处理,可以得到预测精度较高的预测结果。In the embodiment of the present application, due to the formation of multiple prediction models in the iterative process, the server determines the preset data prediction model corresponding to the target iteration number with the smallest error of multiple sets of test data, and because the preset data prediction model does not affect the test set The prediction accuracy is high, and then the hierarchical time series data can be processed through the preset data prediction model, and the prediction result with high prediction accuracy can be obtained.
在一些实施例中,参见图9,图9为本申请实施例提供的数据预测方法的一个可选的流程示意图,将结合各步骤进行说明。In some embodiments, refer to FIG. 9 . FIG. 9 is an optional schematic flowchart of the data prediction method provided in the embodiment of the present application, which will be described in combination with various steps.
S123、获取多个历史时间段对应的多组物流货量数据。S123. Obtain multiple sets of logistics cargo volume data corresponding to multiple historical time periods.
本申请实施例中,服务器获取多个历史时间段对应的多组物流货量数据。In the embodiment of the present application, the server acquires multiple sets of logistics cargo volume data corresponding to multiple historical time periods.
其中,多组物流货量数据包括:全国、各区域、各省的发货量数据与层级关系。Among them, multiple sets of logistics cargo volume data include: shipment volume data and hierarchical relationships of the whole country, each region, and each province.
S124、利用预设数据预测模型对多组物流货量数据进行处理,得到多个历史时间段之后的预设时间段的预测物流货量数据。S124. Using a preset data prediction model to process multiple sets of logistics cargo volume data to obtain predicted logistics cargo volume data for a preset time period after multiple historical time periods.
本申请实施例中,服务器利用预设数据预测模型对多组物流货量数据进行处理,得到多个历史时间段之后的预设时间段的预测物流货量数据。In the embodiment of the present application, the server uses a preset data prediction model to process multiple sets of logistics cargo volume data to obtain predicted logistics cargo volume data for preset time periods after multiple historical time periods.
本申请实施例中,服务器利用预设数据预测模型对多组物流货量数据进行处理,由于预设数据预测模型是基于历史预设时间段内的多组训练数据的预测误差,以及各个层级之间误差共同进行训练得到的。进而通过该预设数据预测模型对多组物流货量数据进行预测,可以得到精度较高的预测结果。In the embodiment of this application, the server uses the preset data prediction model to process multiple sets of logistics cargo data. Since the preset data prediction model is based on the prediction errors of multiple sets of training data in the historical preset time period, and the The error between them is obtained by training together. Furthermore, by using the preset data prediction model to predict multiple sets of logistics cargo volume data, a prediction result with high accuracy can be obtained.
本申请实施例还提供了一种物流货量预测装置600,用于执行图9中提供的数据预测方法,请参阅,图10为本申请实施例提供的物流货量预测装置的结构示意图。The embodiment of the present application also provides a logistics cargo volume forecasting device 600 for implementing the data forecasting method provided in FIG. 9 . Please refer to FIG. 10 , which is a schematic structural diagram of the logistics cargo volume forecasting device provided in the embodiment of the present application.
本申请实施例提供了一种物流货量预测装置600,包括:数据获取模块601、数据预处理模块602、目标预测模型训练模块603和数据预测模型604。The embodiment of the present application provides a logistics volume forecasting device 600 , including: a data acquisition module 601 , a data preprocessing module 602 , a target prediction model training module 603 and a data prediction model 604 .
数据获取模块601,用于获取物流货量历史时间序列数据与时序间的层级关系。如全国、各区域、各省的发货量数据与层级关系。数据获取模块601用于执行S123。The data acquisition module 601 is used to acquire the hierarchical relationship between the historical time series data of logistics cargo volume and time series. For example, the shipment data and hierarchical relationship of the whole country, each region, and each province. The data acquisition module 601 is used to execute S123.
数据预处理模块602,用于对数据进行预处理,剔除异常值与缺失值填充,并对数据进行标准化。然后对预处理后的数据划分为训练集和测试集。The data preprocessing module 602 is used for preprocessing the data, removing outliers and filling missing values, and standardizing the data. Then the preprocessed data is divided into training set and test set.
目标预测模型训练模块603,用于利用历史时序数据对初始网络模型进行训练,得到时序数据的目标预测模型。The target prediction model training module 603 is used to train the initial network model by using the historical time series data to obtain the target prediction model of the time series data.
数据预测模块604,用于利用目标预测模型对时序数据在未来时间段的数据进行预测得到预测结果,并对所述预测结果进行存储、展示。The data prediction module 604 is configured to use the target prediction model to predict the data of the time series data in the future time period to obtain a prediction result, and store and display the prediction result.
在一些实施例中,参见图11,图11为本申请实施例提供的数据预测方法的一个可选的流程示意图,将结合各步骤进行说明。In some embodiments, referring to FIG. 11 , FIG. 11 is an optional schematic flowchart of the data prediction method provided in the embodiment of the present application, which will be described in combination with each step.
S201、采集待预测的分层时间序列数据。S201. Collect hierarchical time series data to be predicted.
示例性的,结合图12,数据预测装置700中的数据获取模块701,用于获取历史时间序列数据与时序间的层级关系。Exemplarily, with reference to FIG. 12 , the data acquisition module 701 in the data prediction device 700 is used to acquire the hierarchical relationship between historical time series data and time series.
S202、数据预处理,剔除异常值与缺失值填充;数据切分,划分训练集与测试集。S202. Data preprocessing, removing outliers and filling in missing values; data segmentation, dividing training set and test set.
示例性的,数据预测装置700中的数据预处理模块702,用于对历史时间序列数据进行预处理,剔除异常值与缺失值填充,并对数据进行标准化。然后对预处理后的数据划分为训练集和测试集。Exemplarily, the data preprocessing module 702 in the data forecasting device 700 is used to preprocess the historical time series data, remove outliers and fill in missing values, and standardize the data. Then the preprocessed data is divided into training set and test set.
S203、构建DeepAR时间序列预测模型。S203. Construct a DeepAR time series prediction model.
S204、训练集输入。S204, training set input.
S205、设定分层损失项超参数。S205. Setting hyperparameters of layered loss items.
S206、采用学习率自适应的Adam优化算法更新DeepAR模型参数。S206. Update the parameters of the DeepAR model by using an adaptive learning rate Adam optimization algorithm.
S207、训练是否达到预设训练次数。S207. Whether the training reaches the preset number of times of training.
示例性的,数据预测装置700中的目标预测模型训练模块703,用于利用历史时序数据对初始网络模型进行训练,得到时序数据的目标预测模型。也就是最终模型。Exemplarily, the target prediction model training module 703 in the data prediction device 700 is configured to use historical time series data to train an initial network model to obtain a target prediction model for time series data. That is the final model.
S208、取最终模型输出未来期预测结果。S208, taking the final model and outputting a prediction result for the future period.
示例性的,数据预测装置700中的数据预测模块704,用于利用目标预测模型(最终模型)对时序数据在未来时间段的数据进行预测得到预测结果,并对所述预测结果进行存储、展示。Exemplarily, the data prediction module 704 in the data prediction device 700 is used to use the target prediction model (final model) to predict the data of the time series data in the future time period to obtain the prediction results, and store and display the prediction results .
由于DeepAR时间序列预测模型是基于历史时间段内分层时间序列数据中的多组训练数据的预测误差,及各个层级之间误差构建的,在DeepAR时间序列预测模型训练时候不仅考虑到了预测误差的准确性,还考虑到了各个层级间的误差,所以训练得到的最终模型对数据的预测更加准确。Since the DeepAR time series prediction model is constructed based on the prediction errors of multiple sets of training data in the hierarchical time series data in the historical time period, and the errors between each level, not only the prediction error is taken into account when training the DeepAR time series prediction model Accuracy also takes into account the errors between the various levels, so the final model trained is more accurate in predicting the data.
示例性的,本申请实施例还提供了一种数据预测装置700,用于执行图11中提供的数据预测方法,请参阅,图12为本申请实施例提供的数据预测装置的结构示意图一。Exemplarily, the embodiment of the present application further provides a data prediction device 700 for executing the data prediction method provided in FIG. 11 . Please refer to FIG. 12 , which is a first structural diagram of the data prediction device provided in the embodiment of the present application.
本申请实施例提供了一种数据预测装置700,包括:数据获取模块701、数据预处理模块702、目标预测模型训练模块703和数据预测模型704。The embodiment of the present application provides a data prediction device 700 , including: a data acquisition module 701 , a data preprocessing module 702 , a target prediction model training module 703 and a data prediction model 704 .
数据获取模块701,用于获取历史时间序列数据与时序间的层级关系。The data acquisition module 701 is used to acquire the hierarchical relationship between historical time series data and time series.
数据预处理模块702,用于对历史时间序列数据进行预处理,剔除异常值与缺失值填充,并对数据进行标准化。然后对预处理后的数据划分为训练集和测试集。模块细节在上述预测方法流程中的S202中。The data preprocessing module 702 is used for preprocessing the historical time series data, removing outliers and filling in missing values, and standardizing the data. Then the preprocessed data is divided into training set and test set. Module details are in S202 in the flow of the above prediction method.
目标预测模型训练模块703,用于利用历史时序数据对初始网络模型进行训练,得到时序数据的目标预测模型。模块细节在上述预测方法流程中的S203至S207。The target prediction model training module 703 is used to train the initial network model by using the historical time series data to obtain the target prediction model of the time series data. Module details are in S203 to S207 in the flow of the above prediction method.
数据预测模块704,用于利用目标预测模型对时序数据在未来时间段的数据进行预测得到预测结果,并对所述预测结果进行存储、展示。模块细节在上述预测方法流程中的S208。The data prediction module 704 is used to use the target prediction model to predict the data of the time series data in the future time period to obtain a prediction result, and store and display the prediction result. Module details are in S208 in the flow of the above prediction method.
请参阅,图13为本申请实施例提供的数据预测装置的结构示意图二。Please refer to FIG. 13 , which is a second structural schematic diagram of a data prediction device provided by an embodiment of the present application.
本申请实施例还提供了一种数据预测装置800,包括:数据获取单元803和预测单元804。The embodiment of the present application also provides a data prediction device 800 , including: a data acquisition unit 803 and a prediction unit 804 .
数据获取单元803,用于获取分层时间序列数据;分层时间序列数据为各个层级时间序列对应的多组数据,其中,各个层级中的每层的子层级的数据之和等于对应父层级的数据;The data acquisition unit 803 is used to acquire hierarchical time series data; the hierarchical time series data are multiple sets of data corresponding to the time series of each level, wherein the sum of the sub-level data of each level in each level is equal to that of the corresponding parent level data;
预测单元804,用于利用预设数据预测模型,对分层时间序列数据进行预测,确定出多个历史时间段之后的预设时间段内的预测结果;其中,The prediction unit 804 is configured to use a preset data prediction model to predict hierarchical time series data, and determine the prediction results within a preset time period after multiple historical time periods; wherein,
预设数据预测模型是基于分层时间序列数据中的历史预设时间段内的多组训练数据的预测误差,以及各个层级之间误差共同进行训练得到的。The preset data prediction model is obtained by joint training based on the prediction errors of multiple sets of training data in the historical preset time period in the hierarchical time series data, and the errors between each level.
本申请实施例中,数据预测装置800用于对分层时间序列数据的多组数据进行标准化处理,并将标准化处理后的多组数据按照预设历史时间段分为训练集和测试集;训练集包括:多组训练数据;测试集包括:多组测试数据;利用初始预测模型的损失函数计算训练集的预测误差,以及各个层级之间误差,并依据预测误差,及各个层级之间误差对初始预测模型的模型参数进行迭代调整,直至满足训练条件时停止,得到对应测试集的第一预测数据集合;第一预测数据集合包括:对应测试集的各个历史时间段的各个层级的迭代过程中的多次预测数据;利用多组测试数据和第一预测数据集合进行比对,确定出预设数据预测模型。In the embodiment of the present application, the data prediction device 800 is used to standardize multiple sets of data of hierarchical time series data, and divide the standardized multiple sets of data into training sets and test sets according to preset historical time periods; training The set includes: multiple sets of training data; the test set includes: multiple sets of test data; use the loss function of the initial prediction model to calculate the prediction error of the training set, and the error between each level, and based on the prediction error, and the error between each level. The model parameters of the initial prediction model are iteratively adjusted until the training conditions are met, and the first prediction data set corresponding to the test set is obtained; the first prediction data set includes: the iterative process of each level of each historical time period corresponding to the test set Multiple prediction data; use multiple sets of test data to compare with the first prediction data set, and determine a preset data prediction model.
本申请实施例中,数据预测装置800用于将多组训练数据输入初始预测模型,得到第二预测数据集合;第二预测数据集合包括:多个历史时间段的各个层级的预测数据;基于第二预测数据集合和多组训练数据,结合损失函数计算预测误差和各个层级之间误差;利用预测误差和各个层级之间误差对损失函数进行梯度求解,得到迭代过程中的模型参数,从而得到更新的预测模型;利用更新的预测模型,继续对多组训练数据进行训练,直至满足训练条件时停止,得到最终的预测模型,从而得到迭代过程中的多个预测模型;在采用多个预测模型,得到对应的每个第二预测数据集合中,提取出对应测试集的各个历史时间段的各个层级的预测数据,进而得到迭代过程中的第一预测数据集合。In the embodiment of the present application, the data prediction device 800 is used to input multiple sets of training data into the initial prediction model to obtain the second prediction data set; the second prediction data set includes: prediction data of various levels in multiple historical time periods; based on the first Two prediction data sets and multiple sets of training data, combined with the loss function to calculate the prediction error and the error between each level; use the prediction error and the error between each level to solve the gradient of the loss function, and obtain the model parameters in the iterative process, so as to be updated prediction model; using the updated prediction model, continue to train multiple sets of training data until the training conditions are met, and stop to obtain the final prediction model, thereby obtaining multiple prediction models in the iterative process; when using multiple prediction models, From each corresponding second prediction data set, the prediction data of each level in each historical time period corresponding to the test set is extracted, and then the first prediction data set in the iterative process is obtained.
本申请实施例中,数据预测装置800用于基于第二预测数据集合中的第一预测数据,及多组训练数据,计算预测误差;第一预测数据为第二预测数据集合中多个第一时间段中的各个层级的预测数据;多个第一时间段为多个历史时间段中预设历史时间段之前的时间段;基于第二预测数据集合中第二预测数据,计算各个层级之间误差;第二预测数据为第二预测数据集合中多个第二时间段中的各个层级的预测数据;多个第二时间段为多个历史时间段中预设历史时间段之后的时间段。In the embodiment of the present application, the data prediction device 800 is used to calculate the prediction error based on the first prediction data in the second prediction data set and multiple sets of training data; the first prediction data is a plurality of first prediction data in the second prediction data set. The forecast data of each level in the time period; the multiple first time periods are the time periods before the preset historical time period in the multiple historical time periods; based on the second forecast data in the second forecast data set, calculate the time period between each level The error; the second forecast data is the forecast data of each level in the multiple second time periods in the second forecast data set; the multiple second time periods are the time periods after the preset historical time period among the multiple historical time periods.
本申请实施例中,数据预测装置800用于计算同一第一时间段中第一预测数据,与对应层级的训练数据的差的平方和,进而得到同一第一时间段中各个层级的第一总和,将多个第一时间段对应的多个第一总和相加得到预测误差。In the embodiment of the present application, the data prediction device 800 is used to calculate the sum of the squares of the difference between the first prediction data in the same first time period and the training data of the corresponding level, and then obtain the first sum of each level in the same first time period , adding the multiple first sums corresponding to the multiple first time periods to obtain the prediction error.
本申请实施例中,数据预测装置800用于计算同一第二时间段中第二预测数据中的每层的各个父层级的预测数据,与对应的各个子层级的预测数据和之差的平方和,将多个第二时间段的多个平方和相加得到第二总和;将多个第二总和与调和误差惩罚项超参数相乘,得到各个层级之间误差。In the embodiment of the present application, the data prediction device 800 is used to calculate the sum of the squares of the difference between the forecast data of each parent level of each layer in the second forecast data in the same second time period and the sum of the forecast data of the corresponding sub-levels , adding multiple sums of squares in multiple second time periods to obtain the second sum; multiplying the multiple second sums with the hyperparameter of the harmonic error penalty term to obtain the error between levels.
本申请实施例中,数据预测装置800用于将多组测试数据分别与第一预测数据集合中的多次预测数据进行比对,确定出多次预测数据对应的多次对比误差;在多次对比误差中确定出在预设误差范围内的目标对比误差;确定出目标对比误差对应的目标次预测数据对应的目标迭代次;在多个预测模型中确定目标迭代次对应的预设数据预测模型。In the embodiment of the present application, the data prediction device 800 is used to compare multiple sets of test data with multiple prediction data in the first prediction data set, and determine multiple comparison errors corresponding to multiple prediction data; Determine the target comparison error within the preset error range from the comparison error; determine the target iteration number corresponding to the target prediction data corresponding to the target comparison error; determine the preset data prediction model corresponding to the target iteration number in multiple prediction models .
本申请实施例中,多组训练数据包括:多组第一已处理数据;多组测试数据包括:多组第二已处理数据;数据预测装置800用于利用各个层级的平均数据更新所述各个层级中的异常值;利用存在空白数据的层级对应的平均数据,填充多组数据中各个层级对应的空白数据,进而得到对应各个层级时间序列的多组已处理数据;在多个历史时间段中确定出预设历史时间段,将预设历史时间段之前的多个第一时间段对应的多组第一已处理数据组合为训练集,将预设历史时间段之后的多个第二时间段对应的多组第二已处理数据组合为测试集。In the embodiment of the present application, the multiple sets of training data include: multiple sets of first processed data; multiple sets of test data include: multiple sets of second processed data; the data prediction device 800 is used to update each Outliers in the hierarchy; use the average data corresponding to the hierarchy with blank data to fill in the blank data corresponding to each hierarchy in multiple sets of data, and then obtain multiple sets of processed data corresponding to the time series of each hierarchy; in multiple historical time periods Determine the preset historical time period, combine multiple sets of first processed data corresponding to multiple first time periods before the preset historical time period into a training set, and combine multiple second time periods after the preset historical time period The corresponding sets of second processed data are combined into a test set.
本申请实施例中,数据预测装置800中的数据获取单元803用于获取多个历史时间段对应的多组物流货量数据;数据预测装置800中的预测单元804用于利用预设数据预测模型对多组物流货量数据进行处理,得到多个历史时间段之后的预设时间段的预测物流货量数据。In the embodiment of the present application, the data acquisition unit 803 in the data prediction device 800 is used to obtain multiple sets of logistics cargo volume data corresponding to multiple historical time periods; the prediction unit 804 in the data prediction device 800 is used to use the preset data prediction model Multiple sets of logistics cargo volume data are processed to obtain forecasted logistics cargo volume data for preset time periods after multiple historical time periods.
本申请实施例中,通过数据获取单元803获取分层时间序列数据;分层时间序列数据为各个层级时间序列对应的多组数据,其中,各个层级中的每层的子层级的数据之和等于对应父层级的数据;再通过预测单元804利用预设数据预测模型,对分层时间序列数据进行预测,确定出多个历史时间段之后的预设时间段内的预测结果;其中,预设数据预测模型是基于分层时间序列数据中的,历史预设时间段内的多组训练数据的预测误差,以及各个层级之间误差共同进行训练得到的。由于预设数据预测模型是基于历史时间段内的多组训练数据的预测误差,及各个层级之间误差训练得到的,在训练时候不仅考虑到了预测误差的准确性,还考虑到了各个层级间的误差,所以训练得到的预设数据预测模型对数据的预测更加准确。In the embodiment of the present application, the hierarchical time series data is obtained through the data acquisition unit 803; the hierarchical time series data are multiple sets of data corresponding to the time series of each level, wherein the sum of the sub-level data of each level in each level is equal to Corresponding to the data of the parent level; then use the preset data prediction model to predict the hierarchical time series data through the prediction unit 804, and determine the prediction results in the preset time period after multiple historical time periods; wherein, the preset data The prediction model is based on the hierarchical time series data, the prediction errors of multiple sets of training data in the historical preset time period, and the errors between each level are jointly trained. Since the preset data prediction model is based on the prediction error of multiple sets of training data in the historical time period and the error training between each level, not only the accuracy of the prediction error but also the difference between each level are taken into account during training. Error, so the pre-set data prediction model trained to predict the data is more accurate.
需要说明的是,本申请实施例中,如果以软件功能模块的形式实现上述的数据预测方法,并作为独立的产品销售或使用时,也可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请实施例的技术方案本质上或者说对相关技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台数据预测装置(可以是个人计算机等)执行本申请各个实施例所述方法的全部或部分。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read Only Memory,ROM)、磁碟或者光盘等各种可以存储程序代码的介质。这样,本申请实施例不限制于任何特定的硬件和软件结合。It should be noted that, in the embodiment of the present application, if the above-mentioned data prediction method is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the essence of the technical solutions of the embodiments of the present application or the part that contributes to the related technologies can be embodied in the form of software products. The computer software products are stored in a storage medium and include several instructions to make A data prediction device (which may be a personal computer, etc.) executes all or part of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: various media that can store program codes such as U disk, mobile hard disk, read-only memory (Read Only Memory, ROM), magnetic disk or optical disk. Thus, embodiments of the present application are not limited to any specific combination of hardware and software.
对应地,本申请实施例提供一种计算机可读存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现上述方法中的步骤。Correspondingly, an embodiment of the present application provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the steps in the above method are implemented.
对应地,本申请实施例提供一种数据预测装置,包括存储器802和处理器801,所述存储器802存储有可在处理器801上运行的计算机程序,所述处理器801执行所述程序时实现上述方法中的步骤。Correspondingly, the embodiment of the present application provides a data prediction device, including a memory 802 and a processor 801, the memory 802 stores a computer program that can be run on the processor 801, and the processor 801 implements when executing the program. steps in the method above.
这里需要指出的是:以上存储介质和装置实施例的描述,与上述方法实施例的描述是类似的,具有同方法实施例相似的有益效果。对于本申请存储介质和装置实施例中未披露的技术细节,请参照本申请方法实施例的描述而理解。It should be noted here that: the descriptions of the above storage medium and device embodiments are similar to the descriptions of the above method embodiments, and have similar beneficial effects to those of the method embodiments. For technical details not disclosed in the storage medium and device embodiments of the present application, please refer to the description of the method embodiment of the present application for understanding.
需要说明的是,图14为本申请实施例提供的数据预测装置的一种硬件实体示意图,如图14所示,该数据预测装置800的硬件实体包括:处理器801和存储器802,其中;It should be noted that FIG. 14 is a schematic diagram of a hardware entity of the data prediction device provided in the embodiment of the present application. As shown in FIG. 14 , the hardware entity of the data prediction device 800 includes: a processor 801 and a memory 802, wherein;
处理器801通常控制数据预测装置800的总体操作。The processor 801 generally controls the overall operation of the data prediction device 800 .
存储器802配置为存储由处理器801可执行的指令和应用,还可以缓存待处理器801以及数据预测装置800中各模块待处理或已经处理的数据(例如,图像数据、音频数据、语音通信数据和视频通信数据),可以通过闪存(FLASH)或随机访问存储器(Random Access Memory,RAM)实现。The memory 802 is configured to store instructions and applications executable by the processor 801, and can also cache data to be processed or processed by each module in the processor 801 and the data prediction device 800 (for example, image data, audio data, voice communication data) and video communication data), which can be implemented by flash memory (FLASH) or random access memory (Random Access Memory, RAM).
应理解,说明书通篇中提到的“一个实施例”或“一实施例”意味着与实施例有关的特定特征、结构或特性包括在本申请的至少一个实施例中。因此,在整个说明书各处出现的“在一个实施例中”或“在一实施例中”未必一定指相同的实施例。此外,这些特定的特征、结构或特性可以任意适合的方式结合在一个或多个实施例中。应理解,在本申请的各种实施例中,上述各过程的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。It should be understood that reference throughout the specification to "one embodiment" or "an embodiment" means that a particular feature, structure, or characteristic related to the embodiment is included in at least one embodiment of the present application. Thus, appearances of "in one embodiment" or "in an embodiment" in various places throughout the specification are not necessarily referring to the same embodiment. Furthermore, the particular features, structures or characteristics may be combined in any suitable manner in one or more embodiments. It should be understood that, in various embodiments of the present application, the size of the sequence numbers of the above-mentioned processes does not mean the order of execution, and the execution order of each process should be determined by its functions and internal logic, and should not be used in the embodiments of the present application. The implementation process constitutes any limitation. The serial numbers of the above embodiments of the present application are for description only, and do not represent the advantages and disadvantages of the embodiments.
需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者装置不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者装置所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、方法、物品或者装置中还存在另外的相同要素。It should be noted that, in this document, the term "comprising", "comprising" or any other variation thereof is intended to cover a non-exclusive inclusion such that a process, method, article or apparatus comprising a set of elements includes not only those elements, It also includes other elements not expressly listed, or elements inherent in the process, method, article, or device. Without further limitations, an element defined by the phrase "comprising a ..." does not preclude the presence of additional identical elements in the process, method, article, or apparatus comprising that element.
在本申请所提供的几个实施例中,应该理解到,所揭露的装置和方法,可以通过其它的方式实现。以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,如:多个单元或组件可以结合,或可以集成到另一个系统,或一些特征可以忽略,或不执行。另外,所显示或讨论的各组成部分相互之间的耦合、或直接耦合、或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性的、机械的或其它形式的。In the several embodiments provided in this application, it should be understood that the disclosed devices and methods may be implemented in other ways. The device embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods, such as: multiple units or components can be combined, or May be integrated into another system, or some features may be ignored, or not implemented. In addition, the coupling, or direct coupling, or communication connection between the various components shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be in electrical, mechanical or other forms. of.
上述作为分离部件说明的单元可以是、或也可以不是物理上分开的,作为单元显示的部件可以是、或也可以不是物理单元;既可以位于一个地方,也可以分布到多个网络单元上;可以根据实际的需要选择其中的部分或全部单元来实现本实施例方案的目的。The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed to multiple network units; Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
另外,在本申请各实施例中的各功能单元可以全部集成在一个处理单元中,也可以是各单元分别单独作为一个单元,也可以两个或两个以上单元集成在一个单元中;上述集成的单元既可以采用硬件的形式实现,也可以采用硬件加软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present application can be integrated into one processing unit, or each unit can be used as a single unit, or two or more units can be integrated into one unit; the above-mentioned integration The unit can be realized in the form of hardware or in the form of hardware plus software functional unit.
本领域普通技术人员可以理解:实现上述方法实施例的全部或部分步骤可以通过程序指令相关的硬件来完成,前述的程序可以存储于计算机可读取存储介质中,该程序在执行时,执行包括上述方法实施例的步骤;而前述的存储介质包括:移动存储装置、只读存储器(Read Only Memory,ROM)、磁碟或者光盘等各种可以存储程序代码的介质。Those of ordinary skill in the art can understand that all or part of the steps to realize the above method embodiments can be completed by hardware related to program instructions, and the aforementioned programs can be stored in computer-readable storage media. When the program is executed, the execution includes The steps of the above-mentioned method embodiments; and the aforementioned storage medium includes: various media that can store program codes such as removable storage devices, read-only memory (Read Only Memory, ROM), magnetic disks or optical disks.
或者,本申请上述集成的单元如果以软件功能模块的形式实现并作为独立的产品销售或使用时,也可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请实施例 的技术方案本质上或者说对相关技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机装置(可以是个人计算机、服务器、或者网络装置等)执行本申请各个实施例所述方法的全部或部分。而前述的存储介质包括:移动存储装置、ROM、磁碟或者光盘等各种可以存储程序代码的介质。以上所述,仅为本申请的实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。Alternatively, if the above-mentioned integrated units of the present application are realized in the form of software function modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the essence of the technical solutions of the embodiments of the present application or the part that contributes to the related technologies can be embodied in the form of software products. The computer software products are stored in a storage medium and include several instructions to make A computer device (which may be a personal computer, a server, or a network device, etc.) executes all or part of the methods described in the various embodiments of the present application. The aforementioned storage medium includes various media capable of storing program codes such as a removable storage device, ROM, magnetic disk or optical disk. The above is only the embodiment of the present application, but the scope of protection of the present application is not limited thereto. Anyone familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, and should covered within the scope of protection of this application. Therefore, the protection scope of the present application should be determined by the protection scope of the claims.
工业实用性Industrial Applicability
本申请实施例服务器通过获取分层时间序列数据;分层时间序列数据为各个层级时间序列对应的多组数据,其中,各个层级中的每层的子层级的数据之和等于对应父层级的数据;利用预设数据预测模型,对分层时间序列数据进行预测,确定出多个历史时间段之后的预设时间段内的预测结果;其中,预设数据预测模型是基于分层时间序列数据中的,历史预设时间段内的多组训练数据的预测误差,以及各个层级之间误差共同进行训练得到的。由于预设数据预测模型在训练时候不仅考虑到了预测误差的准确性,还考虑到了各个层级间的误差,所以服务器训练得到的预设数据预测模型对数据的预测更加准确。In the embodiment of the present application, the server obtains hierarchical time series data; the hierarchical time series data is multiple sets of data corresponding to the time series of each level, wherein the sum of the sub-level data of each level in each level is equal to the data of the corresponding parent level ; Use the preset data forecasting model to predict the hierarchical time series data, and determine the forecasting results in the preset time period after multiple historical time periods; wherein, the preset data forecasting model is based on the hierarchical time series data , which is obtained by jointly training the prediction errors of multiple sets of training data within the historical preset time period, and the errors between each level. Since the preset data prediction model not only takes into account the accuracy of the prediction error, but also considers the errors between various levels during training, the preset data prediction model obtained by the server training is more accurate in predicting data.

Claims (12)

  1. 一种数据预测方法,包括:A data prediction method comprising:
    获取分层时间序列数据;所述分层时间序列数据为各个层级时间序列对应的多组数据,其中,所述各个层级中的每层的子层级的数据之和等于对应父层级的数据;Acquiring hierarchical time series data; the hierarchical time series data is a plurality of sets of data corresponding to each hierarchical time series, wherein the sum of the sub-level data of each level in each level is equal to the data of the corresponding parent level;
    利用预设数据预测模型,对所述分层时间序列数据进行预测,确定出多个历史时间段之后的预设时间段内的预测结果;其中,Using a preset data prediction model to predict the hierarchical time series data, and determine the prediction results within a preset time period after multiple historical time periods; wherein,
    所述预设数据预测模型是基于所述分层时间序列数据中的,历史预设时间段内的多组训练数据的预测误差,以及各个层级之间误差共同进行训练得到的。The preset data prediction model is obtained through joint training based on the prediction errors of multiple sets of training data in the historical preset time period in the hierarchical time series data, and the errors between each level.
  2. 根据权利要求1所述的数据预测方法,其中,所述利用预设数据预测模型,对所述分层时间序列数据进行预测,确定出多个历史时间段之后的预设时间段内的预测结果之前,所述获取分层时间序列数据之后,所述方法还包括:The data forecasting method according to claim 1, wherein said using the preset data forecasting model to predict the hierarchical time series data, and determine the forecast results within the preset time period after a plurality of historical time periods Before, after the acquisition of hierarchical time series data, the method further includes:
    对所述分层时间序列数据的多组数据进行标准化处理,并将标准化处理后的多组数据按照预设历史时间段分为训练集和测试集;所述训练集包括:多组训练数据;所述测试集包括:多组测试数据;Performing standardization processing on multiple sets of data of the layered time series data, and dividing the multiple sets of standardized data into training sets and test sets according to preset historical time periods; the training set includes: multiple sets of training data; The test set includes: multiple sets of test data;
    利用初始预测模型的损失函数计算所述训练集的预测误差,以及各个层级之间误差,并依据所述预测误差,及所述各个层级之间误差对所述初始预测模型的模型参数进行迭代调整,直至满足训练条件时停止,得到对应所述测试集的第一预测数据集合;所述第一预测数据集合包括:对应所述测试集的各个历史时间段的各个层级的迭代过程中的多次预测数据;Using the loss function of the initial prediction model to calculate the prediction error of the training set and the error between the various levels, and iteratively adjust the model parameters of the initial prediction model according to the prediction error and the error between the various levels. , stop until the training condition is satisfied, and obtain the first prediction data set corresponding to the test set; the first prediction data set includes: multiple times in the iterative process of each level of each historical time period corresponding to the test set forecast data;
    利用所述多组测试数据和所述第一预测数据集合进行比对,确定出所述预设数据预测模型。The preset data prediction model is determined by comparing the multiple sets of test data with the first prediction data set.
  3. 根据权利要求2所述的数据预测方法,其中,所述利用初始预测模型的损失函数计算所述训练集的预测误差,以及各个层级之间误差,并依据所述预测误差,及所述各个层级之间误差对初始预测模型的模型参数进行迭代调整,直至满足训练条件时停止,得到对应测试集的第一预测数据集合,包括:The data prediction method according to claim 2, wherein said using the loss function of the initial prediction model to calculate the prediction error of the training set, and the error between each level, and based on the prediction error, and the each level The model parameters of the initial prediction model are iteratively adjusted until the training conditions are met, and the first prediction data set corresponding to the test set is obtained, including:
    将所述多组训练数据输入所述初始预测模型,得到第二预测数据集合;所述第二预测数据集合包括:所述多个历史时间段的各个层级的预测数据;Inputting the multiple sets of training data into the initial forecasting model to obtain a second forecasting data set; the second forecasting data set includes: forecasting data at various levels of the multiple historical time periods;
    基于所述第二预测数据集合和所述多组训练数据,结合所述损失函数计算所述预测误差和所述各个层级之间误差;calculating the prediction error and the error between the various levels in combination with the loss function based on the second prediction data set and the plurality of sets of training data;
    利用所述预测误差和所述各个层级之间误差对所述损失函数进行梯度求解,得到迭代过程中的模型参数,从而得到更新的预测模型;performing a gradient solution to the loss function by using the prediction error and the errors between the various levels to obtain model parameters in the iterative process, thereby obtaining an updated prediction model;
    利用所述更新的预测模型,继续对所述多组训练数据进行训练,直至满足训练条件时停止,得到最终的预测模型,从而得到迭代过程中的多个预测模型;Using the updated prediction model, continue to train the multiple sets of training data until the training conditions are met, and stop to obtain the final prediction model, thereby obtaining multiple prediction models in the iterative process;
    在采用所述多个预测模型,得到对应的每个第二预测数据集合中,提取出对应所述测试集的各个历史时间段的各个层级的预测数据,进而得到所述迭代过程中的所述第一预测数据集合。In each of the corresponding second prediction data sets obtained by using the plurality of prediction models, the prediction data of each level corresponding to each historical time period of the test set is extracted, and then the above-mentioned in the iterative process is obtained. The first forecast data set.
  4. 根据权利要求3所述的数据预测方法,其中,所述基于所述第二预测数据集合和所述多组训练数据,结合所述损失函数计算所述预测误差和所述各个层级之间误差,包括:The data prediction method according to claim 3, wherein, based on the second prediction data set and the multiple sets of training data, the prediction error and the error between the various levels are calculated in combination with the loss function, include:
    基于所述第二预测数据集合中的第一预测数据,及所述多组训练数据,计算所述预测误差;所述第一预测数据为所述第二预测数据集合中多个第一时间段中的各个层级的预测数据;所述多个第一时间段为所述多个历史时间段中所述预设历史时间段之前的时间段;Calculate the prediction error based on the first prediction data in the second prediction data set and the multiple sets of training data; the first prediction data is a plurality of first time periods in the second prediction data set The forecast data of each level in the above; the plurality of first time periods are the time periods before the preset historical time period in the plurality of historical time periods;
    基于所述第二预测数据集合中第二预测数据,计算所述各个层级之间误差;所述第二预测数据为所述第二预测数据集合中多个第二时间段中的各个层级的预测数据;所述多个第二时间段为所述多个历史时间段中所述预设历史时间段之后的时间段。Based on the second prediction data in the second prediction data set, calculate the error between the various levels; the second prediction data is the prediction of each level in a plurality of second time periods in the second prediction data set Data; the multiple second time periods are time periods after the preset historical time period among the multiple historical time periods.
  5. 根据权利要求4所述的数据预测方法,其中,所述基于所述第二预测数据集合中的 第一预测数据,及所述多组训练数据,计算所述预测误差,包括:The data prediction method according to claim 4, wherein, calculating the prediction error based on the first prediction data in the second prediction data set and the plurality of sets of training data includes:
    计算同一第一时间段中所述第一预测数据,与对应层级的训练数据的差的平方和,进而得到同一第一时间段中各个层级的第一总和,将所述多个第一时间段对应的多个第一总和相加得到所述预测误差。Calculating the sum of squares of the differences between the first prediction data in the same first time period and the training data of the corresponding level, and then obtaining the first sum of each level in the same first time period, combining the multiple first time periods The corresponding multiple first sums are added to obtain the prediction error.
  6. 根据权利要求4所述的数据预测方法,其中,所述基于所述第二预测数据集合中第二预测数据,计算所述各个层级之间误差,包括:The data prediction method according to claim 4, wherein said calculating the errors between the various levels based on the second prediction data in the second prediction data set includes:
    计算同一第二时间段中所述第二预测数据中的每层的各个父层级的预测数据,与对应的各个子层级的预测数据和之差的平方和,将所述多个第二时间段的多个平方和相加得到第二总和;calculating the sum of the squares of the differences between the forecast data of each parent level in the second forecast data in the same second time period and the forecast data sums of the corresponding sub-levels, and combining the multiple second time periods Multiple sums of squares are added to obtain the second sum;
    将所述多个第二总和与调和误差惩罚项超参数相乘,得到所述各个层级之间误差。The multiple second sums are multiplied by the hyperparameter of the harmonic error penalty term to obtain the errors between the various levels.
  7. 根据权利要求3所述的数据预测方法,其中,所述利用所述多组测试数据和所述第一预测数据集合进行比对,确定出所述预设数据预测模型,包括:The data prediction method according to claim 3, wherein said comparing the multiple sets of test data with the first prediction data set to determine the preset data prediction model includes:
    将所述多组测试数据分别与所述第一预测数据集合中的所述多次预测数据进行比对,确定出所述多次预测数据对应的多次对比误差;Comparing the plurality of sets of test data with the multiple prediction data in the first prediction data set respectively, and determining the multiple comparison errors corresponding to the multiple prediction data;
    在所述多次对比误差中确定出在预设误差范围内的目标对比误差;Determining a target comparison error within a preset error range among the multiple comparison errors;
    确定出所述目标对比误差对应的目标次预测数据对应的目标迭代次;Determining a target iteration number corresponding to the target number of prediction data corresponding to the target comparison error;
    在所述多个预测模型中确定目标迭代次对应的所述预设数据预测模型。The preset data prediction model corresponding to the target iteration number is determined among the plurality of prediction models.
  8. 根据权利要求2所述的数据预测方法,其中,所述多组训练数据包括:多组第一已处理数据;所述多组测试数据包括:多组第二已处理数据;The data prediction method according to claim 2, wherein the multiple sets of training data include: multiple sets of first processed data; the multiple sets of test data include: multiple sets of second processed data;
    所述对所述分层时间序列数据的多组数据进行标准化处理,并将标准化处理后的多组数据按照预设历史时间段分为训练集和测试集,包括:The multiple sets of data of the hierarchical time series data are standardized, and the multiple sets of standardized data are divided into training sets and test sets according to preset historical time periods, including:
    利用各个层级的平均数据更新所述各个层级中的异常值;updating the outliers in each stratum with the average data for each stratum;
    利用存在空白数据的层级对应的平均数据,填充所述多组数据中各个层级对应的空白数据,进而得到对应所述各个层级时间序列的多组已处理数据;Filling the blank data corresponding to each level in the multiple sets of data by using the average data corresponding to the levels with blank data, and then obtaining multiple sets of processed data corresponding to the time series of each level;
    在所述多个历史时间段中确定出预设历史时间段,将所述预设历史时间段之前的多个第一时间段对应的所述多组第一已处理数据组合为所述训练集,将所述预设历史时间段之后的多个第二时间段对应的所述多组第二已处理数据组合为所述测试集。A preset historical time period is determined in the multiple historical time periods, and the multiple sets of first processed data corresponding to the multiple first time periods before the preset historical time period are combined into the training set Combining the plurality of sets of second processed data corresponding to the plurality of second time periods after the preset historical time period into the test set.
  9. 根据权利要求1所述的数据预测方法,其中,所述方法还包括:The data prediction method according to claim 1, wherein the method further comprises:
    获取所述多个历史时间段对应的多组物流货量数据;Obtain multiple sets of logistics cargo volume data corresponding to the multiple historical time periods;
    利用所述预设数据预测模型对所述多组物流货量数据进行处理,得到所述多个历史时间段之后的预设时间段的预测物流货量数据。The multiple sets of logistics cargo volume data are processed by using the preset data prediction model to obtain predicted logistics cargo volume data for a preset time period after the multiple historical time periods.
  10. 一种数据预测装置,包括:A data prediction device, comprising:
    数据获取模块,被配置为获取分层时间序列数据;所述分层时间序列数据为各个层级时间序列对应的多组数据,其中,所述各个层级中的每层的子层级的数据之和等于对应父层级的数据;The data acquisition module is configured to acquire hierarchical time series data; the hierarchical time series data is a plurality of sets of data corresponding to each hierarchical time series, wherein the sum of the sub-level data of each level in each level is equal to Corresponding to the data of the parent level;
    预测模块,被配置为利用预设数据预测模型,对所述分层时间序列数据进行预测,确定出多个历史时间段之后的预设时间段内的预测结果;其中,The prediction module is configured to use a preset data prediction model to predict the hierarchical time series data, and determine the prediction results within a preset time period after a plurality of historical time periods; wherein,
    所述预设数据预测模型是基于所述分层时间序列数据中的历史预设时间段内的多组训练数据的预测误差,以及各个层级之间误差共同进行训练得到的。The preset data prediction model is obtained through joint training based on the prediction errors of multiple sets of training data in the historical preset time period in the layered time series data, and the errors between each level.
  11. 一种数据预测装置,包括存储器和处理器,所述存储器存储有可在处理器上运行的计算机程序,所述处理器执行所述程序时实现权利要求1至9任一项所述方法中的步骤。A data prediction device, comprising a memory and a processor, the memory stores a computer program that can run on the processor, and the processor implements the method described in any one of claims 1 to 9 when executing the program step.
  12. 一种计算机可读存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现权利要求1至9任一项所述方法中的步骤。A computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps in the method of any one of claims 1 to 9 are implemented.
PCT/CN2022/108936 2021-08-17 2022-07-29 Data prediction method and apparatus, and storage medium WO2023020257A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110943383.6 2021-08-17
CN202110943383.6A CN113656691A (en) 2021-08-17 2021-08-17 Data prediction method, device and storage medium

Publications (1)

Publication Number Publication Date
WO2023020257A1 true WO2023020257A1 (en) 2023-02-23

Family

ID=78479949

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/108936 WO2023020257A1 (en) 2021-08-17 2022-07-29 Data prediction method and apparatus, and storage medium

Country Status (2)

Country Link
CN (1) CN113656691A (en)
WO (1) WO2023020257A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116956049A (en) * 2023-09-19 2023-10-27 中国联合网络通信集团有限公司 Training method, device, equipment and storage medium of industrial productivity prediction model
CN118350515A (en) * 2024-06-18 2024-07-16 浙江天演维真网络科技股份有限公司 Crop yield prediction method, device, equipment and storage medium
CN118606718A (en) * 2024-08-08 2024-09-06 安徽思高智能科技有限公司 Flow prediction method and equipment based on historical model integration

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113656691A (en) * 2021-08-17 2021-11-16 北京沃东天骏信息技术有限公司 Data prediction method, device and storage medium
CN114626896A (en) * 2022-04-02 2022-06-14 北京京东振世信息技术有限公司 Method and device for predicting quantity of articles, electronic equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110263380A (en) * 2019-05-23 2019-09-20 东华大学 A kind of spinning process cascade modeling piecewise interval method for parameter configuration
CN111915083A (en) * 2020-08-03 2020-11-10 国网山东省电力公司电力科学研究院 Wind power prediction method and prediction system based on time hierarchical combination
CN112348271A (en) * 2020-11-12 2021-02-09 华北电力大学 Short-term photovoltaic power prediction method based on VMD-IPSO-GRU
CN113656691A (en) * 2021-08-17 2021-11-16 北京沃东天骏信息技术有限公司 Data prediction method, device and storage medium

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109034905A (en) * 2018-08-03 2018-12-18 四川长虹电器股份有限公司 The method for promoting sales volume prediction result robustness
CN111124840B (en) * 2019-12-02 2022-02-08 北京天元创新科技有限公司 Method and device for predicting alarm in business operation and maintenance and electronic equipment
CN113049453B (en) * 2021-03-15 2022-06-14 中国石油大学(北京) In-situ wetting angle measuring device and wetting angle determining method based on deep learning

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110263380A (en) * 2019-05-23 2019-09-20 东华大学 A kind of spinning process cascade modeling piecewise interval method for parameter configuration
CN111915083A (en) * 2020-08-03 2020-11-10 国网山东省电力公司电力科学研究院 Wind power prediction method and prediction system based on time hierarchical combination
CN112348271A (en) * 2020-11-12 2021-02-09 华北电力大学 Short-term photovoltaic power prediction method based on VMD-IPSO-GRU
CN113656691A (en) * 2021-08-17 2021-11-16 北京沃东天骏信息技术有限公司 Data prediction method, device and storage medium

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116956049A (en) * 2023-09-19 2023-10-27 中国联合网络通信集团有限公司 Training method, device, equipment and storage medium of industrial productivity prediction model
CN118350515A (en) * 2024-06-18 2024-07-16 浙江天演维真网络科技股份有限公司 Crop yield prediction method, device, equipment and storage medium
CN118606718A (en) * 2024-08-08 2024-09-06 安徽思高智能科技有限公司 Flow prediction method and equipment based on historical model integration

Also Published As

Publication number Publication date
CN113656691A (en) 2021-11-16

Similar Documents

Publication Publication Date Title
WO2023020257A1 (en) Data prediction method and apparatus, and storage medium
Li et al. Effective tourist volume forecasting supported by PCA and improved BPNN using Baidu index
Srivastava et al. Software test effort estimation: a model based on cuckoo search
Liu et al. Particle Swarm Optimization‐Based Support Vector Regression for Tourist Arrivals Forecasting
CN109767032A (en) A kind of business finance operation digital management optimization system based on data analysis
Chen et al. An effective matching algorithm with adaptive tie-breaking strategy for online food delivery problem
Davila Delgado et al. Big data analytics system for costing power transmission projects
Yi et al. Intelligent prediction of transmission line project cost based on least squares support vector machine optimized by particle swarm optimization
CN112668822A (en) Scientific and technological achievement transformation platform sharing system, method, storage medium and mobile phone APP
Luo et al. Improving neighborhood based Collaborative Filtering via integrated folksonomy information
Gandhmal et al. Wrapper-enabled feature selection and CPLM-based NARX model for stock market prediction
Lee et al. Dynamic BIM component recommendation method based on probabilistic matrix factorization and grey model
Mahbub et al. A neural approach to product demand forecasting
Yu et al. SALSTM: An improved LSTM algorithm for predicting the competitiveness of export products
Shi Cloud manufacturing service recommendation model based on GA-ACO and carbon emission hierarchy
Zhang et al. RSVRs based on feature extraction: a novel method for prediction of construction projects’ costs
Zhai et al. Combining PSO-SVR and Random Forest Based Feature Selection for Day-ahead Peak Load Forecasting.
Wu et al. Forecast combination using grey relational analysis and Choquet fuzzy integral for container throughput forecasting
CN116777056A (en) Method and device for training prediction model and determining material demand
Chang et al. An interval-valued time series forecasting scheme with probability distribution features for electric power generation prediction
Wang An analysis of the optimal customer clusters using dynamic multi-objective decision
CN104657429A (en) Complex-network-based technology-driven product innovation method
Sakawa et al. Interactive fuzzy multiobjective stochastic programming with simple recourse
Shir‐Mohammadli et al. A comparative study of a hybrid Logit–Fratar and neural network models for trip distribution: case of the city of Isfahan
Ji et al. Two-phase layered learning recommendation via category structure

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22857569

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205 DATED 10/06/2024)