# Bayesian Network Demand-Forecasting Model Based on Modified Particle Swarm Optimization
## 2 Bayesian Network Model Construction
### Model Prediction Process  
The current customer demand data are \(y_{1}\), \(y_{2}\),..., \(y_{T}\). The hidden layer parameter \(\hat{\eta}_{1}\), \(\hat{\eta}_{2}\),..., \(\hat{\eta}_{T}\) and the hyper-parameter layers \(\hat{\gamma}\), \(\hat{\beta}\), \(\hat{\eta}\), \(\hat{\phi}\) corresponding to \(y\) at each moment are obtained by using Algorithm 1. According to Equation (9), the estimation of the next hidden layer parameter \(\eta_{T+1}\) can be obtained, and then, according to Equation (8), the estimation of the next requirement \(y_{T+1}\) can be obtained. Repeat this process, and \"\(\hat{\eta}_{T+1}\to\hat{y}_{T+1}\to\hat{\eta}_{T+2}\to\hat{y}_{T+2}\)...\" can be obtained in turn. The specific prediction process is shown in Algorithm 2. ``` Input: Customer historical demand data \(y=(y_{1},y_{2},\ldots,y_{T})\); objective function Equation (20); decision variables: \(\eta\in[0\), max(\(\eta_{t}\)), \(\gamma\in[0,3\sigma_{\gamma}]\), \(\beta\in[-3\sigma_{\beta},3\sigma_{\beta}]\), \(\mu\in[0,m_{0}+



## 4 Experiment

### Data Description Statistics

In this section, based on the prediction model and solution method proposed in this paper, the dataset of the \"DataFountain\" platform is used as a sample to predict the commodity demand of an e-commerce enterprise for the next week. In this paper, the three attributes of sku_id, goods_num, and data_date in this dataset are used to randomly select commodities with sku_id as \"SK4 taRSU\", \"SKILr87U\", and \"SKJCqIoN\" as experimental datasets DS-1, DS-2, and DS-3. In order to verify the accuracy of the prediction results, the product sales volume from 1 March 2017 to 29 October 2017 is used as the training data, and the product sales volume from 30 October 2017 to 5 November 2017 is used as the test set for verification. The online retail dataset DS-4 was also selected from UCI, which includes transactions from a UK e-commerce company for 374 days from 1 December 2010 to 9 December 2011. Because of Christmas and the New Year, there are 11 consecutive days of blank records in the dataset. Therefore, after removing the blank record, this paper selected the commodity with the most complete sales record and summarized the sales quantity by week to get the data of 51 weeks for the experiment. In addition, this paper also features the sales data DS-5 and DS-6 of two kinds of commodities on an e-commerce platform for the experiment. The sequence diagrams of the DS-1-6 datasets are shown in Figure 5:

Figure 5: _Cont_. As can be seen from the time series graphs, not only the fluctuations of adjacent time nodes are large, but also the overall volatility of these six datasets is strong, which poses a great challenge to the demand-forecasting problem. Table 1 summarizes some statistical features of DS-1 to 6. It can be seen from Table 1 that the dispersion coefficients of these six datasets are very high, and the fluctuations are quite dramatic, which is consistent with the results of the time series diagram. Therefore, it is reasonable to add the volatility factor \(\gamma\) to the model established in this paper. ### Results of Measurement

In terms of the measurement results, RMSE (Root Mean Square Error, RMSE) and MAPE (Mean Absolute Percentage Error) are used as the evaluation indicators of the algorithm proposed in this chapter. RMSE is used to measure the absolute error between the predicted value and the actual value, and MAPE reflects the relative size of the error between the predicted value and the actual value. The smaller the value of the above two evaluation indicators, the higher the prediction accuracy. Suppose at points 1, 2, 3, \(\ldots\), \(n\), the actual quantity of the customer demand for goods is \(y_{1}\), \(y_{2}\), \(y_{3}\), \(\ldots\), \(y_{n}\). The