CN113656691A - Data prediction method, device and storage medium - Google Patents

Data prediction method, device and storage medium Download PDF

Info

Publication number
CN113656691A
CN113656691A CN202110943383.6A CN202110943383A CN113656691A CN 113656691 A CN113656691 A CN 113656691A CN 202110943383 A CN202110943383 A CN 202110943383A CN 113656691 A CN113656691 A CN 113656691A
Authority
CN
China
Prior art keywords
data
prediction
training
preset
hierarchy
Prior art date
Legal status (The legal status 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 status listed.)
Pending
Application number
CN202110943383.6A
Other languages
Chinese (zh)
Inventor
耿东阳
张建申
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Wodong Tianjun Information Technology Co Ltd
Original Assignee
Beijing Wodong Tianjun Information Technology Co Ltd
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 Beijing Wodong Tianjun Information Technology Co Ltd filed Critical Beijing Wodong Tianjun Information Technology Co Ltd
Priority to CN202110943383.6A priority Critical patent/CN113656691A/en
Publication of CN113656691A publication Critical patent/CN113656691A/en
Priority to PCT/CN2022/108936 priority patent/WO2023020257A1/en
Pending legal-status Critical Current

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

Abstract

The invention provides a data prediction method, a data prediction device and a storage medium, wherein layered time series data are acquired; the hierarchical time series data is a plurality of groups of data corresponding to each hierarchical time series, wherein the sum of the data of the sub-hierarchy of each hierarchy in each hierarchy is equal to the data of the corresponding parent hierarchy; predicting the hierarchical time series data by using a preset data prediction model, and determining a prediction result in a preset time period after a plurality of historical time periods; the preset data prediction model is obtained by training prediction errors of a plurality of groups of training data in historical preset time periods and errors among all levels together in the layered time series data. The preset data prediction model obtained by training predicts data more accurately because the accuracy of prediction errors and errors among layers are considered in the training process.

Description

Data prediction method, device and storage medium
Technical Field
The embodiment of the invention relates to the technical field of prediction models, in particular to a data prediction method, a data prediction device and a storage medium.
Background
The time series prediction has wide application fields, such as demand prediction in the retail industry, financial market prediction, logistics capacity prediction and the like. In the process of realizing automatic intelligence in many business processes, time series prediction plays a very important role, for example, an online shopping website, and it is a series of business decisions that the sales volume of each type of goods needs to be predicted in a future period of time. Such as stock, promotions, etc., and therefore the predictive technical capabilities can ultimately have a significant impact on sales revenue, inventory costs, etc. Meanwhile, the quantity of commodities sold by a large online shopping website can reach millions, and a large-scale time sequence generates a new challenge to a modern time sequence prediction technology.
In the prior art, time series prediction uses single-level data for prediction, and then obtains prediction results of other levels in a splitting or aggregation manner, although the time series prediction is simple and convenient to use, the prediction accuracy is generally relatively low, and the main disadvantages are as follows: firstly, the existing prediction methods only use the prediction result of a single level substantially, and do not use the information contained in the prediction data of other levels, thereby causing the loss of accuracy; secondly, when the prediction results are summarized upwards or decomposed downwards, additional prediction errors are introduced. In addition, because different single levels are used to obtain different results, not only is the level selection dependent on manual experience, but also accuracy is lost.
Disclosure of Invention
The data prediction method, the data prediction device and the storage medium provided by the embodiment of the invention can improve the accuracy of data prediction.
The technical scheme of the invention is realized as follows:
the embodiment of the invention provides a data prediction method, which comprises the following steps:
acquiring layered time series data; the hierarchical time series data is a plurality of groups of data corresponding to each hierarchical time series, wherein the sum of the data of the sub-hierarchy of each hierarchy in each hierarchy is equal to the data of the corresponding parent hierarchy;
predicting the hierarchical time series data by using a preset data prediction model, and determining a prediction result in a preset time period after a plurality of historical time periods; wherein the content of the first and second substances,
the preset data prediction model is obtained by training prediction errors of a plurality of groups of training data in historical preset time periods and errors among all levels in the layered time series data together.
In the above scheme, the method further includes, after the layered time series data is acquired before the preset data prediction model is used to predict the layered time series data and the prediction results in the preset time period after the plurality of historical time periods are determined, the method further includes:
carrying out standardization processing on a plurality of groups of data of the layered time sequence data, and dividing the plurality of groups of data after the standardization processing into a training set and a test set according to a preset historical time period; the training set comprises: a plurality of sets of training data; the test set includes: a plurality of sets of test data;
calculating a prediction error of a training set and errors among all levels by using a loss function of an initial prediction model, and iteratively adjusting model parameters of the initial prediction model according to the prediction error and the errors among all levels until training conditions are met, so as to obtain a first prediction data set corresponding to a test set; the first set of prediction data comprises: multiple times of prediction data in the iteration process of each level corresponding to each historical time period of the test set;
and comparing the plurality of groups of test data with the first prediction data set to determine a preset data prediction model.
In the above scheme, calculating a prediction error of the training set and an error between each level by using a loss function of the initial prediction model, and iteratively adjusting a model parameter of the initial prediction model according to the prediction error and the error between each level until a training condition is satisfied, to obtain a first prediction data set corresponding to the test set, including:
inputting a plurality of groups of training data into an initial prediction model to obtain a second prediction data set; the second set of prediction data comprises: prediction data for each hierarchy of a plurality of historical time periods;
calculating a prediction error and errors among all levels by combining a loss function based on the second prediction data set and the multiple groups of training data;
carrying out gradient solving on the loss function to obtain model parameters in an iterative process so as to obtain an updated prediction model;
continuously training a plurality of groups of training data by using the updated prediction model until the training conditions are met, and obtaining a final prediction model, thereby obtaining a plurality of prediction models in the iterative process;
and extracting the prediction data of each hierarchy of each historical time period corresponding to the test set from each corresponding second prediction data set obtained by adopting a plurality of prediction models, and further obtaining a first prediction data set in the iterative process.
In the above scheme, calculating the prediction error and the error between each hierarchy level by combining the loss function based on the second prediction data set and the plurality of sets of training data includes:
calculating a prediction error based on the first prediction data in the second prediction data set and the plurality of groups of training data; the first prediction data is prediction data of each level in a plurality of first time periods in the second prediction data set; the plurality of first time periods are time periods before a preset historical time period in the plurality of historical time periods;
calculating errors between the levels based on second prediction data in a second prediction data set; the second prediction data is prediction data of each hierarchy in a plurality of second time periods in a second prediction data set; the plurality of second time periods are time periods after a preset history time period among the plurality of history time periods.
In the above scheme, calculating the prediction error based on the first prediction data in the second prediction data set and multiple sets of training data includes:
and calculating the square sum of the difference between the first prediction data in the same first time period and the training data of the corresponding hierarchy to further obtain the first sum of each hierarchy in the same first time period, and adding the first sums corresponding to the first time periods to obtain the prediction error.
In the above solution, calculating an error between each hierarchy based on the second prediction data in the second prediction data set includes:
calculating the square sum of the difference between the prediction data of each parent level of each layer in the second prediction data in the same second time period and the corresponding prediction data sum of each sub-level, and adding the square sums of a plurality of second time periods to obtain a second sum;
and multiplying the second sums by the harmonic error penalty term hyperparameter to obtain the error between each hierarchy.
In the above scheme, comparing the plurality of groups of test data with the first prediction data set to determine a preset data prediction model includes:
comparing the multiple groups of test data with multiple times of predicted data in the first predicted data set respectively to determine multiple times of comparison errors corresponding to the multiple times of predicted data;
determining a target comparison error within a preset error range from the multiple comparison errors;
determining a target iteration number corresponding to target secondary prediction data corresponding to the target comparison error;
and determining a prediction data prediction model corresponding to the target iteration in the plurality of prediction models.
In the above scheme, the plurality of sets of training data include: a plurality of sets of first processed data; the sets of test data include: a plurality of sets of second processed data;
standardizing a plurality of groups of data of the layered time sequence data, and dividing the standardized plurality of groups of data into a training set and a testing set according to a preset historical time period, wherein the method comprises the following steps:
deleting abnormal values of all levels in the multiple groups of data, and filling average data of the levels corresponding to the abnormal values;
filling blank data corresponding to each hierarchy in a plurality of groups of data by using average data corresponding to the hierarchy with the blank data, and further obtaining a plurality of groups of processed data corresponding to each hierarchy time sequence;
determining a preset historical time period in the plurality of historical time periods, combining a plurality of groups of first processed data corresponding to a plurality of first time periods before the preset historical time period into a training set, and combining a plurality of groups of second processed data corresponding to a plurality of second time periods after the preset historical time period into a test set.
In the above scheme, the method further comprises:
acquiring a plurality of groups of logistics cargo volume data corresponding to a plurality of historical time periods;
and processing the multiple groups of logistics cargo volume data by using a preset data prediction model to obtain predicted logistics cargo volume data of a preset time period after the multiple historical time periods.
An embodiment of the present invention further provides a data prediction apparatus, including:
a data acquisition unit for acquiring layered time-series data; the hierarchical time series data is a plurality of groups of data corresponding to each hierarchical time series, wherein the sum of the data of the sub-hierarchy of each hierarchy in each hierarchy is equal to the data of the corresponding parent hierarchy;
the prediction unit is used for predicting the hierarchical time series data by using a preset data prediction model and determining a prediction result in a preset time period after a plurality of historical time periods; wherein the content of the first and second substances,
the preset data prediction model is obtained by training a plurality of groups of training data prediction errors in a historical preset time period in the layered time series data and errors among all layers together.
The embodiment of the invention also provides a data prediction device, which comprises a memory and a processor, wherein the memory stores a computer program capable of running on the processor, and the processor realizes the steps in the method when executing the program.
Embodiments of the present invention also provide a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the computer program implements the steps in the above method.
In the embodiment of the invention, layered time series data are acquired; the hierarchical time series data is a plurality of groups of data corresponding to each hierarchical time series, wherein the sum of the data of the sub-hierarchy of each hierarchy in each hierarchy is equal to the data of the corresponding parent hierarchy; predicting the hierarchical time series data by using a preset data prediction model, and determining a prediction result in a preset time period after a plurality of historical time periods; the preset data prediction model is obtained by training prediction errors of a plurality of groups of training data in historical preset time periods and errors among all levels together in the layered time series data. Because the preset data prediction model is obtained by training based on prediction errors of a plurality of groups of training data in a historical time period and errors among all levels, the accuracy of the prediction errors and the errors among all levels are considered during training, and the data can be predicted more accurately by the trained preset data prediction model.
Drawings
FIG. 1 is a schematic flow chart of an alternative data prediction method according to an embodiment of the present invention;
fig. 2 is a schematic diagram illustrating an optional effect of the data prediction method according to the embodiment of the present invention;
fig. 3 is a schematic diagram illustrating an optional effect of the data prediction method according to the embodiment of the present invention;
FIG. 4 is a schematic flow chart of an alternative data prediction method according to an embodiment of the present invention;
FIG. 5 is a schematic flow chart of an alternative data prediction method according to an embodiment of the present invention;
FIG. 6 is a schematic flow chart of an alternative data prediction method according to an embodiment of the present invention;
FIG. 7 is a schematic flow chart of an alternative data prediction method according to an embodiment of the present invention;
FIG. 8 is a schematic flow chart of an alternative data prediction method according to an embodiment of the present invention;
FIG. 9 is a schematic flow chart of an alternative data prediction method according to an embodiment of the present invention;
fig. 10 is a schematic structural diagram of a logistics cargo quantity prediction apparatus according to an embodiment of the present invention;
FIG. 11 is a schematic flow chart illustrating an alternative data prediction method according to an embodiment of the present invention;
FIG. 12 is a first schematic structural diagram of a data prediction apparatus according to an embodiment of the present invention;
FIG. 13 is a second schematic structural diagram of a data prediction apparatus according to an embodiment of the present invention;
fig. 14 is a hardware entity diagram of a data prediction apparatus according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the technical solutions of the present invention are further described in detail with reference to the drawings and the embodiments, the described embodiments should not be construed as limiting the present invention, and all other embodiments obtained by a person of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
In the following description, reference is made to "some embodiments" which describe a subset of all possible embodiments, but it is understood that "some embodiments" may be the same subset or different subsets of all possible embodiments, and may be combined with each other without conflict.
To the extent that similar descriptions of "first/second" appear in this patent document, the description below will be added, where reference is made to the term "first \ second \ third" merely to distinguish between similar objects and not to imply a particular ordering with respect to the objects, it being understood that "first \ second \ third" may be interchanged either in a particular order or in a sequential order as permitted, to enable embodiments of the invention described herein to be practiced in other than the order illustrated or described herein.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. The terminology used herein is for the purpose of describing embodiments of the invention only and is not intended to be limiting of the invention.
In the prior art, for example, a nationwide fast-food product producing enterprise needs to predict the future sales of a certain product in the country and provinces simultaneously so as to make an inventory layout and stock plan. The prediction scheme is to perform single-time sequence prediction on sales time sequences of each province and each province respectively, so that the prediction results of different levels do not automatically meet consistency, namely the total sum of sales prediction of the provinces and the nationwide sales prediction is not equal, and the inconsistent prediction results cannot be used in the cooperative decision flow of each level.
The current major prediction methods include: "Top-Down" (Top-Down), "Bottom-Up" (Bottom-Up), "Middle-Out" (Middle-Out), "optimal blending". As the name implies, "top-down" means that the time series of the highest hierarchy is predicted first, and then the prediction results are divided into lower hierarchies according to a fixed proportion, and "bottom-up" means that the time series of the finest granularity is predicted first, and then the prediction results are aggregated upwards. The "middle break" approach combines bottom-up and top-down approaches. First, an "intermediate level" is selected and predictions are generated for all sequences of that level. For series above the middle level, consistent predictions are generated using a bottom-up approach by aggregating the predictions of the "middle level" upward. For sequences below the "intermediate level," consistent predictions are generated using a top-down approach by decomposing the predictions of the "intermediate level" downward. The optimal reconciliation method is that all levels of prediction results are obtained first, then the prediction results are processed in an optimal linear weighted reconciliation mode, and then final results are obtained.
The three methods of "top-down", "bottom-up" and "middle breakthrough" are the most used methods at present, and these methods only use a single level of data for prediction, and then obtain the prediction results of other levels by means of splitting or aggregating, although the methods are simple and convenient to use, they also result in relatively low prediction accuracy, and the main disadvantages are: firstly, the three prediction methods essentially only use the prediction result of a single level, and do not use the information contained in the prediction data of other levels, thereby causing the loss of accuracy; secondly, when the prediction results are summarized upwards or decomposed downwards, additional prediction errors are introduced. In addition, because different single levels are used to obtain different results, not only is the level selection dependent on manual experience, but also accuracy is lost.
In order to solve the technical problem of low prediction accuracy of the prediction model, an embodiment of the present invention further provides a data prediction method, please refer to fig. 1, which is an optional flow diagram of the data prediction method provided in the embodiment of the present invention, and the data prediction method will be described with reference to the steps shown in fig. 1.
S101, acquiring layered 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 data of the child hierarchy of each of the respective hierarchical levels is equal to the data of the corresponding parent hierarchy.
In the embodiment of the invention, the server acquires the layered time series data. The hierarchical time series data is a plurality of groups of data corresponding to each hierarchical time series. The sum of the data of the child levels of each of the various levels is equal to the data of the corresponding parent level.
In the embodiment of the invention, the server establishes communication connection with the client corresponding to each hierarchy in advance. And the server acquires multiple groups of data of each hierarchy corresponding to multiple historical time periods from the client through communication connection with the client of each hierarchy. That is, the server obtains multiple sets of data corresponding to the time series of each hierarchy from the client of each hierarchy.
In the embodiment of the invention, the server acquires the pre-stored hierarchical time sequence data in the database of the server.
Wherein, any one of the plurality of sets of data may include: the combination of data corresponding to each hierarchy of any time series. That is, any one of the sets of data may include: and combining data of each hierarchy corresponding to any one time period in the plurality of historical time periods. Wherein, one data in the group of data can be any one of sales data, object flow data and user age data of the corresponding hierarchy. Wherein, the material flow data can be one of the corresponding total material flow number, the total material flow weight and the total material flow volume.
For example, the time series may be three time series corresponding to three months before the current time. The time sequence may also be three time sequences corresponding to three days before the current time, respectively.
In the embodiment of the present invention, the sub-level may be a city level, and the parent level may be a province level corresponding to the sub-level. A province level may correspond to a plurality of city levels. The parent level can also be a primary agent, and the sub-level can be a plurality of secondary agents corresponding to the parent level. One primary agent may correspond to multiple secondary agents. The sum of the data of the multiple child hierarchies is the data of the corresponding parent hierarchy.
In the embodiment of the invention, the server firstly acquires the hierarchical time series data to be predicted. The ith time sequence value observed by the server at the moment 1-T is recorded as yi=(yt i,…,yT i)TI is 1, …, n. Wherein, yi=(yt i,…,yT i)TData characterizing each level of 1-T time periods, 1, …, n being n levels.
And the hierarchical time series data satisfy that the sum of the data of each sub-hierarchy is equal to the data of the corresponding parent hierarchy. In connection with FIG. 2, the hierarchy satisfies y1=y2+y3. Wherein y is1Is y2And y3Corresponding parent level data, y2And y3Is y1Corresponding sub-level data.
In connection with FIG. 3, the hierarchy of the hierarchical time series data satisfies y1=y2+y3,y2=y4+y5,y3=y6+y7. Wherein y is2Is y4And y5Corresponding parent level data, y3Is y6And y7Corresponding parent level data. The task of hierarchical time series prediction is to give time 1, …, t0Predicting the value of the whole time sequence in the future period t + h
Figure BDA0003215973120000091
Where y is data in the time series data. When the time series is the day dimension, then the daily volume. For example, day 1 to day 5 of 7, y _ beijing ═ 10, 20, 30, 40, 50, and y _ hebei ═ 30, 40, 50, 60, 10. In the layered time series research and application, the constraint condition is expressed visually by using the shown hierarchical structure diagram. Such constraints are fundamental features of hierarchical timing, and are also representative of the meaning of "hierarchy", which is a natural law satisfied by variables within a statistical range, such as Y _ national sum (Y _ beijing, Y _ hebeibei, …), and Y _ beijing sum (Y _ hai lake, …, Y _ west city).
S102, predicting the hierarchical time series data by using a preset data prediction model, and determining a prediction result in a preset time period after a plurality of historical time periods; the preset data prediction model is obtained by training prediction errors of a plurality of groups of training data in historical preset time periods and errors among all levels together in the layered time series data.
In the embodiment of the invention, a server predicts the hierarchical time series data by using a preset data prediction model and determines the prediction results in a preset time period after a plurality of historical time periods; the preset data prediction model is obtained by training prediction errors of a plurality of groups of training data in historical preset time periods and errors among all levels together in the layered time series data.
In the embodiment of the invention, the server divides a plurality of groups of data into a training set and a test set. And the server iteratively trains the initial prediction model by combining the training data with the loss function. And the server obtains a plurality of prediction models corresponding to a plurality of iterations through iterative training. And the server compares the prediction data of each iteration with the corresponding real data to obtain the prediction error of each iteration. And the server determines the prediction model corresponding to the iteration with the minimum error as a preset data prediction model.
In the embodiment of the invention, layered time series data are acquired; the hierarchical time series data is a plurality of groups of data corresponding to each hierarchical time series, wherein the sum of the data of the sub-hierarchy of each hierarchy in each hierarchy is equal to the data of the corresponding parent hierarchy; predicting the hierarchical time series data by using a preset data prediction model, and determining a prediction result in a preset time period after a plurality of historical time periods; the preset data prediction model is obtained by training prediction errors of a plurality of groups of training data in historical preset time periods and errors among all levels together in the layered time series data. Because the preset data prediction model is obtained by training based on prediction errors of a plurality of groups of training data in a historical time period and errors among all levels, the accuracy of the prediction errors and the errors among all levels are considered during training, and the data can be predicted more accurately by the trained preset data prediction model.
In some embodiments, referring to fig. 4, fig. 4 is an optional flowchart of the data prediction method provided in the embodiment of the present invention, and S101 shown in fig. 1 further includes implementation of S103 to S105, which will be described with reference to each step.
S103, carrying out standardization processing on multiple groups of data of the hierarchical time sequence data, and dividing the multiple groups of data subjected to standardization processing into a training set and a test set according to a preset historical time period.
In the embodiment of the invention, the server carries out standardization processing on a plurality of groups of data of the layered time sequence data, and divides the plurality of groups of data after the standardization processing into a training set and a test set according to a preset historical time period. Wherein, the training set includes: a plurality of sets of training data. The test set includes: and (6) multiple groups of test data.
In the embodiment of the invention, the server can delete redundant data in the multiple groups of data and fill the redundant data with average data of corresponding levels, or the server can fill blank data of each level in the multiple groups of data with the average data of the corresponding level to obtain the processed multiple groups of data. Since multiple sets of data correspond to multiple historical time periods. The server determines a preset historical time period in a plurality of historical time periods, and the server determines a plurality of groups of corresponding training data before the preset historical time period as training sets. And the server determines a plurality of groups of corresponding test data after the preset historical time period as a test set.
Wherein the training set is a data set used to train the initial predictive model. The test set is a data set used to determine a predetermined data prediction model.
In the embodiment of the invention, the server preprocesses a plurality of groups of data, deletes abnormal values and fills missing values, and standardizes the data. Then, the preprocessed data is taken at a certain time T0, and is divided into a training set (T is 1, …, T0) and a testing set (T is T0+1, …, T) according to the use purpose.
S104, calculating a prediction error of the training set and errors among all levels by using a loss function of the initial prediction model, and iteratively adjusting model parameters of the initial prediction model according to the prediction error and the errors among all levels until the training condition is met, so as to obtain a first prediction data set corresponding to the test set.
In the embodiment of the invention, the server calculates the prediction error of the training set and the error among all levels by using the loss function of the initial prediction model, and iteratively adjusts the model parameters of the initial prediction model according to the prediction error and the error among all levels until the training condition is met, so as to obtain the first prediction data set corresponding to the test set. Wherein the first set of prediction data comprises: multiple prediction data in an iterative process corresponding to each level of each historical time period of the test set.
In the embodiment of the invention, the server inputs a plurality of groups of training data in the training set into the initial prediction model. A second set of prediction data is obtained. The second set of prediction data comprises: prediction data for each of a plurality of tiers of historical time periods. And the server calculates prediction errors of the multiple groups of training data and errors among all levels by combining a loss function based on the second prediction data set and the multiple groups of training data. And the server solves the loss function to obtain the model parameters of the training. And the server adjusts the initial prediction model according to the model parameters to obtain a new prediction model. And the server continues to train multiple groups of training data through the new prediction model until the training conditions are met, and a final prediction model is obtained. Meanwhile, a first prediction data set corresponding to the test set in the iteration process is obtained.
Wherein, satisfying the training condition can be: reaching the preset training times or losing function value convergence.
And S105, comparing the plurality of groups of test data with the first prediction data set to determine a preset data prediction model.
In the embodiment of the invention, the server compares a plurality of groups of test data with the first prediction data set to determine the preset data prediction model.
In the embodiment of the present invention, the first prediction data set includes: multiple prediction data corresponding to multiple iterations of the test set. And the server compares the data of each level in each time period in the multiple groups of test data with the corresponding data in the predicted data each time to determine the error of each level, and then adds the errors of each level to obtain the error of the predicted data each time. And then a plurality of errors corresponding to the plurality of prediction data can be determined. And the server determines that the primary prediction data with the minimum error corresponds to the prediction model after iterative adjustment as a preset data prediction model.
For example, the server subtracts data of each level in each time period from corresponding data in the prediction data of a certain time in the plurality of sets of test data, and obtains an error of the data of each level corresponding to each time period. The server adds the errors of the data of each hierarchy of each time period, and the error corresponding to the predicted data of the time can be obtained.
In the embodiment of the invention, the server iteratively adjusts the prediction models through the prediction errors and the errors among all the layers to obtain a plurality of prediction models in the iterative process. And the server compares the plurality of groups of test data with the first prediction data set to determine a preset data model. Because the preset data prediction model is obtained by training based on prediction errors of a plurality of groups of training data in a historical time period and errors among all levels, the accuracy of the prediction errors and the errors among all levels are considered during training, and the data can be predicted more accurately by the trained preset data prediction model.
In some embodiments, referring to fig. 5, fig. 5 is an optional flowchart of the data prediction method provided in the embodiment of the present invention, and S104 shown in fig. 4 can also be implemented through S106 to S110, which will be described with reference to the steps.
And S106, inputting the multiple groups of training data into the initial prediction model to obtain a second prediction data set.
In the embodiment of the invention, the server inputs a plurality of groups of training data into the initial prediction model to obtain a second prediction data set of the first iteration in the iteration process. Wherein the second set of prediction data comprises: prediction data for each of a plurality of tiers of historical time periods.
In the embodiment of the invention, the server inputs a plurality of groups of training data into the initial prediction model to obtain a second prediction data set for the first training. And the server calculates the prediction error and the error between each layer according to the first second prediction data set and the loss function. And the server obtains model parameters according to the prediction errors and the errors among all the layers, and adjusts the initial prediction model to obtain a next updated prediction model. And the server inputs a plurality of groups of training data into the next updated prediction model again, and then executes the process to complete iteration.
And S107, calculating prediction errors and errors among all levels by combining a loss function based on the second prediction data set and the multiple groups of training data.
In the embodiment of the invention, the server calculates the prediction error and the error between each level by combining the loss function based on the second prediction data set and the multiple groups of training data. Wherein the loss function is a function corresponding to the initial prediction model.
In the embodiment of the invention, the server calculates the prediction errors corresponding to the multiple groups of training data in the multiple first time periods by combining the loss function based on the second prediction data set and the multiple groups of training data. The plurality of first time periods are time periods before the preset historical time period in the plurality of historical time periods. The prediction error characterizes an error between the prediction data and corresponding data in the plurality of sets of training data.
In an embodiment of the invention, the server calculates, in combination with the loss function, errors between respective levels within the second prediction data combinations for the plurality of second time periods based on the second prediction data set. The plurality of second time periods are time ends after the preset historical time period in the plurality of historical time periods. The inter-level errors characterize errors of data of a parent level and corresponding child level data sums in the second prediction data set.
And S108, carrying out gradient solution on the loss function to obtain model parameters in an iterative process, thereby obtaining an updated prediction model.
In the embodiment of the invention, the server carries out gradient solution on the loss function to obtain the model parameters in the iterative process, thereby obtaining the updated prediction model.
In the embodiment of the invention, the server solves the gradient of the loss function after each iteration in the iteration process to obtain the model parameter of each iteration in the iteration process. And the server adjusts the prediction model of this time through the model parameters of each time to obtain an updated prediction model.
And S109, training the multiple groups of training data continuously by using the updated prediction model until the training conditions are met, and obtaining a final prediction model, thereby obtaining multiple prediction models in the iterative process.
In the embodiment of the invention, the server continues to train multiple groups of training data by using the updated prediction model until the training conditions are met, and a final prediction model is obtained, so that multiple prediction models in an iterative process are obtained.
In the embodiment of the invention, the network structure of the prediction model transmits the prediction error and the error between each layer level back to the middle layer and the input layer by layer through the output layer, and the weight of each layer is corrected in a gradient descending mode. And after the weight values of all layers of the network structure of the prediction model are corrected, a new prediction model is obtained. And the network structure of the new prediction model can continue to train the training set until the training condition is met, and a plurality of prediction models in the iterative process are obtained.
S110, extracting prediction data of each hierarchy of each historical time period corresponding to the test set from each corresponding second prediction data set obtained by adopting a plurality of prediction models, and further obtaining a first prediction data set in an iterative process.
In the embodiment of the invention, the server extracts the prediction data of each hierarchy of each historical time period corresponding to the test set from each corresponding second prediction data set obtained by adopting a plurality of prediction models, and further obtains the first prediction data set in the iterative process.
In the embodiment of the invention, 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, so as to obtain a prediction data set corresponding to each iteration. The server combines the once-predicted data sets of each iteration to form a first predicted data set.
In the embodiment of the invention, the server inputs a plurality of groups of training data into the initial prediction model to obtain a second prediction data set. And the server calculates a prediction error and errors among all the layers by using the second prediction data set. The server iteratively adjusts the prediction models through the prediction errors and the errors among the layers, and a plurality of prediction models in the iterative process are obtained. Meanwhile, the server may extract the first prediction data set from the plurality of second prediction data sets in the iterative process to compare the first prediction data set with the second prediction data set. Because the preset data prediction model is obtained by training based on prediction errors of a plurality of groups of training data in a historical time period and errors among all levels, the accuracy of the prediction errors and the errors among all levels are considered during training, and the data can be predicted more accurately by the trained preset data prediction model.
In some embodiments, referring to fig. 6, fig. 6 is an optional flowchart of the data prediction method provided in the embodiment of the present invention, and S107 shown in fig. 5 may also be implemented through S111 to S112, which will be described with reference to each step.
And S111, calculating a prediction error based on the first prediction data in the second prediction data set and multiple groups of training data.
In the embodiment of the invention, the server calculates the prediction error based on the first prediction data in the second prediction data set and multiple groups of training data.
And the first prediction data is prediction data of each level in a plurality of first time periods in the second prediction data set. The plurality of first time periods are time periods before a preset history time period in the plurality of history time periods.
And S112, calculating errors among the layers based on the second prediction data in the second prediction data set.
In the embodiment of the invention, the server calculates the error between each layer based on the second prediction data in the second prediction data set.
And the second prediction data is prediction data of each hierarchy in a plurality of second time periods in a second prediction data set. The plurality of second time periods are time periods after a preset history time period among the plurality of history time periods.
In the embodiment of the invention, a server constructs a hierarchical time series prediction model based on deep AR. The DeepAR model is a time sequence prediction model based on a recurrent neural network, can be used for general time sequence prediction, but cannot be directly used for hierarchical time prediction. Therefore, for the task of predicting the hierarchical time series, the improved loss function (1) for predicting the hierarchical time series designed by the invention is as follows:
Figure BDA0003215973120000151
wherein the content of the first and second substances,
Figure BDA0003215973120000152
in order to predict the loss of error,
Figure BDA0003215973120000153
for the loss function of the DeepAR model, without loss of generality, let l (x, y) be (x-y)2
Figure BDA0003215973120000154
Is the inter-level harmonic error loss, where λ is the harmonic error penalty hyperparameter. C is a set of constraints derived from the hierarchy.
Figure BDA0003215973120000155
Is the predicted value of the "parent" time series in the constraint c at time t,
Figure BDA0003215973120000156
is the predicted value of the time sequence of the leaf nodes in the constraint condition c at the time t, and J (c) is the number of the leaf nodes. As an example of hierarchical time series data structured as shown in fig. 3, the hierarchical structure satisfies the constraint of C ═ y1=y2+y3,y2=y4+y5,y3=y6+y7}。
Wherein the content of the first and second substances,
Figure BDA0003215973120000157
is a predicted value.
Figure BDA0003215973120000158
Is composed of
Figure BDA0003215973120000159
Corresponding training data. n is the number of each level, t0Is the number of the plurality of first time periods. T is the number of the plurality of second time periods.
In some embodiments, referring to fig. 7, fig. 7 is an optional flowchart of the data prediction method provided in the embodiment of the present invention, and S111 to S112 shown in fig. 6 can also be implemented through S113 to S115, which will be described with reference to each step.
And S113, calculating the square sum of the difference between the first prediction data in the same first time period and the training data of the corresponding hierarchy, further obtaining the first sum of each hierarchy in the same first time period, and adding the first sums corresponding to the first time periods to obtain a prediction error.
In the embodiment of the invention, the server calculates the square sum of the difference between the first prediction data in the same first time period and the training data of the corresponding level, and further obtains the first sum of each level in the same first time period. And the server adds the first sums corresponding to the first time periods to obtain a prediction error.
Illustratively, the plurality of first time periods includes: two first time periods. Each hierarchy includes: a parent level (primary agent) and two corresponding child levels (two secondary agents). The server calculates the square sum of the differences between the data of the parent level and the corresponding prediction data in the first time period, calculates the square sum of the differences between the data of the two child levels and the corresponding prediction data, and adds the square sum of the corresponding differences of the parent level and the square sums of the differences of the two child levels to obtain a first sum corresponding to the first time period. Similarly, the server calculates a first sum corresponding to the second time period by using the same method. The server adds the two first sums to obtain the prediction error.
S114, in the same second time period, the sum of squares of the differences between the predicted data of each parent level of each layer in the second predicted data and the corresponding sum of predicted data of each child level is calculated, and the second sum is obtained by adding the sums of squares of the plurality of second time periods.
In the embodiment of the present invention, the server calculates the sum of squares of differences between the predicted data of each parent level of each layer in the second predicted data in the same second time period and the corresponding sum of the predicted data of each child level, and adds the sums of squares of a plurality of second time periods to obtain a second sum.
Illustratively, the plurality of second time periods includes: two second time periods. Each hierarchy includes: a parent level (primary agent) and two corresponding child levels (two secondary agents). The server calculates the square sum of the differences between the data of the parent level and the corresponding predicted data sums of the sub-level in the first second time period. Similarly, the server calculates the square sum corresponding to the second time period in the same way. The server adds the two squared sums to obtain a second sum.
And S115, multiplying the plurality of second sums by the harmonic error penalty term hyper-parameter to obtain the errors among the layers.
In the embodiment of the invention, the server obtains the errors among all the levels by using the plurality of second sums and the harmonic error penalty term hyper-parameter.
The harmonic error penalty term hyperparameter can be any positive number.
Compared with the common time series prediction, the hierarchical time series prediction essentially adds the consistency constraint condition among the hierarchies to the final prediction result, namely:
Figure BDA0003215973120000171
Figure BDA0003215973120000172
however, it is very difficult to directly solve such a large-scale optimization problem, and after adding the constraint condition as a penalty term to the loss function, we can solve the formula (1) by a random gradient descent method or the like, and for any given difference penalty term, the over-parameter λ is exceeded, and the inconsistency of prediction results between levels decreases with the decrease of the loss function value in the training process.
For hierarchical time series prediction, future hierarchical timing must satisfy inter-hierarchical coherence. And by adding a penalty term for reconciling the error loss, from the process of parameter iteration, the network parameters equivalent to the requirement of deep ar can take prediction deviation and hierarchy deviation into account in the optimization process. From a result point of view, this is equivalent to a lower bound on the optimization test set error. Taking the hierarchical timing diagram in fig. 2 as an example, according to the cauchy inequality:
Figure BDA0003215973120000173
therefore, it can be seen that the hierarchical structure deviation term in the loss function is substantially a lower bound of the prediction error, and it is intuitively understood that although the prediction result satisfying the inter-hierarchy consistency is not necessarily guaranteed to be the highest in prediction accuracy, since the real data in the future must satisfy the consistency, if the error between the hierarchies of the prediction result is large, the prediction accuracy is not necessarily high, and therefore, adding the term to the loss function can help to improve the prediction performance of the hierarchical time series prediction.
In the embodiment of the invention, the server respectively calculates the prediction error and the error between each hierarchy level through the first prediction data and the second prediction data in the second prediction data set. In the process of calculating the error by combining the loss function, the server considers the error among all the layers, so that the prediction of the data by the prediction model after the model parameter adjustment of the loss function is more accurate.
In some embodiments, referring to fig. 8, fig. 8 is an optional flowchart of the data prediction method provided in the embodiment of the present invention, and S103 shown in fig. 3 may be implemented by S116 to S118, which will be described with reference to the steps.
And S116, deleting abnormal values of all levels in the multiple groups of data, and filling the average data of the levels corresponding to the abnormal values.
In the embodiment of the invention, the server deletes abnormal values of all levels in the multiple groups of data and fills the average data of the levels corresponding to the abnormal values.
Wherein the average data is an average value of data of a plurality of levels of a plurality of historical time periods of the level corresponding to the abnormal value.
And S117, filling blank data corresponding to each hierarchy in the multiple groups of data by using average data corresponding to the hierarchy with blank data, and further obtaining multiple groups of processed data corresponding to each hierarchy time sequence.
In the embodiment of the invention, the server fills the blank data corresponding to each hierarchy in the multiple groups of data by using the average data corresponding to the hierarchy with the blank data, so as to obtain multiple groups of processed data corresponding to each hierarchy time sequence.
S118, determining a preset historical time period in the multiple historical time periods, combining multiple groups of first processed data corresponding to the multiple first time periods before the preset historical time period into a training set, and combining multiple groups of second processed data corresponding to the multiple second time periods after the preset historical time period into a test set.
In the embodiment of the invention, the server determines a preset historical time period from a plurality of historical time periods, combines a plurality of groups of first processed data corresponding to a plurality of first time periods before the preset historical time period into a training set, and combines a plurality of groups of second processed data corresponding to a plurality of second time periods after the preset historical time period into a testing set.
For example, the plurality of historical time periods may include: 12 time periods corresponding to months 1 to 12. The server may determine that 9 months is a preset historical period of time. In the case where the server determines that 9 months is the preset historical time period, the plurality of first time periods are 8 time periods corresponding to 1-8 months, and the plurality of second time periods may also be 3 time periods corresponding to 10-12 months.
In the embodiment of the invention, the server carries out standardization processing on a plurality of groups of data, deletes abnormal values and fills blank data, so that the data structure of the plurality of groups of data is more perfect, and the model training is facilitated.
In some embodiments, referring to fig. 8, fig. 8 is an optional flowchart of the data prediction method provided in the embodiment of the present invention, and S105 shown in fig. 3 may be implemented through S119 to S122, which will be described with reference to each step.
S119, comparing the multiple groups of test data with multiple times of predicted data in the first predicted data set respectively, and determining multiple times of comparison errors corresponding to the multiple times of predicted data.
In the embodiment of the invention, the server respectively compares the multiple groups of test data with the multiple times of predicted data in the first predicted data set to determine the multiple times of comparison errors corresponding to the multiple times of predicted data.
In the embodiment of the invention, the server compares the test data of each level of each time period in the multiple groups of test data with the corresponding prediction data in the first prediction data set. And the server determines the error corresponding to the test data of each time period in each hierarchy. The server adds the errors corresponding to the test data of each hierarchy of each time period to obtain the error corresponding to each time period, namely the error of each group of test data. And the server adds the errors corresponding to each group of test data to obtain the error corresponding to the predicted data. Further, a multiple comparison error of multiple prediction data can be obtained.
And S120, determining a target comparison error within a preset error range from the multiple comparison errors.
In the embodiment of the invention, the server determines the target comparison error within the preset error range from the multiple comparison errors.
And S121, determining the target iteration times corresponding to the target secondary prediction data corresponding to the target comparison error.
In the embodiment of the invention, the server determines the target iteration times corresponding to the target secondary prediction data corresponding to the target comparison error.
And S122, determining a prediction data prediction model corresponding to the target iteration times in the plurality of prediction models.
In the embodiment of the invention, a plurality of prediction models are formed in the iteration process. And the server determines a preset data prediction model correspondingly formed by the target iteration times in the plurality of prediction models.
In the embodiment of the invention, because a plurality of prediction models are formed in the iteration process, the server determines the preset data prediction model corresponding to the target iteration with the minimum error of a plurality of groups of test data, and because the preset data prediction model has higher prediction precision on the test set, the layered time series data is processed by the preset data prediction model, and a prediction result with higher prediction precision can be obtained.
In some embodiments, referring to fig. 9, fig. 9 is an alternative flow chart of a data prediction method provided in an embodiment of the present invention, and will be described with reference to steps.
And S123, acquiring multiple groups of logistics cargo volume data corresponding to multiple historical time periods.
In the embodiment of the invention, the server acquires a plurality of groups of logistics cargo volume data corresponding to a plurality of historical time periods.
Wherein, multiunit commodity circulation freight volume data include: the shipment data and the hierarchical relation of the whole country, each region and each province.
And S124, processing the multiple groups of logistics cargo volume data by using a preset data prediction model to obtain predicted logistics cargo volume data of a preset time period after a plurality of historical time periods.
In the embodiment of the invention, the server processes a plurality of groups of logistics cargo volume data by using the preset data prediction model to obtain the predicted logistics cargo volume data of the preset time period after a plurality of historical time periods.
In the embodiment of the invention, the server processes a plurality of groups of logistics cargo volume data by using the preset data prediction model, and the preset data prediction model is obtained by training a plurality of groups of training data prediction errors in a historical preset time period and errors among all levels together. And then, a plurality of groups of logistics cargo volume data are predicted through the preset data prediction model, and a prediction result with higher precision can be obtained.
Fig. 10 is a schematic structural diagram of a device 600 for predicting a logistics cargo amount according to an embodiment of the present invention, for implementing the data prediction method provided in fig. 9.
An embodiment of the present invention provides a device 600 for predicting a logistics cargo amount, 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 configured to acquire a hierarchical relationship between the historical time-series data of the logistics cargo volume and the time sequence. Such as the shipment data and the hierarchical relationship of the whole country, each region and each province. The data obtaining module 601 is configured to execute S123.
The data preprocessing module 602 is configured to preprocess the data, remove the outliers and the missing values, and normalize the data. The preprocessed data is then divided into training sets and test sets.
And the target prediction model training module 603 is configured to train the initial network model by using the historical time sequence data to obtain a target prediction model of the time sequence data.
And the data prediction module 604 is configured to predict data of the time series data in a future time period by using the target prediction model to obtain a prediction result, and store and display the prediction result.
In some embodiments, referring to fig. 11, fig. 11 is an optional flowchart of a data prediction method provided in an embodiment of the present invention, and will be described with reference to steps.
S201, collecting hierarchical time sequence data to be predicted.
Illustratively, in conjunction with fig. 12, the data obtaining module 701 in the data prediction apparatus 700 is configured to obtain a hierarchical relationship between the historical time-series data and the time sequence.
S202, preprocessing data, and removing abnormal values and filling missing values; and (3) segmenting data, and dividing a training set and a test set.
Illustratively, the data preprocessing module 702 in the data prediction apparatus 700 is configured to preprocess the historical time-series data, remove abnormal values and missing values, and normalize the data. The preprocessed data is then divided into training sets and test sets.
S203, constructing a DeepAR time series prediction model.
And S204, inputting a training set.
And S205, setting a layering loss item hyperparameter.
And S206, updating the parameters of the DeepaR model by adopting an Adam optimization algorithm with a self-adaptive learning rate.
And S207, judging whether the training times reach the preset training times or not.
Illustratively, the target prediction model training module 703 in the data prediction apparatus 700 is configured to train the initial network model by using historical time series data to obtain a target prediction model of the time series data. I.e. the final model.
And S208, taking the final model and outputting a future-period prediction result.
Illustratively, the data prediction module 704 in the data prediction apparatus 700 is configured to predict data of the time-series data in a future time period by using a target prediction model (final model) to obtain a prediction result, and store and display the prediction result.
Because the DeepAR time series prediction model is constructed based on prediction errors of a plurality of groups of training data in the layered time series data in the historical time period and errors among the layers, the accuracy of the prediction errors and the errors among the layers are considered when the DeepAR time series prediction model is trained, and the final model obtained by training can predict the data more accurately.
For example, a data prediction apparatus 700 is further provided in an embodiment of the present invention, for executing the data prediction method provided in fig. 11, please refer to fig. 12, which is a schematic structural diagram of the data prediction apparatus provided in the embodiment of the present invention.
An embodiment of the present invention provides a data prediction apparatus 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 obtaining module 701 is configured to obtain a hierarchical relationship between the historical time series data and the time sequence.
And the data preprocessing module 702 is configured to preprocess the historical time series data, remove abnormal values and missing values, fill in the abnormal values and normalize the data. The preprocessed data is then divided into training sets and test sets. The module details are in S202 of the above prediction method flow.
And the target prediction model training module 703 is configured to train the initial network model by using the historical time sequence data to obtain a target prediction model of the time sequence data. The module details are in S203 to S207 of the above prediction method flow.
And the data prediction module 704 is used for predicting the data of the time sequence data in the future time period by using the target prediction model to obtain a prediction result, and storing and displaying the prediction result. The module details are at S208 in the above prediction method flow.
Please refer to fig. 13, which is a second schematic structural diagram of a data prediction apparatus according to an embodiment of the present invention.
An embodiment of the present invention further provides a data prediction apparatus 800, including: a data acquisition unit 803 and a prediction unit 804.
A data acquisition unit 803 for acquiring layered time-series data; the hierarchical time series data is a plurality of groups of data corresponding to each hierarchical time series, wherein the sum of the data of the sub-hierarchy of each hierarchy in each hierarchy is equal to the data of the corresponding parent hierarchy;
the prediction unit 804 is configured to predict the hierarchical time series data by using a preset data prediction model, and determine a prediction result in a preset time period after a plurality of historical time periods; wherein the content of the first and second substances,
the preset data prediction model is obtained by training a plurality of groups of training data prediction errors in a historical preset time period in the layered time series data and errors among all layers together.
In the embodiment of the present invention, the data prediction apparatus 800 is configured to perform normalization processing on multiple sets of data of the hierarchical time series data, and divide the multiple sets of data after the normalization processing into a training set and a test set according to a preset historical time period; the training set comprises: a plurality of sets of training data; the test set includes: a plurality of sets of test data; calculating a prediction error of a training set and errors among all levels by using a loss function of an initial prediction model, and iteratively adjusting model parameters of the initial prediction model according to the prediction error and the errors among all levels until training conditions are met, so as to obtain a first prediction data set corresponding to a test set; the first set of prediction data comprises: multiple times of prediction data in the iteration process of each level corresponding to each historical time period of the test set; and comparing the plurality of groups of test data with the first prediction data set to determine a preset data prediction model.
In the embodiment of the present invention, the data prediction apparatus 800 is configured to input multiple sets of training data into the initial prediction model to obtain a second prediction data set; the second set of prediction data comprises: prediction data for each hierarchy of a plurality of historical time periods; calculating a prediction error and errors among all levels by combining a loss function based on the second prediction data set and the multiple groups of training data; carrying out gradient solving on the loss function to obtain model parameters in an iterative process so as to obtain an updated prediction model; continuously training a plurality of groups of training data by using the updated prediction model until the training conditions are met, and obtaining a final prediction model, thereby obtaining a plurality of prediction models in the iterative process; and extracting the prediction data of each hierarchy of each historical time period corresponding to the test set from each corresponding second prediction data set obtained by adopting a plurality of prediction models, and further obtaining a first prediction data set in the iterative process.
In the embodiment of the present invention, the data prediction apparatus 800 is configured to calculate a 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 prediction data of each level in a plurality of first time periods in the second prediction data set; the plurality of first time periods are time periods before a preset historical time period in the plurality of historical time periods; calculating errors between the levels based on second prediction data in a second prediction data set; the second prediction data is prediction data of each hierarchy in a plurality of second time periods in a second prediction data set; the plurality of second time periods are time periods after a preset history time period among the plurality of history time periods.
In this embodiment of the present invention, the data prediction apparatus 800 is configured to calculate a sum of squares of differences between first prediction data in the same first time period and training data of corresponding levels, further obtain a first sum of each level in the same first time period, and add a plurality of first sums corresponding to a plurality of first time periods to obtain a prediction error.
In this embodiment of the present invention, the data prediction apparatus 800 is configured to calculate a sum of squares of differences between prediction data of each parent level of each layer in second prediction data in the same second time period and corresponding prediction data sums of each child level, and add a plurality of sums of squares of a plurality of second time periods to obtain a second sum; and multiplying the second sums by the harmonic error penalty term hyperparameter to obtain the error between each hierarchy.
In the embodiment of the present invention, the data prediction apparatus 800 is configured to compare multiple groups of test data with multiple prediction data in the first prediction data set, respectively, and determine multiple comparison errors corresponding to the multiple prediction data; determining a target comparison error within a preset error range from the multiple comparison errors; determining a target iteration number corresponding to target secondary prediction data corresponding to the target comparison error; and determining a prediction data prediction model corresponding to the target iteration in the plurality of prediction models.
In the embodiment of the present invention, the plurality of sets of training data include: a plurality of sets of first processed data; the sets of test data include: a plurality of sets of second processed data; the data prediction device 800 is used for deleting abnormal values of each hierarchy in the plurality of groups of data and filling average data of the corresponding hierarchy with the abnormal values; filling blank data corresponding to each hierarchy in a plurality of groups of data by using average data corresponding to the hierarchy with the blank data, and further obtaining a plurality of groups of processed data corresponding to each hierarchy time sequence; determining a preset historical time period in the plurality of historical time periods, combining a plurality of groups of first processed data corresponding to a plurality of first time periods before the preset historical time period into a training set, and combining a plurality of groups of second processed data corresponding to a plurality of second time periods after the preset historical time period into a test set.
In this embodiment of the present invention, the data obtaining unit 803 in the data prediction apparatus 800 is configured to obtain multiple sets of physical distribution quantity data corresponding to multiple historical time periods; the prediction unit 804 in the data prediction apparatus 800 is configured to process multiple sets of logistics cargo volume data by using a preset data prediction model, so as to obtain predicted logistics cargo volume data of a preset time period after multiple historical time periods.
In the embodiment of the present invention, the layered time series data is acquired by the data acquisition unit 803; the hierarchical time series data is a plurality of groups of data corresponding to each hierarchical time series, wherein the sum of the data of the sub-hierarchy of each hierarchy in each hierarchy is equal to the data of the corresponding parent hierarchy; predicting the hierarchical time series data by using a preset data prediction model through a prediction unit 804 to determine a prediction result in a preset time period after a plurality of historical time periods; the preset data prediction model is obtained by training prediction errors of a plurality of groups of training data in historical preset time periods and errors among all levels together in the layered time series data. Because the preset data prediction model is obtained by training based on prediction errors of a plurality of groups of training data in a historical time period and errors among all levels, the accuracy of the prediction errors and the errors among all levels are considered during training, and the data can be predicted more accurately by the trained preset data prediction model.
It should be noted that, in the embodiment of the present invention, if the data prediction method is implemented in the form of a software functional module and sold or used as a standalone product, the data prediction method may also be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the embodiments of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a data prediction apparatus (which may be a personal computer or the like) to perform all or part of the methods described in the embodiments of the present invention. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read Only Memory (ROM), a magnetic disk, or an optical disk. Thus, embodiments of the invention are not limited to any specific combination of hardware and software.
Correspondingly, the embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, implements the steps of the above-mentioned method.
Correspondingly, the embodiment of the present invention provides a data prediction apparatus, which includes a memory 802 and a processor 801, where the memory 802 stores a computer program operable on the processor 801, and the processor 801 executes the computer program to implement the steps in the above method.
Here, it should be noted that: the above description of the storage medium and apparatus embodiments is similar to the description of the method embodiments above, with similar beneficial effects as the method embodiments. For technical details not disclosed in the embodiments of the storage medium and the apparatus according to the invention, reference is made to the description of the embodiments of the method according to the invention.
It should be noted that fig. 14 is a schematic diagram of a hardware entity of a data prediction apparatus according to an embodiment of the present invention, as shown in fig. 14, the hardware entity of the data prediction apparatus 800 includes: a processor 801 and a memory 802, wherein;
the processor 801 generally controls the overall operation of the data prediction apparatus 800.
The Memory 802 is configured to store instructions and applications executable by the processor 801, and may also buffer data (e.g., image data, audio data, voice communication data, and video communication data) to be processed or already processed by each module in the processor 801 and the data prediction apparatus 800, and may be implemented by a FLASH Memory (FLASH) or a Random Access Memory (RAM).
It should be appreciated that reference throughout this specification to "one embodiment" or "an embodiment" means that a particular feature, structure or characteristic described in connection with the embodiment is included in at least one embodiment of the present invention. Thus, the appearances of the phrases "in one embodiment" or "in an embodiment" in various places throughout this specification are not necessarily all 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 invention, the sequence numbers of the above-mentioned processes do not mean the execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention. The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus and method may be implemented in other ways. The above-described device embodiments are merely illustrative, for example, the division of the unit is only a logical functional division, and there may be other division ways in actual implementation, such as: multiple units or components may be combined, or may be integrated into another system, or some features may be omitted, or not implemented. In addition, the coupling, direct coupling or communication connection between the components shown or discussed may be through some interfaces, and the indirect coupling or communication connection between the devices or units may be electrical, mechanical or other forms.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units; can be located in one place or distributed on a plurality of network units; some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, all the functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may be separately regarded as one unit, or two or more units may be integrated into one unit; the integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional unit.
Those of ordinary skill in the art will understand that: all or part of the steps for realizing the method embodiments can be completed by hardware related to program instructions, the program can be stored in a computer readable storage medium, and the program executes the steps comprising the method embodiments when executed; and the aforementioned storage medium includes: various media capable of storing program codes, such as a removable storage device, a Read Only Memory (ROM), a magnetic disk, and an optical disk.
Alternatively, the integrated unit of the present invention may be stored in a computer-readable storage medium if it is implemented in the form of a software functional module and sold or used as a separate product. Based on such understanding, the technical solutions of the embodiments of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the methods according to the embodiments of the present invention. And the aforementioned storage medium includes: various media that can store program codes, such as a removable storage device, a ROM, a magnetic disk, or an optical disk.
The above description is only an embodiment of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of changes or substitutions within the technical scope of the present invention, and all such changes or substitutions are included in the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the appended claims.

Claims (12)

1. A method of data prediction, comprising:
acquiring layered time series data; the hierarchical time series data is a plurality of groups of data corresponding to each hierarchical time series, wherein the sum of the data of the sub-hierarchy of each hierarchy in each hierarchy is equal to the data of the corresponding parent hierarchy;
predicting the layered time series data by using a preset data prediction model, and determining a prediction result in a preset time period after a plurality of historical time periods; wherein the content of the first and second substances,
the preset data prediction model is obtained by training prediction errors of a plurality of groups of training data in historical preset time periods and errors among all levels in the layered time series data together.
2. The data prediction method of claim 1, wherein the predicting the hierarchical time series data by using a preset data prediction model is performed before determining a prediction result in a preset time period after a plurality of historical time periods and after acquiring the hierarchical time series data, the method further comprises:
carrying out standardization processing on a plurality of groups of data of the layered time series data, and dividing the plurality of groups of data after the standardization processing into a training set and a test set according to a preset historical time period; the training set includes: a plurality of sets of training data; the test set includes: a plurality of sets of test data;
calculating a prediction error of the training set and errors among all levels by using a loss function of an initial prediction model, and iteratively adjusting model parameters of the initial prediction model according to the prediction error and the errors among all levels until a training condition is met, so as to obtain a first prediction data set corresponding to the test set; the first set of prediction data comprises: multiple prediction data in an iterative process corresponding to each level of each historical time period of the test set;
and comparing the plurality of groups of test data with the first prediction data set to determine the preset data prediction model.
3. The data prediction method of claim 2, wherein the calculating a prediction error of the training set and an error between each hierarchy by using a loss function of an initial prediction model, and iteratively adjusting model parameters of the initial prediction model according to the prediction error and the error between each hierarchy, until a training condition is satisfied, to obtain a first prediction data set corresponding to the test set comprises:
inputting the multiple groups of training data into the initial prediction model to obtain a second prediction data set; the second set of prediction data comprises: prediction data for each level of the plurality of historical time periods;
calculating the prediction error and the error between the respective levels in conjunction with the loss function based on the second set of prediction data and the plurality of sets of training data;
carrying out gradient solving on the loss function to obtain model parameters in an iterative process so as to obtain an updated prediction model;
continuing to train the multiple groups of training data by using the updated prediction model until the training conditions are met, and obtaining a final prediction model so as to obtain multiple prediction models in an iterative process;
and extracting the prediction data of each hierarchy corresponding to each historical time period of the test set from each corresponding second prediction data set obtained by adopting the plurality of prediction models, and further obtaining the first prediction data set in the iterative process.
4. The data prediction method of claim 3, wherein the calculating the prediction error and the error between each level in combination with the loss function based on the second set of prediction data and the plurality of sets of training data comprises:
calculating the prediction error based on first prediction data in the second prediction data set and the plurality of sets of training data; the first prediction data is prediction data of each level in a plurality of first time periods in the second prediction data set; the plurality of first time periods are time periods before the preset historical time period in the plurality of historical time periods;
calculating errors between the respective levels based on second prediction data in the second set of prediction data; the second prediction data is prediction data of each level in a plurality of second time periods in the second prediction data set; the plurality of second time periods are time periods after the preset historical time period in the plurality of historical time periods.
5. The method of 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 comprises:
and calculating the square sum of the difference between the first prediction data in the same first time period and the training data of the corresponding hierarchy to further obtain a first sum of each hierarchy in the same first time period, and adding the first sums corresponding to the first time periods to obtain the prediction error.
6. The method of claim 4, wherein said calculating the error between each level based on the second prediction data in the second prediction data set comprises:
calculating the square sum of the difference between the prediction data of each parent level of each layer in the second prediction data in the same second time period and the corresponding prediction data sum of each sub-level, and adding the square sums of the second time periods to obtain a second sum;
and multiplying the plurality of second sums by the harmonic error penalty term hyperparameter to obtain the errors among all the levels.
7. The data prediction method according to any one of claims 3 to 6, wherein the determining the predetermined data prediction model by comparing the plurality of sets of test data with the first prediction data set comprises:
comparing the multiple groups of test data with multiple times of predicted data in the first predicted data set respectively to determine multiple times of comparison errors corresponding to the multiple times of predicted data;
determining a target comparison error within a preset error range from the multiple comparison errors;
determining a target iteration number corresponding to the target secondary prediction data corresponding to the target comparison error;
determining the prediction data prediction model corresponding to the target iteration in the plurality of prediction models.
8. The data prediction method according to any one of claims 2 to 7, wherein the plurality of sets of training data includes: a plurality of sets of first processed data; the plurality of sets of test data includes: a plurality of sets of second processed data;
the step of standardizing a plurality of groups of data of the layered time series data and dividing the plurality of groups of standardized data into a training set and a testing set according to a preset historical time period comprises the following steps:
deleting abnormal values of all levels in the multiple groups of data, and filling average data of the levels corresponding to the abnormal values;
filling blank data corresponding to each hierarchy in the multiple groups of data by using average data corresponding to the hierarchy with blank data, and further obtaining multiple groups of processed data corresponding to each hierarchy time sequence;
determining a preset historical time period in the plurality of historical time periods, combining the plurality of groups of first processed data corresponding to a plurality of first time periods before the preset historical time period into a training set, and combining the plurality of groups of second processed data corresponding to a plurality of second time periods after the preset historical time period into a test set.
9. The data prediction method according to any one of claims 1 to 8, characterized in that the method further comprises:
acquiring a plurality of groups of logistics cargo volume data corresponding to the plurality of historical time periods;
and processing the multiple groups of logistics cargo volume data by using the preset data prediction model to obtain predicted logistics cargo volume data of a preset time period after the multiple historical time periods.
10. A data prediction apparatus, comprising:
a data acquisition unit for acquiring layered time-series data; the hierarchical time series data is a plurality of groups of data corresponding to each hierarchical time series, wherein the sum of the data of the sub-hierarchy of each hierarchy in each hierarchy is equal to the data of the corresponding parent hierarchy;
the prediction unit is used for predicting the layered time series data by using a preset data prediction model and determining a prediction result in a preset time period after a plurality of historical time periods; wherein the content of the first and second substances,
the preset data prediction model is obtained by training a plurality of groups of training data prediction errors in a historical preset time period in the layered time series data and errors among all levels together.
11. A data prediction device comprising a memory and a processor, the memory storing a computer program operable on the processor, the processor implementing the steps of the method of any one of claims 1 to 9 when executing the program.
12. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 9.
CN202110943383.6A 2021-08-17 2021-08-17 Data prediction method, device and storage medium Pending CN113656691A (en)

Priority Applications (2)

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

Applications Claiming Priority (1)

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

Publications (1)

Publication Number Publication Date
CN113656691A true CN113656691A (en) 2021-11-16

Family

ID=78479949

Family Applications (1)

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

Country Status (2)

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

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2023020257A1 (en) * 2021-08-17 2023-02-23 北京沃东天骏信息技术有限公司 Data prediction method and apparatus, and storage medium

Families Citing this family (1)

* 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

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110263380B (en) * 2019-05-23 2020-11-24 东华大学 Spinning process cascade modeling subsection interval parameter configuration method
CN111915083A (en) * 2020-08-03 2020-11-10 国网山东省电力公司电力科学研究院 Wind power prediction method and prediction system based on time hierarchical combination
CN112348271B (en) * 2020-11-12 2024-01-30 华北电力大学 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 (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2023020257A1 (en) * 2021-08-17 2023-02-23 北京沃东天骏信息技术有限公司 Data prediction method and apparatus, and storage medium

Also Published As

Publication number Publication date
WO2023020257A1 (en) 2023-02-23

Similar Documents

Publication Publication Date Title
US20200302524A1 (en) Systems and methods for model fairness
Kolassa Combining exponential smoothing forecasts using Akaike weights
Sentas et al. Categorical missing data imputation for software cost estimation by multinomial logistic regression
Guan et al. An adaptive neuro-fuzzy inference system based approach to real estate property assessment
US8346516B2 (en) Predictive modeling
JPWO2015040790A1 (en) Payout amount prediction device, payout amount prediction method, program, and payout amount prediction system
WO2023020257A1 (en) Data prediction method and apparatus, and storage medium
US20200226504A1 (en) Method and system for hierarchical forecasting
CN110046981B (en) Credit evaluation method, device and storage medium
CN109767032A (en) A kind of business finance operation digital management optimization system based on data analysis
Yilmaz et al. Synthetic demand data generation for individual electricity consumers: Generative Adversarial Networks (GANs)
Mahbub et al. A neural approach to product demand forecasting
Melendez et al. Tourism demand modeling and forecasting for El Salvador
Estes et al. Smart predict-then-optimize for two-stage linear programs with side information
CN115630979A (en) Day-ahead electricity price prediction method and device, storage medium and computer equipment
Hanapi et al. Developed a hybrid sliding window and GARCH model for forecasting of crude palm oil prices in Malaysia
CN114282657A (en) Market data long-term prediction model training method, device, equipment and storage medium
CN114519073A (en) Product configuration recommendation method and system based on atlas relation mining
Cui et al. Probabilistic model for online 3D printing service evaluation
CN112232945A (en) Method and device for determining personal customer credit
Lv et al. GA‐based feature selection method for oversized data analysis in digital economy
Sarvi Predicting product sales in retail store chain
CN113240359B (en) Demand prediction method for coping with external major changes
CN117252665B (en) Service recommendation method and device, electronic equipment and storage medium
Frischknecht et al. Incorporating prior information to overcome complete separation problems in discrete choice model estimation

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination