A commodity sales forecasting method and forecasting model based on fully connected neural network
Through the multi-scale feature extraction and Stack module of the fully connected neural network model, combined with the fusion of prediction results, the nonlinear and sequential processing problems of commodity sales data in the existing technology are solved, and the prediction accuracy and stability are improved.
Patent Information
- Application Number
- CN202410729689.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-06
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2044-06-06
AI Technical Summary
When processing product sales data, the existing technology is difficult to effectively handle non-stationary, intermittency and non-linear characteristics, resulting in a decrease in prediction accuracy, and multi-scale decomposition methods are prone to noise deviation and information leakage problems.
A product sales forecast model based on a fully connected neural network is used. Through the multi-scale feature extraction module and the Stack module, the average pooling and fully connected layers are used to build a time series feature pyramid to capture the trends and seasonal characteristics of different time scales, and input data through calculation and the reconstructed value, learn the unfitted information layer by layer, and combine the prediction result fusion module to make the final prediction.
It improves the accuracy of product sales forecasting, can better handle nonlinear and sequential problems, reduces the impact of local irregular features, aggregates information at different scales, and enhances the stability and accuracy of forecasting results.
Smart Images

Figure CN118313869B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of sales forecasting and deep learning technology, and in particular to a commodity sales forecasting method based on a fully connected neural network and a forecasting model Unet-Block. Background Art
[0002] As the cornerstone of marketing, sales forecasting has important guiding significance for the company's strategic decision-making, production planning, inventory management, marketing and financial management. Due to the wide variety of commodities, fast update speed, wide and changeable consumer groups, and this trend of diversification and personalization has also brought huge challenges to enterprises, especially in sales forecasting. If the sales forecast is inaccurate, there may be shortages or surpluses of goods, which will directly affect the company's profit level. At the same time, the accuracy of sales forecasts will also directly affect the quality of customer service. Once there is a large deviation in the sales forecast, the entire supply chain will face serious challenges. Inventory backlogs will lead to significant increases in costs (such as labor and storage), thereby reducing profit margins. Additional warehousing and management costs, when sales forecasts are lower than actual market sales, will directly cause sales losses, weaken customer satisfaction and have a negative impact on the business. If the goods cannot be provided on time, their potential sales will be lost, and customers may turn to competitors, making it difficult to maintain loyalty.
[0003] Problems with existing technologies:
[0004] 1. The sales data of commodities are highly non-stationary, intermittent and non-linear. When faced with data with complex non-linear characteristics, the prediction accuracy may decrease.
[0005] The reported "A method, device, equipment and medium for predicting instant lottery sales", patent application number 202311302193.1, builds an ARIMA sales prediction model, selects features and determines the order of the ARIMA sales prediction model, and predicts instant lottery sales. However, the ARIMA model requires that the data is stationary or the data is stationary after differentiation. When the stationarity is not met, the order of the ARIMA sales prediction model needs to be determined by the Bayesian information criterion. The ARIMA model has many parameters, including autoregressive terms, difference orders, and coefficients of moving average terms. These parameters need to be adjusted appropriately according to the characteristics of the data. However, the parameter adjustment process is often more complicated, and overfitting or underfitting is prone to occur, which affects the prediction performance of the model. The reported "Product Sales Forecasting Method, Device, Electronic Device and Storage Medium", patent application number: 202311610758.2, is based on linear prediction models and nonlinear prediction models, which can better fit the nonlinear characteristics existing in the data. By combining the linear prediction model and the nonlinear prediction model, the linear prediction value and the nonlinear prediction value of the prediction time period are obtained, and then the sales forecast value is obtained. At the same time, the linear and nonlinear trends of sales are considered, so that the obtained sales forecast value is more accurate, but the further decomposition and utilization of the residual are not considered.
[0006] 2. The sales data of retail enterprises can be divided into trend items and periodic items through the time series decomposition method, but the trend items and seasonal items enter their own feature extraction modules for feature extraction and prediction, and then perform prediction feature fusion. At present, feature fusion mainly uses simple addition to output the prediction result, and there is no correlation feature between the two for processing. Therefore, the present invention adopts a multi-scale feature extraction method, and performs multiple samplings through average pooling to obtain sales sequences of different scales for prediction, so as to reduce the influence of local irregular features and aggregate information of different scales.
[0007] The reported "Retail Product Sales Forecasting Methods, Tools, Systems, Equipment and Storage Medium", patent application number: 202210454050.1, uses the EEMD model to decompose the sales data of retail enterprises. By establishing a SARIMA model or an ARIMA model based on the quasi-periodic information of each IMF component series, the sales of each IMF component series are predicted separately, and the various prediction results are fitted and added to achieve the prediction of retail enterprise sales. However, the level of noise and the number of additions have a certain impact on the decomposition results. If the noise level is too high or the number of additions is too many, the decomposition results may be biased or unstable, and the entire sequence is decomposed during the decomposition process, but there is an information leakage problem. The "Method and Device for Commodity Sales Prediction Based on Prophet-CEEMDAN-ARIMA" has been reported, and the patent application number is: 202010258782.4. The Prophet model is used to predict the regular items of commodity sales. For random items, the complete empirical mode decomposition (CEEMDAN) algorithm of adaptive white noise is first used to decompose the residual sequence into several components of different frequencies, and then the components are tested and screened by ADF. Finally, ARIMA is used to predict the screened components, and the prediction results are added, while the correlation between the decomposed sequences is ignored. Summary of the invention
[0008] In view of the above problems, the purpose of the present invention is to provide a commodity sales forecasting method and forecasting model based on a fully connected neural network. Through a fully connected neural network, a deep learning model is constructed. By calculating the residual between the data input and the reconstructed value as the input between modules, the model can learn irregular features that have not yet been fitted. It can better understand the nonlinearity and timing in the data, better handle nonlinear and timing problems, and adopt a multi-scale feature extraction method. Through average pooling, multiple samples are taken to obtain sales sequences of different scales for prediction, so as to reduce the impact of local irregular features and aggregate information of different scales to obtain better prediction accuracy.
[0009] To achieve the above object, the present invention adopts the following technical solutions:
[0010] A commodity sales prediction model based on a fully connected neural network, comprising: a multi-scale feature extraction module, a Stack module, and a prediction result fusion module;
[0011] The multi-scale feature extraction module constructs a time series feature pyramid through an average pooling operation to obtain features of different time scales, which can help capture trends and seasonal characteristics within different time ranges, and can also smooth noise and fluctuations in the data and reduce the impact of short-term fluctuations.
[0012] The Stack module includes multiple block modules, and multiple block modules are connected in series to form a Stack module with multiple layers of block modules. The output of the block module is divided into two parts, namely the prediction result and the reconstruction value of the current input. The prediction results output by multiple block modules are added to obtain the final prediction result, and the input of each layer of block module is the residual of the input of the previous layer of block module minus the reconstruction value, so as to fully learn the unlearned information and unexplained irregularities; the Stack module is designed with a fully connected layer as a whole, and the module structure is shown in the attached figure. Figure 3 As shown, it is proposed by the N-beats model and used in its variant model.
[0013] The prediction result fusion module is used to connect the prediction results of different scales output by the Stack module with the prediction results of the previous layer by splicing, and then output the prediction results of the same length as the prediction results of the previous layer through the linear layer, so as to output them layer by layer until the final prediction result is output.
[0014] Another object of the present invention is to provide a prediction method for a commodity sales prediction model based on a fully connected neural network, which specifically comprises the following steps:
[0015] Step S1: Construct a training data set based on the historical sales data of the product.
[0016] The historical sales data of the commodity is preprocessed by a preprocessing module to form a data set required for building a prediction model, wherein the preprocessing module includes: a data cleaning module and a data set building module;
[0017] The data cleaning module is used to process missing values and abnormal values in historical sales data;
[0018] The data set construction module is used to process the historical sales data and perform standardization operations on the historical sales data to meet the needs of prediction model training to obtain a data set for training, wherein the data set is divided into a training set, a validation set and a test set, the training set is used for model training to learn the distribution characteristics of the data, the validation set verifies the reliability of the learned distribution characteristics, and the test set tests the generalization ability of the model;
[0019] Among them, when two extractions are performed, the prediction model will obtain the prediction results y1, y2, and y3. Let T be the number of days for the product sales forecast, then the prediction length of each sequence is shown in the following formula. The input sequence length calculation formula is consistent with the prediction length calculation formula. By setting the input length and the prediction length, the length of each scale sequence is automatically calculated. Therefore, you only need to consider whether the set input length and the prediction length are reasonable. Among them, kernel_size is the convolution kernel size, stride is the sliding step size, and padding is padding. Due to multi-scale feature extraction, padding is set to 0;
[0020] len(y1)=T;
[0021]
[0022]
[0023] Step S2: The data set is input into the multi-scale feature extraction module to obtain sequences of different scales.
[0024] The data set obtained in step S1 is passed through a multi-scale feature extraction module, and a time series feature pyramid is constructed through an average pooling operation to obtain sequences of different scales. Average pooling calculates the average value within the pooling window through the pooling window and the pooling step size, which can help capture trends and seasonal characteristics within different time ranges, and at the same time can smooth the noise and fluctuations in the data and reduce the impact of short-term fluctuations. Assume that the original product needs to predict the sales volume of the next M days, and the historical data is x=(x1, x2, ..., x n ), the sequence to be predicted in the future is y = (y1, y2, ..., y m ). Considering the limited historical data of commodities, only two average poolings are performed to obtain time series of different scales. The original input data is set to x,
[0025] x1=x;
[0026] x2 = AvgPool(x1);
[0027] x3 = AvgPool(x2);
[0028] In this way, we get sequence data x1, x2, and x3 of different scales. In the time dimension, x2 and x3 focus on larger granularity, that is, they focus on trend features, which helps the model learn the trend information of the sequence and reduce the impact of short-term fluctuations.
[0029] Step S3: Predict sequence data of different scales and output prediction results.
[0030] The sequences of different scales obtained from step S2 are input into the Stack module, which is composed of multiple block modules in series. The block module consists of six fully connected layers and is divided into two parts. The first part is a fully connected layer that maps the input time series x1, x2, x3 into expansion coefficients. Here, x1, x2, x3 are abbreviated as x l ,
[0031] h l,1 =FC l,1 (x l );
[0032] h l,2 =FC l,2 (x l,1 );
[0033] h l,3 =FC l,3 (x l,2 );
[0034] h l,4 =FC l,4 (x l,3 );
[0035]
[0036]
[0037] Among them, FC is a fully connected layer, using ReLu activation function, and Linear is a simple linear projection layer; finally, we get Represent the forward and reverse expansion coefficients respectively; the expansion coefficient is understood as a low-dimensional vector (dimension dim) that stores the intrinsic information of the time series; the second part is formed by the mapping function and Map the expansion coefficient back to the time series; as shown in the following formula, the reconstructed value of the current window and the prediction result of the future prediction window are obtained;
[0038]
[0039]
[0040] in is the reconstructed value at the current window time point, Forecasts for future points in the forecast window, are the backward and forward basis vectors respectively; They are The i-th value of ; The role is to provide a sufficiently rich collection The input x of the current layer block module lSubtract the reconstructed value result Get the residual and input it to the next block as input. In this way, each layer of the prediction model needs to process the residual that the previous layer cannot fit correctly. It also plays a role in decomposing the time series layer by layer and predicting part of the time series. The final prediction result is the prediction result of multiple block modules. The sum of , that is, the prediction results y1, y2, y3;
[0041] Step S4: Fusion of prediction results at different scales to obtain the final prediction result.
[0042] In step S3, the prediction results y1, y2, and y3 are obtained through the fusion module to obtain the final prediction result. The fusion module uses y i and i-1 The concatenation method is then used to obtain the linear layer output with y i-1 The output results of the same length are fused layer by layer to obtain the final prediction result y;
[0043] y′2=Linear(cat(y3, y2));
[0044] y=Linear(cat(y1,y′2));
[0045] In order to compare the error between the true value and the predicted value, two loss evaluation indicators, MSE (Mean Square Error) and MAE (Mean Absolute Error), are used to measure the performance of the model.
[0046]
[0047] where y i is the true value, After the prediction model training is completed, it is restored through denormalization to obtain the product prediction result.
[0048] The advantages and positive effects of the present invention are:
[0049] 1. The present invention performs multiple samplings through average pooling to obtain sales sequences of different scales for prediction, so as to reduce the influence of local irregular features and aggregate information of different scales and input them into a deep learning model constructed by a fully connected neural network. This can better understand the nonlinear and temporal problems in the data, better handle nonlinear and temporal problems, and adopt a multi-scale feature extraction method to obtain better prediction accuracy.
[0050] 2. By calculating the residual between the data input and the reconstructed value, the model can learn irregular features that have not yet been fitted, thereby improving the prediction accuracy of the model. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] Figure 1 It is a schematic diagram of the process of the present invention;
[0052] Figure 2 is a schematic diagram of a prediction model of the present invention;
[0053] Figure 3 It is a schematic diagram of the fully connected layer design of the Stack module of the present invention. DETAILED DESCRIPTION
[0054] Example 1
[0055] like Figure 2 and Figure 3 As shown, this embodiment provides a commodity sales prediction model based on a fully connected neural network, including: a multi-scale feature extraction module, a Stack module, and a prediction result fusion module;
[0056] Among them, the multi-scale feature extraction module constructs a time series feature pyramid through average pooling operations to obtain features of different time scales, which can help capture trends and seasonal characteristics within different time ranges, and at the same time can smooth the noise and fluctuations in the data and reduce the impact of short-term fluctuations;
[0057] The Stack module is designed with a fully connected layer. The module structure is shown in the attached figure. Figure 3 As shown in the figure, it is proposed by the N-beats model and used in its variant model. The Stack module includes multiple block modules. Multiple block modules are connected in series to form a Stack module with multiple layers of block modules. The output of the block module is divided into two parts, namely the prediction result and the reconstruction value of the current input. The prediction results output by multiple block modules are added to obtain the final prediction result. The input of each layer of block module is the residual of the input of the previous layer of block module minus the reconstruction value, so as to fully learn the unlearned information and unexplained irregularities.
[0058] The prediction result fusion module is used to connect the prediction results of different scales output by the Stack module with the prediction results of the previous layer by splicing, and then pass the prediction results of the same length as the prediction results of the previous layer through the linear layer, and output them layer by layer until the final prediction result is output.
[0059] Example 2
[0060] like Figure 1As shown, due to the nonlinear characteristics of time series such as sales volume, the existing sales volume forecasting model cannot accurately predict, resulting in unreliable prediction results. Therefore, this embodiment provides a product sales volume forecasting method based on a fully connected neural network. The method includes:
[0061] Step S1: Construct a training data set based on the historical sales data of the product.
[0062] Obtain historical sales data of the product. The product can be various commodities, such as beverages, alcoholic beverages, snacks, etc., and the prediction model training data can be the historical sales data of a certain commodity, wherein the sample size of the data cannot be too small to avoid underfitting of the model. Since the present embodiment adopts the extraction of multi-scale time dimension features, the input data and prediction length will affect the number of downsampling, so they need to be set reasonably. If only two extractions are performed, the prediction results y1, y2, and y3 will be obtained. Let T be the number of days for the sales forecast of the beverage product, then the prediction length of each sequence is shown in the following formula, and the input sequence length calculation formula is consistent with the prediction length calculation formula. The method proposed in the present invention can automatically calculate the length of each scale sequence by setting the input length and the prediction length. Therefore, it is only necessary to consider whether the set input length and the prediction length are reasonable. Among them, kernel_size is the convolution kernel size, stride is the sliding step size, padding is padding, and padding is set to 0 due to multi-scale feature extraction;
[0063] len(y1)=T
[0064]
[0065] The obtained data needs to be processed through certain preprocessing modules to create a data set, including missing value processing and outlier processing. In the data set construction module, the data is standardized and divided into training set, validation set and test set, thus forming the data required for model construction. The training set is used for model training to learn the distribution characteristics of the data, the validation set verifies the reliability of the learned distribution characteristics, and the test set tests the generalization ability of the model.
[0066] Step S2: The data set is input into the multi-scale feature extraction module to obtain sequence values of different scales and nonlinear residuals.
[0067] The data set obtained in step S1 is passed through a multi-scale feature extraction module, and a temporal feature pyramid is constructed through an average pooling operation to obtain sequences of different scales.
[0068] X1 = x;
[0069] x2 = AvgPool(x1);
[0070] x3 = AvgPool(x2);
[0071] When the input data length and prediction length support more sampling operations, sequences of more scales can be obtained. When performing the sampling operation, the values of Kernel size, padding, and stride need to be set.
[0072] Step S3: predict the sequences of different scales and output the nonlinear prediction values of the prediction results for the time period.
[0073] The sequences of different scales obtained from step S2 are input into the Stack module respectively. The Stack module is composed of multiple block modules in series. The block module is mainly composed of six fully connected layers and can be divided into two parts. The first part consists of four fully connected layers to map the input time series x1, x2, x3 into expansion coefficients. Here, x1, x2, x3 are abbreviated as x l ,
[0074] h l,1 =FC l,1 (x l );
[0075] h l,2 =FC l , 2(x l,1 );
[0076] h l,3 =FC l,3 (x l,2 );
[0077] h l,4 =FC l,4 (X l,3 );
[0078]
[0079] Among them, FC is a fully connected layer, using ReLu activation function, and Linear is a simple linear projection layer; finally, we get Represent the forward and reverse expansion coefficients respectively; the expansion coefficient is understood as a low-dimensional vector (dimension dim) that stores the intrinsic information of the time series; the second part is formed by the mapping function and Map the expansion coefficient back to the time series; as shown in the following formula, the reconstructed value of the current window and the prediction result of the future prediction window are obtained;
[0080]
[0081] in is the reconstructed value at the current window time point, Forecasts for future points in the forecast window, are the backward and forward basis vectors respectively; They are The i-th value of ; The role is to provide a sufficiently rich collection The input x of the current layer block module l Subtract the reconstructed value result Get the residual and input it to the next block as input. In this way, each layer of the prediction model needs to process the residual that the previous layer cannot fit correctly. It also plays a role in decomposing the time series layer by layer and predicting part of the time series. The final prediction result is the prediction result of multiple block modules. The sum of , that is, the prediction results y1, y2, y3;
[0082] Step S4: Fusion of prediction results at different scales to obtain the final prediction result.
[0083] In step S3, the prediction results y1, y2, and y3 are obtained through the fusion module to obtain the final prediction result. i and i-1 The concatenation method is then used to obtain the linear layer output with y i-1 The output results are of the same length. The final prediction result y is obtained by fusing upward layer by layer.
[0084] y′2=Linear(cat(y3, y2));
[0085] y=Linear(cat(y1,y'2)).
[0086] The above description is only a preferred example of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various changes and variations. Any modification, equivalent substitution, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A prediction method for a commodity sales prediction model based on a fully connected neural network, characterized in that: The following steps are involved: Step S1: Construct a training data set based on the historical sales data of the product. The historical sales data of the commodity is preprocessed by a preprocessing module to form a data set required for building a prediction model, wherein the preprocessing module includes: a data cleaning module and a data set building module; The data cleaning module is used to process missing values and abnormal values in historical sales data; The data set construction module is used to process the historical sales data and perform standardization operations on the historical sales data to meet the needs of prediction model training to obtain a data set for training, wherein the data set is divided into a training set, a validation set and a test set, the training set is used for model training to learn the distribution characteristics of the data, the validation set verifies the reliability of the learned distribution characteristics, and the test set tests the generalization ability of the model; Among them, when two extractions are performed, that is, when sequence data x1, x2, x3 of different scales are obtained, the prediction model will obtain prediction results y1, y2, y3 of different lengths according to x1, x2, x3. Let T be the number of days for product sales forecast, then the prediction length of each sequence is as shown in the following formula. The input sequence length calculation formula is consistent with the prediction length calculation formula. By setting the input length and prediction length, the length of each scale sequence is automatically calculated. Therefore, it is only necessary to consider whether the set input length and prediction length are reasonable. Among them, kernel_size is the convolution kernel size, stride is the sliding step size, padding is padding, and padding is set to 0 due to multi-scale feature extraction. Len(y1), Len(y1), and Len(y3) refer to the lengths of y1, y2, and y3 respectively. len(y1)=T; Step S2: The data set is input into the multi-scale feature extraction module to obtain sequences of different scales. The data set obtained in step S1 is passed through the multi-scale feature extraction module, and the time series feature pyramid is constructed through the average pooling operation to obtain sequences of different scales. The average pooling calculates the average value within the pooling window through the pooling window and the pooling step size; suppose that n days of historical data are used for training, and the historical data of n days is x = (x1, x2, ..., x n ), it is necessary to predict the sales volume in the next m days. The sequence to be predicted in the future is y=(y1,y2,…,y m ), considering the limited historical data of commodities, only two average poolings are performed to obtain time series of different scales. The original input data is set to x, x1=x; x2 = AvgPool(x1); x3 = AvgPool(x2); In this way, we get sequence data x1, x2, and x3 of different scales. In the time dimension, x2 and x3 focus on larger granularity, that is, focus on trend features, which helps the model learn the trend information of the sequence and reduce the impact of short-term fluctuations. Step S3: Predict sequence data of different scales and output prediction results. The sequences of different scales obtained from step S2 are input into the Stack module, which is composed of multiple block modules in series. The block module consists of six fully connected layers and is divided into two parts. The first part is a fully connected layer that maps the input time series x1, x2, x3 into expansion coefficients. and Here we take x1 as an example, abbreviated as x l , h l,1 =FC l,1 (x e ); h l,2 =FC e,2 (x l,1 ); h l,3 =FC l,3 (x e,2 ); h l,4 =FC l,4 (x l,3 ); Among them, FC is a fully connected layer, using ReLu activation function, h l,1 ,h l,2 ,h l,3 ,h l,4 is the result of each fully connected layer using the ReLu function, x l,i =h e,i , the value of i ranges from 1, 2, 3, is the linear projection layer; Represent the forward and reverse expansion coefficients respectively; the expansion coefficient is understood as a low-dimensional vector that stores the intrinsic information of the time series; the second part is formed by the mapping function and Map the expansion coefficient back to the time series; as shown in the following formula, the reconstructed value of the current window and the prediction result of the future prediction window are obtained; in is the reconstructed value at the current window time point, The prediction of a point in time within the future prediction window; dim represents the dimension, are the i-th values of the backward and forward basis vectors, respectively, They are The i-th value of and The range of i values is and The range of i values is The input x of the current layer block module l Subtract the reconstructed value result Get the residual and input it to the next block as input. In this way, each layer of the prediction model needs to process the residual that the previous layer cannot fit correctly. It also plays a role in decomposing the time series layer by layer and predicting part of the time series. The final prediction result is the prediction result of multiple block modules. The sum of , that is, the predicted results y1, y2, y3; Step S4: Fusion of prediction results at different scales to obtain the final prediction result. In step S3, the prediction results y1, y2, and y3 are obtained through the fusion module to obtain the final prediction result. The fusion module uses y i and i-1 The concatenation method is then used to obtain the linear layer output with y i-1 The output results of the same length are fused upward layer by layer, that is, y3, and the fusion will obtain the result y′2 of the length of y2. The fusion of y′2 and y1 will obtain the final prediction result y; y′2=Linear(cat(y3,y2)); y = Linear(cat(y1,y′2)); In order to compare the error between the true value and the predicted value, the performance of the model is measured by two loss evaluation indicators, MSE and MAE; where y i is the true value, After the prediction model training is completed, it is restored through denormalization to obtain the product prediction result.
Citation Information
Patent Citations
Prophet-CEEMDAN-ARIMA-based commodity sales volume prediction method and Prophet-CEEMDAN-ARIMA-based commodity sales volume prediction device
CN111461786A
Retail product sales volume prediction method, tool, system and equipment and storage medium
CN114862459A
Instant lottery sales volume prediction method, apparatus and device, and medium
CN117035848A
Product sales prediction method and device, electronic equipment and storage medium
CN117710010A
Sales prediction method, medium, device and computing device
CN109886747A
