Disclosure of Invention
In order to solve the problem of accurate prediction of the quantity of delivered goods in the technical field of express delivery, the application provides a quantity prediction method, a device, equipment and a storage medium based on model fusion.
The technical scheme of the invention is as follows:
the invention provides a component prediction fusion model generation method, which comprises the following steps:
acquiring historical data of the quantity, preprocessing the historical data and screening out target quantity data information;
constructing various prediction models according to the target quantity data information, and fusing various prediction models by using any one of various model fusion methods to form various quantity prediction fusion models for predicting the quantity of the express delivery;
respectively predicting the component by adopting various component prediction fusion models, calculating error information of component prediction results of the various component prediction fusion models according to actual component data information, and screening the component prediction fusion model with the minimum error as a target component prediction fusion model;
and carrying out component quantity prediction according to the screened target component quantity prediction fusion model.
Further preferably, the prediction model includes multiple ones of a qualitative prediction model, a time series prediction model, a panel data prediction model, a wavelet analysis prediction model, and an LSTM prediction model, and the model fusion method includes multiple ones of a voting method, an averaging method, a Bagging method, and a Boosting method.
Further preferably, the predicting of the quantity by using the various quantity prediction fusion models includes predicting the number of the quantities and predicting a prediction index of the quantities.
Further preferably, the prediction index includes recent factors, current factors and cycle factors, wherein the recent factors include a recent piece amount, a recent piece amount smooth value and a recent week average value, the current factors include a current piece amount index in a historical year, and the cycle factors include a piece amount on the same day in the historical week, a piece amount on the same day in the historical month, a piece amount on the same day in the historical quarter and a piece amount on the same day in the historical year.
Further preferably, the calculating of the error information of the component prediction results of the various component prediction fusion models according to the actual component data information specifically includes calculating any one or more error information of a component prediction error value, a component prediction error rate, a model error, a measurement error, a truncation error and a rounding error.
Further preferably, the calculation process of the component prediction error value and the component prediction error rate is as follows:
calculating a component quantity prediction error value according to the number of the actual component quantities and the number of the predicted component quantities;
and performing multiple times of component prediction by using the component prediction fusion model, and calculating a component prediction error rate according to the numerical values of the multiple times of component prediction.
Further preferably, the preprocessing the historical data includes: cleaning historical data, replacing null data and processing abnormal data.
The invention also provides a part prediction device based on model fusion, which comprises:
the data processing module is used for acquiring historical data of the quantity, preprocessing the historical data and screening out target quantity data information;
the model fusion creation module is used for constructing various prediction models according to the target quantity data information and fusing various prediction models by using any one of various model fusion methods so as to form various quantity prediction fusion models for predicting the express quantity;
the model fusion screening module is used for respectively predicting the component by adopting various component prediction fusion models, calculating error information of component prediction results of the various component prediction fusion models according to actual component data information, and screening the component prediction fusion model with the minimum error as a target component prediction fusion model;
and the component prediction module is used for predicting the components based on the target component prediction fusion model.
The invention also provides a model fusion-based component prediction device, which comprises a processor and a memory, wherein at least one instruction, at least one program, a code set or an instruction set is stored in the memory, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by the processor to realize the component prediction method.
The present invention also provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the above-described component prediction method.
According to the quantity prediction method, the device, the terminal equipment and the storage medium of the embodiment, various prediction models are fused by adopting a model fusion method to form a quantity prediction fusion model, the optimal quantity prediction fusion model is obtained by screening to perform optimal prediction on the quantity of the express delivery, and compared with the method that the quantity of the express delivery is mainly predicted by adopting manual prediction or a rough method in the current logistics industry, the quantity prediction fusion model provided by the application can greatly improve the accuracy of quantity prediction, and further provides a powerful data basis for the orderly development of logistics work, for example, the preparation of workers and vehicles can be made in advance based on the predicted quantity, so that the effects of reducing cost and reducing loss are achieved.
Detailed Description
The present invention will be described in further detail with reference to the following detailed description and accompanying drawings.
The first embodiment is as follows:
the present embodiment provides a method for predicting a component based on model fusion, and a flowchart thereof is shown in fig. 1, which specifically includes the following steps.
S100: and acquiring historical data of the quantity, preprocessing the historical data and screening target quantity data information.
S200: and constructing various prediction models according to the target quantity data information, and fusing various prediction models by using any one of various model fusion methods to form various quantity prediction fusion models for predicting the delivery quantity.
S300: and respectively carrying out component prediction by adopting various component prediction fusion models, calculating error information of component prediction results of the various component prediction fusion models according to actual component data information, and screening the component prediction fusion model with the minimum error as a target component prediction fusion model.
S400: and predicting the quantity of the parts according to the screened target quantity prediction fusion model.
The following specifically describes the above steps S100 to S400.
In step S100, historical data of the quantity is obtained, the historical data is preprocessed, and target quantity data information is screened, where the historical data of the quantity refers to quantity data stored in the logistics industry, and may also be quantity data in the logistics industry in a certain period of time published by a certain statistical institution. The delivery amount includes an addressee amount, may also include a delivery amount, and may also include an addressee amount and a delivery amount. In the database, the information of the dispatch amount and the receiving amount is stored no matter on-line or off-line. The information may include, but is not limited to: type of piece, time. The time may be stored by day, by week, or by the specific time entered into the system.
Preprocessing the acquired historical data, comprising: cleaning historical data, replacing null data and processing abnormal data; and cleaning the historical data, removing unnecessary information in the acquired historical data and replacing abnormal data. Often, some irregularities need to be filtered out before statistical analysis of the data is performed to ensure the accuracy of the analysis. Data cleansing is a process that reduces data errors and inconsistencies, primarily detecting and deleting or correcting irregular data.
In the present embodiment, since the prediction is mainly performed for the quantity, the single number information and the address information included in the history data can be eliminated. In the historical data, null data or data with numerical abnormality (such as non-numerical representation) may occur, and the null data or the data with numerical abnormality is replaced by adjacent data.
Specifically, the historical data includes the receiving amount and/or the sending amount, the receiving amount (with an order or without an order) and the sending amount information of each website can be called from the database according to different service scenes, the receiving amount of a certain website is taken as test data, the date of the historical data is the collecting amount in the period from 2017 to 2020, and the obtained historical data can be shown in the following table 1 after being cleaned.
TABLE 1
Date of collection
|
Amount of received data
|
2017/1/1
|
XXXXXX
|
2017/1/2
|
XXXXXX
|
...
|
XXXXXX
|
2020/12/31
|
XXXXXX |
The abnormal data may be processed by a deletion method, a substitution method (substitution of a continuous variable mean, substitution of a discrete variable with a mode and a median), or an interpolation method (regression interpolation, multiple interpolation), and the abnormal value may be changed into a missing value first and then the missing value may be supplemented. In practical applications, the abnormal value processing is generally classified as NA missing value processing or data trimming.
In step S200, a plurality of prediction models are constructed according to the target quantity data information, and the various prediction models are fused using any one of a plurality of model fusion methods, thereby constituting a plurality of quantity-of-delivery prediction fusion models for predicting the quantity of the delivered goods.
The prediction model comprises multiple qualitative prediction models, time series prediction models, panel data prediction models, wavelet analysis prediction models and LSTM prediction models, and the model fusion method comprises multiple voting methods, averaging methods, Bagging methods, Boosting methods and regression methods.
Each prediction model is described in detail below:
the qualitative prediction model means that the qualitative prediction means that related personnel make side prediction on the quantity according to past experience, knowledge, intuition and the like, continuous data is not needed to be used as support, timeliness is stronger, influence of subjective factors is larger, and therefore business sensitivity needs to be improved.
The time series prediction model refers to that a large number of time series are used in traditional prediction, whether the time series data have stationarity and seasonality generally needs to be observed, and if the data have stationarity and non-seasonality, the time series prediction model generally adopts a smoothing method, such as a simple average method, a moving average method and an exponential smoothing method. Seasonal predictions are used for seasonal data, such as seasonal multivariate regression models, seasonal autoregressive models, time series decomposition. And the data is non-stationary and non-seasonal, trend prediction methods including linear trend prediction, non-linear trend prediction, and autoregressive prediction models can be used.
The panel data prediction model is that the panel data has two time sequences and sections, can overcome the problem that the time sequence analysis is disturbed by multiple collinearity, and can provide more information, more changes, less collinearity, more degrees of freedom and higher estimation efficiency, and the unit root inspection and the co-integration analysis of the panel data are one of the most advanced fields at present.
The wavelet analysis prediction model means that wavelet analysis is suitable for a time sequence with the characteristics of non-stability, nonlinearity and high signal-to-noise ratio, and if a traditional denoising processing method is adopted, a plurality of defects exist. The wavelet theory is developed according to the time-frequency localization requirement, has the properties of self-adaption and mathematical microscopy, and is particularly suitable for processing non-stationary and non-linear signals.
The LSTM prediction model refers to the most recently very hot LSTM (long short term memory network), which is a time-recursive neural network that can perform better in longer sequences, and is suitable for processing and predicting important events with relatively long intervals and delays in time sequences. The LSTM has higher accuracy, more internal parameters, higher training difficulty and more data which is usually needed. And because the GRU effect is equivalent to the LSTM, the parameters are less than the LSTM, and the method is a good choice when a large-training model is constructed.
Furthermore, exponential smoothing can be performed on the prediction models by adopting exponential smoothing of different times, so that the processed prediction models are more stable and have smaller fluctuation.
The fusion method of each model is described in detail as follows:
the voting method is a simple model fusion method, and if 3 basic models exist for a two-classification problem, a voting method is adopted, and voting is determined as a final classification.
The averaging method means that for the regression problem, a simple and direct idea is to take the average. A slightly improved approach is to perform a weighted average. The weight value can be determined by a sorting method, for example, A, B, C three basic models, the model effect is ranked, and assuming that the ranking is 1, 2 and 3 respectively, the weight values given to the three models are 3/6, 2/6 and 1/6 respectively.
The Bagging method is that the Bagging adopts a mode of putting back for sampling, a sub-model is established by using the sampled sample, the sub-model is trained, the process is repeated for many times, and finally fusion is carried out. The Bagging method is roughly divided into the following processes:
repeating for K times;
repeated sampling modeling with a release;
and training the sub-model.
The Boosting method means that the Bagging algorithm can be processed in parallel, the Boosting idea is an iterative method, samples with classification errors are more concerned in each training, larger weights are added to the samples with the classification errors, and the next iteration aims to be capable of more easily distinguishing the samples with the classification errors in the previous round. And finally, weighting and adding the weak classifiers.
Regression methods refer to regression analysis as a mathematical model. When the dependent variable and the independent variable are in a linear relationship, the method is a special linear model.
The simplest case is a univariate linear regression, consisting of one independent variable and one dependent variable in a substantially linear relationship; the model is Y ═ a + bX + epsilon (X is the independent variable, Y is the dependent variable, epsilon is the random error).
It is generally assumed that the mean of the random error is 0 and the variance is σ ^2(σ ^2 > 0, σ ^2 is independent of the value of X). If it is further assumed that the random error follows a normal distribution, it is called a normal linear model. Generally, if there are k independent variables and 1 dependent variable, the value of the dependent variable is divided into two parts: one part is affected by the argument, i.e. represented as a function thereof, the functional form being known and containing unknown parameters; another part is affected by other non-considerations and randomness, i.e. random error.
When the function is a linear function with unknown parameters, the function is called a linear regression analysis model; when the function is a nonlinear function whose parameters are unknown, it is called a nonlinear regression analysis model. When the number of independent variables is greater than 1, the regression is called multiple regression, and when the number of dependent variables is greater than 1, the regression is called multiple regression.
The regression model can be established by using the prediction results of the multiple models as independent variables and the actual component as a dependent variable.
In step S300, component prediction is performed by using each component prediction fusion model, error information of component prediction results of each component prediction fusion model is calculated according to actual component data information, and the component prediction fusion model with the smallest error is screened as a target component prediction fusion model.
Specifically, the component prediction comprises the prediction of the quantity of the components and the prediction of prediction indexes of the components by adopting various component prediction fusion models, wherein the prediction indexes comprise recent factors, contemporaneous factors and cycle factors.
Further, the recent factors comprise recent piece quantity, a recent piece quantity smooth value and a recent week average value, the contemporaneous factors comprise an contemporaneous piece quantity index in the historical year, and the period factors comprise piece quantity of the same day in the historical week, piece quantity of the same day in the historical month, piece quantity of the same day in the historical quarter and piece quantity of the same day in the historical year.
The prediction of the prediction index of the delivery quantity by the exponential smoothing method is taken as an example for explanation.
Assuming that the component collecting quantity of the t day is xt, the component collecting quantity of the t-1 day is xt-1, and so on, designing a prediction index:
the factors include the following:
1) recent quantity: xt-1, xt-2, …, xt-14 represent the first 1, 2, …, 14 day pieces, respectively.
2) The recent piece quantity is smooth: on average, approximately 3 days, approximately 5 days, approximately 7 days, approximately 10 days, and approximately 14 days. Wherein (xt-1+ xt-2+ xt-3)/3 represents the average of nearly 3 days, and so on
3) Average in recent weeks: the average is approximately 2-8 days, and the average is approximately 7-14 days.
Synchronization factors include the following:
the contemporaneous factors include an indication of the number of contemporaneous components in the historical year, for example, a last year contemporaneous indicator such as today lxt of the last year is calculated. The current year synchronization indexes of all indexes in recent factors can be calculated by only changing the current year acquisition quantity into the last year acquisition quantity in the same time period.
The period factors include the following:
the cycle factors include the quantity of the same day in the historical week, the quantity of the same day in the historical month, the quantity of the same day in the historical quarter, and the quantity of the same day in the historical year, for example, the quantity of the same day in the last week, the same day in the last month, the same day in the last quarter, and the same day in the last year.
Further, calculating error information of the component prediction results of various component prediction fusion models according to the actual component data information, wherein the error information specifically comprises any one or more of calculated component prediction error values, component prediction error rates, model errors, measurement errors, truncation errors and rounding errors; the calculation process of the component prediction error value and the component prediction error rate is as follows:
prediction error value formula: the excess is positive and the deficiency is negative, where A represents the measured value and E represents the normal value.
The prediction error rate calculation method comprises the following steps:
a is the first measurement, b is the second measurement, c is the third measurement, d is the fourth measurement, e is the fifth measurement
(a + b + c + d + e)/5 as an average value
Average/100 is a percentage of the average.
The above model errors are: in the process of establishing the mathematical model, complicated phenomena are required to be abstracted and summarized into the mathematical model, the influence of some secondary factors is usually omitted, and the problem is simplified. Therefore, the mathematical model and the practical problem have certain errors, and the errors are called model errors.
The above measurement errors are: the data used in the modeling and detailed calculation processes are often obtained by observation and measurement, and due to the limitation of precision, the data are generally approximate, i.e., have errors, which are called measurement errors.
The truncation error described above refers to: because the actual operation can only complete finite term or finite step operation, the operation which needs to be carried out by finite or infinite process is limited, and the infinite process is cut off, so the generated error becomes a cut-off error.
The rounding error mentioned above means: in the numerical calculation, due to the limitation of the calculation tool, some numbers are often rounded, only the first few digits are kept as the approximate value of the number, and the error caused by rounding becomes the rounding error.
By any one or more of the above-mentioned calculated errors, the part prediction fusion model with the smallest error is selected as the target part prediction fusion model, for example, the corresponding part prediction fusion model can be selected according to the part prediction error value and the part prediction error rate, the prediction model corresponding to the part prediction fusion model is the wavelet analysis prediction model, the corresponding model fusion method is the average method, and for example, the corresponding part prediction fusion model can be selected according to the model error, the prediction model corresponding to the part prediction fusion model is the panel data prediction model, and the corresponding model fusion method is the Bagging method, so that in practical application, the best prediction index, prediction model, and model fusion method can be selected according to the designed target error, and in step S400, the part prediction is performed according to the selected prediction index, prediction model, and model fusion method, so as to improve the accuracy of the prediction of the quantity.
According to the quantity prediction method provided by the embodiment, various prediction models are fused by adopting a model fusion method to form a quantity prediction fusion model, the optimal quantity prediction fusion model is obtained by screening to perform optimal prediction on the quantity of the express delivery, the quantity prediction accuracy can be greatly improved, further, a powerful data basis is provided for orderly development of logistics work, for example, preparation of workers and vehicles can be made in advance based on the predicted quantity, and therefore the effects of reducing cost and reducing loss are achieved.
Example two:
based on the first embodiment, the present embodiment provides a device for generating a parts prediction fusion model, whose schematic diagram is shown in fig. 2, and specifically includes a data processing module 100, a model fusion creation module 200, a model fusion screening module 300, and a parts prediction module 400.
Specifically, the data processing module 100 is configured to obtain historical data of the quantity, pre-process the historical data, and screen out target quantity data information. The historical data of the quantity refers to the quantity data stored in the logistics industry, and can also be the quantity data in the logistics industry within a certain period of time published by a certain statistical institution. The delivery amount includes an addressee amount, may also include a delivery amount, and may also include an addressee amount and a delivery amount.
Preprocessing the acquired historical data, comprising: cleaning historical data, replacing null data and processing abnormal data; and cleaning the historical data, removing unnecessary information in the acquired historical data and replacing abnormal data. Often, some irregularities need to be filtered out before statistical analysis of the data is performed to ensure the accuracy of the analysis. Data cleansing is a process that reduces data errors and inconsistencies, primarily detecting and deleting or correcting irregular data.
In the present embodiment, since the prediction is mainly performed for the quantity, the single number information and the address information included in the history data can be eliminated. In the historical data, null data or data with numerical abnormality (such as non-numerical representation) may occur, and the null data or the data with numerical abnormality is replaced by adjacent data.
The abnormal data may be processed by a deletion method, a substitution method (substitution of a continuous variable mean, substitution of a discrete variable with a mode and a median), or an interpolation method (regression interpolation, multiple interpolation), and the abnormal value may be changed into a missing value first and then the missing value may be supplemented.
The model fusion creation module 200 is configured to construct multiple prediction models according to the target quantity data information, and fuse the various prediction models by using any one of multiple model fusion methods, thereby forming multiple quantity prediction fusion models for predicting the delivery quantity.
The prediction model comprises multiple qualitative prediction models, time series prediction models, panel data prediction models, wavelet analysis prediction models and LSTM prediction models, and the model fusion method comprises multiple voting methods, averaging methods, Bagging methods and Boosting methods. For each prediction model and fusion method, please refer to embodiment one, which is not described in detail herein.
The model fusion screening module 300 is configured to respectively perform component prediction by using various component prediction fusion models, calculate error information of component prediction results of the various component prediction fusion models according to actual component data information, and screen a component prediction fusion model with the smallest error as a target component prediction fusion model.
Specifically, the component prediction comprises the prediction of the quantity of the components and the prediction of prediction indexes of the components by adopting various component prediction fusion models, wherein the prediction indexes comprise recent factors, contemporaneous factors and cycle factors. For the description of the recent factors, the contemporaneous factors, and the period factors, reference is made to the first embodiment, which is not repeated herein.
Further, calculating error information of the component prediction results of various component prediction fusion models according to the actual component data information, wherein the error information specifically comprises any one or more of calculated component prediction error values, component prediction error rates, model errors, measurement errors, truncation errors and rounding errors; for the description of the component prediction error value, the component prediction error rate, the model error, the measurement error, the truncation error, and the rounding error, reference is made to the first embodiment, which is not repeated herein.
The model fusion screening module 300 screens the part prediction fusion model with the smallest error as the target part prediction fusion model by calculating any one or more errors, for example, the corresponding part prediction fusion model can be screened according to the part prediction error value and the part prediction error rate, the prediction model corresponding to the part prediction fusion model is a wavelet analysis prediction model, the corresponding model fusion method is an averaging method, and for example, the corresponding part prediction fusion model can be screened according to the model error, the prediction model corresponding to the part prediction fusion model is a panel data prediction model, and the corresponding model fusion method is a Bagging method.
The quantity prediction module 400 is configured to perform quantity prediction according to the screened target quantity prediction fusion model, and specifically, the quantity prediction module 400 performs quantity prediction according to the screened optimal prediction index, prediction model, and model fusion method, so as to improve the accuracy rate of quantity prediction.
By means of the quantity forecasting fusion model generation device provided by the embodiment, various forecasting models are fused by adopting a model fusion method to form a quantity forecasting fusion model, the optimal quantity forecasting fusion model is obtained through screening to perform optimal forecasting on the quantity of the express delivery, the forecasting accuracy of the quantity can be greatly improved, further, a powerful data basis is provided for orderly development of logistics work, for example, preparation of workers and vehicles can be made in advance based on the forecasted quantity, and therefore the effects of reducing cost and reducing loss are achieved.
Example three:
based on the first embodiment and the second embodiment, the present embodiment provides a component prediction device based on model fusion, and a schematic diagram of the device is shown in fig. 3, where the device 500 may be a tablet computer, a notebook computer, or a desktop computer. The device 500 may also be referred to by other names such as portable terminal, laptop terminal, desktop terminal, and the like.
In general, the device 500 includes a processor 5001 and a memory 5002, and the processor 5001 may include one or more processing cores, such as a 4-core processor, an 8-core processor, and the like. The processor 5001 may be implemented in at least one hardware form of a DSP (Digital Signal Processing), an FPGA (Field-Programmable Gate Array), and a PLA (Programmable Logic Array). The processor 3001 may also include a main processor and a coprocessor, the main processor being a processor for Processing data in an awake state, also referred to as a Central Processing Unit (CPU); a coprocessor is a low power processor for processing data in a standby state.
In some embodiments, the processor 5001 may be integrated with a GPU (Graphics Processing Unit) which is responsible for rendering and drawing the content required to be displayed on the display screen. In some embodiments, the processor 5001 may also include an AI (Artificial Intelligence) processor for processing computing operations related to machine learning.
Memory 5002 can include one or more computer-readable storage media, which can be non-transitory. The memory 5002 can also include high-speed random access memory, as well as non-volatile memory, such as one or more magnetic disk storage devices, flash memory storage devices. In some embodiments, a non-transitory computer readable storage medium in the memory 5002 is used to store at least one instruction, at least one program, set of codes, or set of instructions for execution by the processor 5001 to implement the component prediction method provided by embodiment one of the present application.
Therefore, the device 500 of the present application, which executes the component prediction method provided in the first embodiment through at least one instruction, at least one program, a code set, or an instruction set, has the following advantages: the various prediction models are fused by adopting a model fusion method to form a quantity prediction fusion model, and the best quantity prediction fusion model is obtained by screening to carry out the best prediction on the quantity of the express delivery, so that the quantity prediction accuracy can be greatly improved.
In some embodiments, the apparatus 500 may further optionally include: a peripheral interface 5003 and at least one peripheral. The processor 5001, memory 5002, and peripheral interface 5003 may be connected thereto by buses or signal lines. Various peripheral devices may be connected to the peripheral interface 5003 via a bus, signal line, or circuit board.
Specifically, in this embodiment, in order to implement the component prediction method, the corresponding peripheral device includes a database 5004, further, the processor 5001 may obtain the historical component data information through the database 5004, and the processor 5001 performs corresponding prediction model construction, model fusion, and component prediction operations according to the historical component data information.
The present invention also provides a computer-readable storage medium, which may be a non-volatile computer-readable storage medium, and which may also be a volatile computer-readable storage medium. The computer-readable storage medium has instructions stored therein, which when executed on a computer, cause the computer to perform the component prediction method of the first embodiment.
The system of the second embodiment, if implemented in the form of a software functional module and sold or used as a standalone product, may be stored in a computer-readable storage medium. Based on such understanding, the technical solution 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 steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-only memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
The present invention has been described in terms of specific examples, which are provided to aid understanding of the invention and are not intended to be limiting. For a person skilled in the art to which the invention pertains, several simple deductions, modifications or substitutions may be made according to the idea of the invention.