Prediction method and device
By combining clustering algorithms and BP neural networks to process Internet order data, the problem that traditional mathematical models are difficult to predict the number of Internet orders is solved, and higher-precision order prediction is achieved.
Patent Information
- Application Number
- CN201910532708.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-06-19
- Publication Date
- 2024-11-05
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Because the generation of Internet orders is unknown, random, discrete and irregular repeatability, it is difficult to accurately predict with traditional mathematical models.
The combination of clustering algorithm and BP neural network algorithm is used to train the order prediction model for each time period through denoising and clustering processing of order data, and then predict the order quantity.
This improves the accuracy of order prediction, allowing the prediction model to predict order quantity more accurately and improves the final prediction accuracy.
Smart Images

Figure CN110428086B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of machine learning technology, and specifically, relates to a prediction method and device. Background Art
[0002] With the continuous development of Internet technology, big data technology, artificial intelligence technology and other technologies, Internet-based e-commerce business has also developed rapidly. Order data and information are piling up at an alarming rate, and the prediction of order quantity has become a hot topic of research and concern for domestic and foreign scholars and enterprise developers. Since the generation of Internet orders is characterized by unknown, random, discrete and irregular repetitiveness, it is difficult to predict the order quantity using traditional mathematical models. Summary of the invention
[0003] In view of this, the technical problem to be solved by the present application is to provide a prediction method and device for realizing intelligent prediction of order quantity.
[0004] In order to solve the above technical problems, the present application discloses a prediction method, which comprises:
[0005] Acquire multiple initial sample order data, and perform denoising processing on each of the initial sample order data to obtain multiple target sample order data; wherein the target sample order data includes multiple order quantities sorted by time;
[0006] Performing clustering processing on the order quantity of each target sample order data to obtain order quantity clusters of K time periods of each target sample data, wherein K is a positive integer, and the order quantity clusters include a first order quantity and a second order quantity sorted by time;
[0007] For each time period, the first order quantity of each order quantity cluster in the time period is input into a preset neural network model for training, and when the difference between the output value of the preset neural network model and the second order quantity of the input order quantity cluster is less than a preset threshold, an order prediction model corresponding to the time period is obtained;
[0008] Obtain the number of orders to be predicted including multiple order quantities, perform denoising and clustering processing on the multiple order quantities, obtain order quantity clusters for K time periods, and for each time period, input the order quantity cluster for the time period into the order prediction model corresponding to the time period to obtain the order prediction quantity corresponding to each time period;
[0009] Combine the order forecast quantity corresponding to each time period to determine the final order forecast quantity
[0010] The present application also discloses a prediction device, which comprises:
[0011] A denoising unit, used to obtain a plurality of initial sample order data, and perform denoising processing on each of the initial sample order data to obtain a plurality of target sample order data; wherein the target sample order data includes a plurality of order quantities sorted by time;
[0012] A clustering unit, used for clustering the order quantity of each target sample order data to obtain the order quantity clusters of K time periods of each target sample data, wherein K is a positive integer, and the order quantity clusters include the first order quantity and the second order quantity sorted by time;
[0013] A training unit, for inputting, for each time period, the first order quantity of each order quantity cluster in the time period into a preset neural network model for training, and obtaining an order prediction model corresponding to the time period when the difference between the output value of the preset neural network model and the second order quantity of the input order quantity cluster is less than a preset threshold;
[0014] A prediction unit is used to obtain a to-be-predicted order quantity including multiple order quantities, perform denoising and clustering processing on the multiple order quantities, obtain order quantity clusters for K time periods, and for each time period, input the order quantity cluster for the time period into an order prediction model corresponding to the time period to obtain a predicted order quantity corresponding to each time period; and
[0015] It is used to determine the final order forecast quantity by combining the order forecast quantity corresponding to each time period.
[0016] Compared with the prior art, the present application can obtain the following technical effects:
[0017] The embodiment of the present application adds clustering processing of the order quantity before the BP neural network algorithm trains the order prediction model, so that each order quantity cluster is within a range of high similarity, so that the trained order prediction model can more accurately predict the order quantity. Through the technical solution provided by the embodiment of the present application, the order prediction model corresponding to each time period is obtained by using the training data corresponding to each time period, so that the order prediction model corresponding to each time period predicts the order quantity in the corresponding time period, thereby improving the final prediction accuracy.
[0018] Of course, any product implementing this application does not necessarily need to achieve all of the technical effects described above at the same time. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0020] Figure 1 is a flowchart of a prediction method provided by certain embodiments of the present application;
[0021] Figure 2 It is a schematic diagram of the BP neural network architecture provided by some embodiments of the present application;
[0022] Figure 3 is a flowchart of a prediction method provided by certain embodiments of the present application;
[0023] Figure 4 is a flowchart of a prediction method provided by certain embodiments of the present application;
[0024] Figure 5 It is a schematic diagram of a prediction device provided in certain embodiments of the present application. DETAILED DESCRIPTION
[0025] The following will describe the implementation methods of the present application in detail with the help of accompanying drawings and examples, so that the implementation process of how the present application uses technical means to solve technical problems and achieve technical effects can be fully understood and implemented accordingly.
[0026] In the process of studying the present invention, the inventors found that there are problems with the prior art: since the generation of Internet orders is characterized by unknown, random, discrete and irregular repetitiveness, it is difficult to use traditional mathematical models to predict the order quantity.
[0027] In view of this, the inventor proposed an idea, which combines clustering algorithm and BP neural network algorithm to predict orders. Compared with using only BP neural network algorithm to predict orders, the method of combining clustering algorithm and BP neural network algorithm is more accurate and has higher precision.
[0028] See also Figure 1 , an embodiment of the present application discloses an order prediction method based on BP neural network algorithm, comprising the following steps.
[0029] Step 102, obtaining a plurality of initial sample order data, and performing denoising processing on each of the initial sample order data to obtain a plurality of target sample order data.
[0030] In the implementation, the target sample order data includes multiple order quantities sorted by time.
[0031] For example, you can select the number of orders from 00:00:00 to 23:59:59 every day of a month on an e-commerce website, and use the number of orders from 00:00:00 to 23:59:59 every day of a week as the initial sample order data. Suppose the number of orders obtained in a week is:
[0032] Number of orders from 00:00:00 to 23:59:59 on Monday1 , the number of orders from 00:00:00 to 23:59:59 on Tuesday 2 , the number of orders from 00:00:00 to 23:59:59 on Wednesday 3 , the number of orders from 00:00:00 to 23:59:59 on Thursday 4 , the number of orders from 00:00:00 to 23:59:59 on Friday 5 , the number of orders from 00:00:00 to 23:59:59 on Saturday 6 , the number of orders from 00:00:00 to 23:59:59 on Saturday 7 .
[0033] The selected order quantity can be used as an initial sample order data, assuming it is expressed as:
[0034] {a 1 , a 2 , a 3 , a 4 , a 5 , a 6 , a 7}.
[0035] Then the initial sample order data is denoised to obtain the target sample order data: 1 , a' 2 , a' 3 , a' 4 , a' 5 , a' 6 , a' 7}.
[0036] Optionally, a median filtering method may be used to perform denoising processing on each of the initial sample order data to obtain a plurality of target sample order data.
[0037] It should be noted that the time period selected when selecting the order quantity can be customized, for example: 00:00:00-11:59:59 or 12:00:00-23:59:59. This application is not particularly limited.
[0038] Step 104 , clustering the order quantity of each target sample order data to obtain order quantity clusters of K time periods of each target sample data, where K is a positive integer.
[0039] In this embodiment, the algorithm used for clustering processing may be a K-means algorithm, where K is the number of time periods into which the order quantity is to be divided, for example, K is 3, and the number of time periods is 3, namely, 0 to 8, 8 to 16, and 16 to 24.
[0040] Specifically, for each target sample order data, a plurality of order quantities in the target sample order data may be clustered. 1 , a' 2 , a' 3 , a' 4 , a' 5 , a' 6 , a' 7} as an example, the target sample order data is clustered with K = 3 to obtain the order quantity clusters for three time periods: the first order quantity cluster {a' 11 , a' 21 , a' 31 , a' 41 , a' 51 , a' 61 , a' 71}、The second order quantity cluster from 8:00 to 16:00 {a' 12 , a' 22 , a' 32 , a' 42 , a' 52 , a' 62 , a' 72}、The third order quantity cluster from 16:00 to 24:00 {a' 13 , a' 23 , a' 33 , a' 43 , a' 53 , a' 63 , a' 73}. The sum of the elements for each day in each order quantity cluster is the number of orders on that day. For example, the number of orders on the first day is a' 1 , the sum of the first day elements of the same three order quantity clusters a' 11 +a' 12 +a' 13 =a' 1 .
[0041] In this embodiment, the order quantity cluster includes the first order quantity and the second order quantity sorted by time, and the second order quantity is the last order quantity in the order quantity cluster. 11 , a' 21 , a' 31 , a' 41 , a' 51 , a' 61 As the first order quantity, a' 71 As the second order quantity. Similarly, for the above second order quantity clustering, a' 12, a' 22 , a' 32 , a' 42 , a' 52 , a' 62 As the first order quantity, a' 72 As the second order quantity; for the third order quantity clustering, a' 13 , a' 23 , a' 33 , a' 43 , a' 53 , a' 63 As the first order quantity, a' 73 As the second order quantity.
[0042] Step 106, for each time period, the first order quantity of each order quantity cluster within the time period is input into a preset neural network model for training. When the difference between the output value of the preset neural network model and the second order quantity of the input order quantity cluster is less than a preset threshold, the order prediction model corresponding to the time period is obtained.
[0043] In the implementation, the preset neural network model is a BP neural network model, and its structure is as follows: Figure 2 Specifically, the first order quantity of each target sample order data can be input into the following mathematical model training to obtain an order prediction model:
[0044]
[0045]
[0046] Among them, ω ji (n) is the synaptic weight, x i (n) is the input of the training sample (i.e., the first order quantity of the order quantity clustering), is the activation function. In the embodiment of the present application, the activation function selects the Sigmoid function, v j (n) is the input of the hidden layer, y j (n) is the actual value of the output (i.e., the output value), where i is the number of neurons in the input layer, j is the number of neurons in the hidden layer, n is a positive integer and less than the number of samples.
[0047] In this embodiment, a corresponding order prediction model can be trained for each time period. Specifically, for each time period, the first order quantity of each order quantity cluster within the time period can be input into a preset neural network model for training to obtain an order prediction model corresponding to the time period.
[0048] For example, for time period 1 (0:00 to 8:00), the order quantity is clustered into 1{a' 11 , a' 21 , a' 31 , a' 41 , a' 51 , a' 61 , a' 71} and order quantity cluster 2{a' 21 , a' 31 , a' 41 , a' 51 , a' 61 , a' 71 , a' 81}, the first order quantity of the order quantity cluster 1 {a' 11 , a' 21 , a' 31 , a' 41 , a' 51 , a' 61} Input the BP neural network model and obtain the output value as a 71 , if the output value a 71 and the actual value (i.e. the second order quantity) a' 71 If the difference is greater than the preset threshold, the gradient descent method is used to modify the weight and adjust the threshold. Then the first order quantity {a' 21 , a' 31 , a' 41 , a' 51 , a' 61 , a' 71} Input the BP neural network model and obtain the output value as a 81 , if the output value a 81 and the actual value (i.e. the second order quantity) a' 81 If the difference is less than the preset threshold, the model is trained, that is, the order prediction model 1 corresponding to time period 1 is obtained.
[0049] It should be noted that if the output value a 71 and the actual value (i.e. the second order quantity) a' 71 If the difference is less than or equal to the preset threshold, there is no need to modify the weights and adjust the threshold. Then the first order quantity {a' 21 , a' 31 , a' 41 , a' 51 , a' 61 , a' 71} Input the BP neural network model and obtain the output value as a 81 , if the output value a 81 and the actual value (i.e. the second order quantity) a' 81If the difference is greater than the preset threshold, the weights need to be corrected and the threshold needs to be adjusted, and then the number of samples needs to be expanded and steps 102-108 need to be re-executed to train the model.
[0050] After this step, there is a corresponding order prediction model for each time period. The order prediction model corresponding to each time period can be used to predict the order quantity in each time period.
[0051] Step 108, obtain the number of orders to be predicted including multiple order quantities, denoise and cluster the multiple order quantities, obtain order quantity clusters for K time periods, and for each time period, input the order quantity cluster for the time period into the order prediction model corresponding to the time period to obtain the order prediction quantity corresponding to each time period.
[0052] In this embodiment, according to the acquisition rules of the initial sample order data, multiple order quantities within N days before the predicted time are obtained, where N is the same as the number of days corresponding to the first order quantity. 11 , a' 21 , a' 31 , a' 41 , a' 51 , a' 61} is the number of orders for 6 days, then the number of days corresponding to the first order quantity is 6 days. If the forecast date is September 8, then the number of orders within 6 days before September 8 is obtained, that is, the number of orders from September 2 to September 7 is obtained.
[0053] Then, multiple order quantities in the predicted order quantity are denoised and clustered. The clustering algorithm may be a K-means algorithm to obtain the order quantity clusters of K time periods. For each time period, the order quantity clusters of the time period are input into the order prediction model corresponding to the time period to obtain the order prediction quantity corresponding to each time period.
[0054] For example, the order prediction model corresponding to time period 1 (0:00 to 8:00) is model 1, the order prediction model corresponding to time period 2 (6:00 to 16:00) is model 2, and the order prediction model corresponding to time period 3 (16:00 to 24:00) is model 3.
[0055] Assume that the number of orders to be predicted from September 2 to September 7 is obtained. 2 , a 3 , a 4 , a 5 , a 6 , a 7} to perform denoising, and the number of multiple orders after denoising is {a' 2 , a' 3 , a' 4 , a'5 , a' 6 , a' 7}. Then for {a' 2 , a' 3 , a' 4 , a' 5 , a' 6 , a' 7} Perform clustering with K=3 to obtain the first order quantity cluster {a' 21 , a' 31 , a' 41 , a' 51 , a' 61 , a' 71}、The second order quantity cluster from 8:00 to 16:00 {a' 22 , a' 32 , a' 42 , a' 52 , a' 62 , a' 72}、The third order quantity cluster from 16:00 to 24:00 {a' 23 , a' 33 , a' 43 , a' 53 , a' 63 , a' 73}.
[0056] Cluster the first order quantity in time period 1 into {a' 21 , a' 31 , a' 41 , a' 51 , a' 61 , a' 71} Input model 1 and get the predicted value a' of the order quantity in time period 1 81 ;
[0057] Cluster the second order quantity in time period 2 {a' 22 , a' 32 , a' 42 , a' 52 , a' 62 , a' 72} Input model 2 to get the predicted value a' of the order quantity in time period 2 82 ;
[0058] Cluster the third order quantity in time period 3 into {a' 23 , a' 33 , a' 43 , a' 53 , a' 63 , a' 73} Input model 3 and get the predicted value a' of the order quantity in time period 3 83 .
[0059] Step 1010, determining a final order forecast quantity based on the order forecast quantity corresponding to each time period.
[0060] In this embodiment, the order forecast quantity corresponding to each time period is added up to obtain the final order forecast quantity. Still taking the example shown in step 106 as an example, the order forecast quantity a' for time periods 1-3 is added up to obtain the final order forecast quantity. 81 、a' 82 、a' 83 Add them together to get the predicted order quantity a for September 8 8 =a' 81 +a' 82 +a' 83 .
[0061] The embodiment of the present application adds clustering processing of the order quantity before the BP neural network algorithm trains the order prediction model, so that each order quantity cluster is within a range of high similarity, so that the trained order prediction model can more accurately predict the order quantity. Through the technical solution provided by the embodiment of the present application, the order prediction model corresponding to each time period is obtained by using the training data corresponding to each time period, so that the order prediction model corresponding to each time period predicts the order quantity in the corresponding time period, thereby improving the final prediction accuracy.
[0062] See also Figure 3 In one example, the clustering process in step 104 may be as follows.
[0063] Step 1041 : for each target sample order data, select K order quantities from multiple order quantities of the target sample order data as the central vector.
[0064] Step 1042, for each order quantity except K order quantities among the multiple order quantities, calculate the distance between the order quantity and the K center vectors, determine that the minimum distance among the calculated distances corresponds to the first center vector, and use the cluster corresponding to the first center vector as the cluster to which the order quantity belongs, to obtain K order quantity clusters.
[0065] Step 1043: for each order quantity cluster, re-determine the center vector of the order quantity cluster.
[0066] Step 1044: If it is determined that the difference between the re-determined center vector and the last determined center vector is less than a preset error threshold, the K order quantity clusters are taken as the final clustering result.
[0067] Step 1045, if it is determined that the difference between the re-determined center vector and the last determined center vector is not less than the preset error threshold, then repeat steps 1042-1043 until the difference between the re-determined center vector and the last determined center vector is less than the preset error threshold, and the last determined K order quantity clusters are taken as the final clustering results.
[0068] In order to ensure the accuracy of the order forecast model corresponding to each time period, it is necessary to measure the forecast accuracy of the order forecast model corresponding to each time period. Figure 4 The present application also provides a prediction method. Figure 1 The illustrated embodiment is substantially the same, except that the following steps are included between steps 106 and 108 .
[0069] Step 1071, obtaining the test order data for the time period, wherein the test order data includes the first test order quantity and the second test order quantity sorted by time.
[0070] In this embodiment, the prediction accuracy of the order prediction model corresponding to each time period can be measured, and for this purpose, the test order data corresponding to each time period can be obtained. For example: Figure 1 The test order data 1 of the time period 1 is shown as an example, and the test order data 1 includes a first test order quantity and a second test order quantity sorted by time.
[0071] Step 1072, input the first test order quantity into the order prediction model corresponding to the time period 1: Model 1, obtain the order prediction value output by the order prediction model, and determine the prediction accuracy of the order prediction model corresponding to the time period based on the order prediction value output by the order prediction model and the second test order quantity.
[0072] In this embodiment, the prediction accuracy can be obtained by the following formula:
[0073] A=(d j (n)-y j (n)) / y j (n)×100%, where A is the measurement accuracy, d j (n) is the number of the second test order, y j (n) is the order prediction value output by the order prediction model (i.e., the trained BP neural network model).
[0074] Step 1073, if the prediction accuracy is lower than the preset accuracy threshold, you can consider increasing the data sample and retraining the model, that is, obtaining multiple first sample order data, and using the first sample order data as the initial sample order data, and repeatedly performing denoising processing on the initial sample order data, clustering processing on the target sample order data, obtaining the order prediction model corresponding to the time period, and determining the prediction accuracy of the order prediction model corresponding to the time period, until the prediction accuracy of the order prediction model corresponding to the time period is not lower than the preset accuracy threshold.
[0075] In order to better organize the solutions provided by the embodiments of the present application, a specific example is used below to illustrate the two processes: the training process and the prediction process.
[0076] 1. Training Process
[0077] This process is mainly used to explain the process of training the order prediction model.
[0078] (1) Data sample selection: Select the original order data of an e-commerce website from 00:00:00 to 23:59:59 every day within three months. In order to ensure the generality of the measurement method, select the relatively complete original order data that does not include promotions and other factors that have a great influence, and exclude some holiday data, and finally obtain the original order quantity of 21 days. With a time scale of 5 minutes, the order quantity data is matched one by one according to the time series of each day. The sample has a total of 6048 groups of data. The first 20 days of the collected sample set are used as the BP neural network training sample set, and the last day is used as the test sample set. In this example, the original order data of 21 days is divided into 15 sample order data, namely sample 1 (day 1...day 7), sample 2 (day 2...day 8), and sample 15 (day 15...day 21), among which samples 1 to sample 14 are used as training sample sets (i.e., initial sample order data), and sample 15 is used as the test sample set.
[0079] (2) Data preprocessing: The data sample set collected in (1) above is denoised using the median filter method to obtain a processed training sample set (i.e., target sample order data) and a test sample set (i.e., test order data). The following will select some data for illustration.
[0080] The median filter formula used in denoising is as follows: g(x,y)=med{f(xk,yl),(k,l∈w)}.
[0081] Among them, x is the time series, y is the day, k is the number of time series in each median window, l is the number of days in each median window, f(x,y) is the original number of orders in the time series on that day, g(x,y) is the number of orders in the time series on that day after processing, and the data obtained is pieces / 5 minutes. For the unified standard and magnification, it is converted to pieces / hour. The conversion formula is z(x,y)=g(x,y)*12.
[0082] (3) Model training: Based on the nonlinear, random, and irregular repetitive characteristics of order quantity, we first use the K-means clustering algorithm to generate a time-based classification of order quantity. Then, we input the order quantity in each time period into the BP neural network model for training to obtain the order prediction model corresponding to the time period, thereby improving the accuracy of order quantity measurement.
[0083] This example uses the K-means clustering algorithm to divide the order data into data sets with certain rules, thereby improving the accuracy of the measurement. Assume that the set D of the training sample set (i.e. the initial sample order data) we extracted is (x1, x2, …, x n ), and each x i is a d-dimensional vector, in this example x i is the order data of each day, the latitude is the number of time series 288, under the condition of a given classification group number K (k≤n), where K is the initial value, the original data is divided into k categories S = {S 1 ,S 2 ,…,S k}.
[0084] (3.1) The steps of the K-means algorithm used in the training model are generally as follows:
[0085] (a) Randomly select K elements from D, where K is the initial number of classification groups, as the centers of the K clusters. In this example, K is the number of time periods into which the order quantity is initially divided. For example, if K is 3, the time periods are 0 to 8, 8 to 16, and 16 to 24.
[0086] (b) Calculate the distances of the remaining elements in D to the centers of the K clusters respectively, and assign the elements that are closer to the cluster to which they belong. In this example, calculate the distance between each (order quantity, time series) and the center (order quantity, time series) in K time periods, and assign each (order quantity, time series) to these k clusters.
[0087] (c) Then, based on the clustering results, the center of each cluster is calculated again. In this example, the center of k time periods (order quantity, time series) is recalculated.
[0088] (d) Repeat steps (b) and (c) until the center point no longer changes.
[0089] (f) Output the result.
[0090] The order quantity data is divided into K categories of order quantity clusters using K-means clustering, and the data of each order quantity cluster is input into the BP neural network model for training to obtain the order prediction model corresponding to the category.
[0091] The topological structure of BP neural network is as follows Figure 2 As shown: the BP neural network structure includes an input layer, a hidden layer, and an output layer. In this example, the 21-day data is divided into 15 samples, namely sample 1 (day 1...day 7), sample 2 (day 2...day 8), and sample 15 (day 15...day 21). The input layer of each sample contains 6 nodes, which are the order quantity data of the previous six days; the output layer contains 1 node, which is the corresponding order quantity data of the next day; the hidden layer: in the specific implementation, it can be appropriately increased or decreased in combination with the actual network training process, and the appropriate number of hidden layer nodes can be determined by comparing the training results. The number of hidden layer nodes must be an integer. Optionally, the number of nodes in the hidden layer can satisfy the following formula:
[0092]
[0093] In the formula, l 1 is the number of hidden layer nodes, l is the number of input layer nodes, m is the number of output layer nodes, and a is a constant between [1, 10].
[0094] (3.2) Input the data of each order quantity cluster into the BP neural network model for training to obtain the order prediction model corresponding to this class. Since the order quantity cluster corresponds to the time period, the order prediction model finally obtained corresponds to the time period.
[0095] The neural network algorithm used in the training model is generally as follows:
[0096] (A1) Initialize the synaptic weights ω of the network ji (n), initialize the activation function and its threshold. In this example, initialize the synaptic weight ω ji (n) is randomly selected from a uniform distribution with a mean of 0; the activation function is the Sigmoid function, and the threshold is the value of [-1,1].
[0097] (A2) Determine the training samples. This example divides the 21-day data into 15 samples. After filtering, they are sample 1 (day 1...day 7), sample 2 (day 2...day 8), and sample 15 (day 15...day 21). Samples 1 to 14 are used as training sample sets (i.e., target sample order data), and sample 15 is used as a test sample set. The details are shown in Table 1 below. After clustering the above samples, K order quantity classes are obtained for each sample. For the convenience of description, it is assumed that the data in Table 1 below all correspond to time period 1, where the input data is the first order quantity and the output data is the second order quantity.
[0098] Table 1
[0099]
[0100]
[0101] (A3) Forward propagation, calculate the input and output of each neuron in the hidden layer and output layer. The formula from the input layer to the hidden layer is where ω ji (n) is the synaptic weight, x i (n) is the input of the training sample. In this example, it is the order data of the first 6 days from samples 1 to 14 (i.e., the input data of the training sample set in Table 1). j (n) is the hidden layer input; the formula from the hidden layer to the output layer is in is the activation function. In this example, the activation function is the Sigmoid function. j (n) is the input of the hidden layer, y j (n) is the output prediction value, which in this example is the order quantity data for the 7th day in the predicted samples 1 to 14.
[0102] (A4) Calculate the error between the expected value (i.e., actual value) and the predicted value, back propagate, and update the weights and thresholds. The error calculation formula is e j (n) = d j (n)-y j (n), where d j (n) is the expected order quantity data (i.e., the actual value, i.e., the output data in Table 1). In this example, it is the order quantity data on the 7th day in samples 1 to 14. j (n) is the output prediction value, which is the order quantity data for the 7th day in the predicted samples 1 to 14. j (n) is the error. The weights are corrected using the gradient descent method and the threshold is adjusted.
[0103] (A5) Iterate and perform steps (3) and (4) until the stopping criteria are met and the model is trained. The final model contains the parameter ω ji (n) The number of neurons in the hidden layer.
[0104] (A6) Substitute the input data of sample 15 into the model to obtain the final forecast value of the order quantity on the 21st day.
[0105] (A7) Calculation of measurement accuracy: According to the formula A = (d j (n)-y j (n)) / y j (n)×100%, where A is the measurement accuracy, d j (n), y j (n) Same as above.
[0106] If the measurement accuracy is still low, consider increasing the data sample and retraining the model.
[0107] 2. Prediction Process
[0108] This process mainly uses the order prediction model trained in process 1 to predict the order quantity.
[0109] Since each time period has a corresponding order prediction model, each order prediction model can be used to predict the order quantity in each time period. Then, the predicted order quantity in each time period is added up to obtain the final order prediction quantity.
[0110] Let’s take the prediction for the 21st day as an example.
[0111] Get multiple order quantities for the days corresponding to the first order quantity in samples 1-14 before the 21st day, that is, get the order quantities from the 15th to the 20th day: (the 15th day...the 20th day). The details are shown in Table 2 below.
[0112] Table 2
[0113] Input Data Output Data Prediction sample set Day15, Day16, Day17, Day18, Day19, Day20
[0114] Perform K=3 clustering on multiple order quantities (Day15, Day16, Day17, Day18, Day19, Day20) to obtain the order quantity clusters for three time periods. For the convenience of explanation, in this example, (Day15, Day16, Day17, Day18, Day19, Day20) is the order quantity cluster corresponding to time period 1. Input (Day15, Day16, Day17, Day18, Day19, Day20) into the order prediction model corresponding to time period 1 to obtain the order prediction quantity corresponding to time period 1.
[0115] And so on, the predicted order quantity corresponding to time period 2-3 is obtained.
[0116] Then add up the order forecast quantities for time periods 1-3 to get the order forecast quantity corresponding to the 21st day.
[0117] For the above method embodiments, please refer to Figure 5 An embodiment of the present application provides a prediction device, including a denoising unit 500, a clustering unit 501, a training unit 502, and a prediction unit 503.
[0118] The denoising unit 500 is used to obtain a plurality of initial sample order data, and perform denoising processing on each of the initial sample order data to obtain a plurality of target sample order data; wherein the target sample order data includes a plurality of order quantities sorted by time;
[0119] A clustering unit 501 is used to perform clustering processing on the order quantity of each target sample order data to obtain the order quantity clusters of K time periods of each target sample data, where K is a positive integer, and the order quantity clusters include the first order quantity and the second order quantity sorted by time;
[0120] A training unit 502 is used to input the first order quantity of each order quantity cluster in the time period into a preset neural network model for training, and when the difference between the output value of the preset neural network model and the second order quantity of the input order quantity cluster is less than a preset threshold, obtain an order prediction model corresponding to the time period;
[0121] A prediction unit 503 is used to obtain a to-be-predicted order quantity including multiple order quantities, perform clustering processing on the multiple order quantities to obtain order quantity clusters for K time periods, and for each time period, input the order quantity cluster for the time period into an order prediction model corresponding to the time period to obtain a predicted order quantity corresponding to each time period; and
[0122] It is used to determine the final order forecast quantity by combining the order forecast quantity corresponding to each time period.
[0123] Optionally, the clustering unit 501 is specifically used for:
[0124] For each target sample order data, select K order quantities from multiple order quantities of the target sample order data as the center vector;
[0125] For each order quantity except K order quantities among the multiple order quantities, calculate the distance between the order quantity and the K center vectors, determine that the minimum distance among the calculated distances corresponds to the first center vector, and use the cluster corresponding to the first center vector as the cluster to which the order quantity belongs, to obtain K order quantity clusters;
[0126] For each order quantity cluster, the center vector of the order quantity cluster is re-determined. If it is determined that the difference between the re-determined center vector and the last determined center vector is less than a preset error threshold, the K order quantity clusters are taken as the final clustering results.
[0127] Optionally, the clustering unit 501 is further used for:
[0128] If it is determined that the difference between the re-determined center vector and the last determined center vector is not less than the preset error threshold, then repeatedly calculate the distance from the order quantity to the K center vectors for each order quantity except K order quantities among the multiple order quantities, determine that the first center vector corresponds to the minimum distance among the calculated distances, and use the cluster corresponding to the first center vector as the cluster to which the order quantity belongs to obtain K order quantity clusters; and, for each order quantity cluster, re-determine the center vector of the order quantity cluster until the difference between the re-determined center vector and the last determined center vector is less than the preset error threshold, and use the last determined K order quantity clusters as the final clustering results.
[0129] Optionally, it further includes an accuracy determination unit, configured to:
[0130] Acquire test order data for the time period, wherein the test order data includes a first test order quantity and a second test order quantity sorted by time;
[0131] Inputting the first test order quantity into the order prediction model corresponding to the time period, obtaining the order prediction value output by the order prediction model, and determining the prediction accuracy of the order prediction model corresponding to the time period based on the order prediction value output by the order prediction model and the second test order quantity;
[0132] If the prediction accuracy is lower than the preset accuracy threshold, then
[0133] The denoising unit is triggered to obtain multiple first sample order data, and the first sample order data is used as the initial sample order data, and the denoising process is repeatedly performed on the initial sample order data, the clustering unit is triggered to cluster the obtained target sample order data, and the training unit is triggered to input the first order quantity of the clustered order quantity of each time period into the preset neural network model for training to obtain the order prediction model corresponding to each time period, and the accuracy determination unit is controlled to determine the prediction accuracy of the order prediction model corresponding to each time period, until the prediction accuracy is not lower than the preset accuracy threshold.
[0134] Optionally, the denoising unit 500 is specifically used to: use a median filtering method to perform denoising processing on each of the initial sample order data to obtain multiple target sample order data.
[0135] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0136] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0137] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include non-transitory media such as modulated data signals and carrier waves.
[0138] For example, certain words are used in the specification and claims to refer to specific components. Those skilled in the art should understand that hardware manufacturers may use different terms to refer to the same component. This specification and claims do not use differences in names as a way to distinguish components, but use differences in the functions of components as the criteria for distinction. For example, "including" mentioned throughout the specification and claims is an open term, so it should be interpreted as "including but not limited to". "Substantially" means that within an acceptable error range, those skilled in the art can solve the technical problem within a certain error range and basically achieve the technical effect. In addition, the term "coupled" includes any direct and indirect electrical coupling means. Therefore, if the text describes a first device coupled to a second device, it means that the first device can be directly electrically coupled to the second device, or indirectly electrically coupled to the second device through other devices or coupling means. The subsequent description of the specification is a preferred embodiment of the present application, but the description is for the purpose of illustrating the general principles of the present application, and is not used to limit the scope of the present application. The scope of protection of the present application shall be determined by the attached claims.
[0139] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a product or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such a product or system. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the product or system including the elements.
[0140] The above description shows and describes several preferred embodiments of the present invention, but as mentioned above, it should be understood that the present invention is not limited to the form disclosed herein, and should not be regarded as excluding other embodiments, but can be used in various other combinations, modifications and environments, and can be modified within the scope of the invention concept described herein through the above teachings or the technology or knowledge of the relevant field. Changes and variations made by those skilled in the art do not depart from the spirit and scope of the present invention, and should be within the scope of protection of the claims attached to the present invention.
Claims
1. A prediction method, characterized in that: The method comprises: Acquire multiple initial sample order data, and perform denoising processing on each of the initial sample order data to obtain multiple target sample order data; wherein the target sample order data includes multiple order quantities sorted by time; Performing clustering processing on the order quantity of each target sample order data to obtain order quantity clusters of K time periods of each target sample data, wherein K is a positive integer, and the order quantity clusters include a first order quantity and a second order quantity sorted by time; For each time period, the first order quantity of each order quantity cluster in the time period is input into a preset neural network model for training, and when the difference between the output value of the preset neural network model and the second order quantity of the input order quantity cluster is less than a preset threshold, an order prediction model corresponding to the time period is obtained; Obtain the number of orders to be predicted including multiple order quantities, perform denoising and clustering processing on the multiple order quantities, obtain order quantity clusters for K time periods, and for each time period, input the order quantity cluster for the time period into the order prediction model corresponding to the time period to obtain the order prediction quantity corresponding to each time period; Combine the order forecast quantity corresponding to each time period to determine the final order forecast quantity.
2. The method according to claim 1, characterized in that The clustering process of the order quantity of each target sample order data to obtain the order quantity clusters of K time periods of each target sample data includes: For each target sample order data, select K order quantities from multiple order quantities of the target sample order data as the center vector; For each order quantity except K order quantities among the multiple order quantities, calculate the distance between the order quantity and the K center vectors, determine that the minimum distance among the calculated distances corresponds to the first center vector, and use the cluster corresponding to the first center vector as the cluster to which the order quantity belongs, to obtain K order quantity clusters; For each order quantity cluster, the center vector of the order quantity cluster is re-determined. If it is determined that the difference between the re-determined center vector and the last determined center vector is less than a preset error threshold, the K order quantity clusters are taken as the final clustering results.
3. The method according to claim 2, characterized in that Also includes: If it is determined that the difference between the re-determined central vector and the last determined central vector is not less than the preset error threshold, then repeatedly executing for each order quantity except K order quantities among the multiple order quantities, calculating the distance from the order quantity to the K central vectors, determining that the minimum distance among the calculated distances corresponds to the first central vector, and taking the cluster corresponding to the first central vector as the cluster to which the order quantity belongs, to obtain K order quantity clusters; And, for each order quantity cluster, the center vector of the order quantity cluster is re-determined until the difference between the re-determined center vector and the last determined center vector is less than a preset error threshold, and the last determined K order quantity clusters are used as the final clustering results.
4. The method according to claim 1, characterized in that: Between obtaining the order prediction model corresponding to the time period and obtaining the number of orders to be predicted including multiple order quantities, the method further includes: Acquire test order data for the time period, wherein the test order data includes a first test order quantity and a second test order quantity sorted by time; Inputting the first test order quantity into the order prediction model corresponding to the time period, obtaining the order prediction value output by the order prediction model, and determining the prediction accuracy of the order prediction model corresponding to the time period based on the order prediction value output by the order prediction model and the second test order quantity; If the prediction accuracy is lower than the preset accuracy threshold, multiple first sample order data are obtained, and the first sample order data are used as the initial sample order data. The process of denoising the initial sample order data, clustering the target sample order data, obtaining the order prediction model corresponding to the time period, and determining the prediction accuracy of the order prediction model corresponding to the time period is repeatedly performed until the prediction accuracy of the order prediction model corresponding to the time period is not lower than the preset accuracy threshold.
5. The method according to claim 1, characterized in that The denoising process is performed on each of the initial sample order data to obtain a plurality of target sample order data, including: The median filtering method is used to perform denoising processing on each of the initial sample order data to obtain multiple target sample order data.
6. A prediction device, characterized in that: The device comprises: A denoising unit, used to obtain a plurality of initial sample order data, and perform denoising processing on each of the initial sample order data to obtain a plurality of target sample order data; wherein the target sample order data includes a plurality of order quantities sorted by time; A clustering unit, used for clustering the order quantity of each target sample order data to obtain the order quantity clusters of K time periods of each target sample data, wherein K is a positive integer, and the order quantity clusters include the first order quantity and the second order quantity sorted by time; A training unit, for inputting, for each time period, the first order quantity of each order quantity cluster in the time period into a preset neural network model for training, and obtaining an order prediction model corresponding to the time period when the difference between the output value of the preset neural network model and the second order quantity of the input order quantity cluster is less than a preset threshold; A prediction unit is used to obtain a to-be-predicted order quantity including multiple order quantities, perform denoising and clustering processing on the multiple order quantities, obtain order quantity clusters for K time periods, and for each time period, input the order quantity cluster for the time period into an order prediction model corresponding to the time period to obtain a predicted order quantity corresponding to each time period; and It is used to determine the final order forecast quantity by combining the order forecast quantity corresponding to each time period.
7. The device according to claim 6, characterized in that The clustering unit is specifically used for: For each target sample order data, select K order quantities from multiple order quantities of the target sample order data as the center vector; For each order quantity except K order quantities among the multiple order quantities, calculate the distance between the order quantity and the K center vectors, determine that the minimum distance among the calculated distances corresponds to the first center vector, and use the cluster corresponding to the first center vector as the cluster to which the order quantity belongs, to obtain K order quantity clusters; For each order quantity cluster, the center vector of the order quantity cluster is re-determined. If it is determined that the difference between the re-determined center vector and the last determined center vector is less than a preset error threshold, the K order quantity clusters are taken as the final clustering results.
8. The device according to claim 7, characterized in that The clustering unit is further used for: If it is determined that the difference between the re-determined central vector and the last determined central vector is not less than the preset error threshold, then repeatedly executing for each order quantity except K order quantities among the multiple order quantities, calculating the distance from the order quantity to the K central vectors, determining that the minimum distance among the calculated distances corresponds to the first central vector, and taking the cluster corresponding to the first central vector as the cluster to which the order quantity belongs, to obtain K order quantity clusters; And, for each order quantity cluster, the center vector of the order quantity cluster is re-determined until the difference between the re-determined center vector and the last determined center vector is less than a preset error threshold, and the last determined K order quantity clusters are used as the final clustering results.
9. The device according to claim 6, characterized in that Also included is an accuracy determination unit for: Acquire test order data for the time period, wherein the test order data includes a first test order quantity and a second test order quantity sorted by time; Inputting the first test order quantity into the order prediction model corresponding to the time period, obtaining the order prediction value output by the order prediction model, and determining the prediction accuracy of the order prediction model corresponding to the time period based on the order prediction value output by the order prediction model and the second test order quantity; If the prediction accuracy is lower than the preset accuracy threshold, then The denoising unit is triggered to obtain multiple first sample order data, and the first sample order data is used as the initial sample order data, and the denoising process is repeatedly performed on the initial sample order data, the clustering unit is triggered to cluster the obtained target sample order data, and the training unit is triggered to input the first order quantity of the clustered order quantity of each time period into the preset neural network model for training to obtain the order prediction model corresponding to each time period, and the accuracy determination unit is controlled to determine the prediction accuracy of the order prediction model corresponding to each time period, until the prediction accuracy is not lower than the preset accuracy threshold.
10. The device according to claim 6, characterized in that The denoising unit is specifically used to: use the median filtering method to perform denoising processing on each of the initial sample order data respectively to obtain multiple target sample order data.
