# Bayesian Network Demand-Forecasting Model Based on Modified Particle Swarm Optimization
## 2 Bayesian Network Model Construction
### Model Prediction Process
\begin{table}
\begin{tabular}{l l l l l l l} \hline \hline
**Dataset** & **DS-1** & **DS-2** & **DS-3** & **DS-4** & **DS-5** & **DS-6** \\ \hline Unit of time & day & day & day & week & day & day \\ The length & 250 & 250 & 250 & 51 & 611 & 611 \\ The mean & 32.83 & 168.11 & 61.02 & 449.22 & 3.50 & 2.00 \\ Standard deviation & 26.79 & 75.98 & 48.31 & 481.19 & 4.01 & 2.56 \\ Dispersion coefficient & 0.82 & 0.45 & 0.79 & 1.07 & 1.14 & 1.31 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Description statistics for datasets DS-1 to 6. Figure 5: Sequence diagrams for datasets DS-1 to 6.

corresponding results predicted by the algorithm are \(\hat{y}_{1},\;\hat{y}_{2},\;\hat{y}_{3},\;\ldots,\;\hat{y}_{n}\). The calculation formulas of RMSE and MAPE are as follows:

\[RMSE=\sqrt{\frac{\sum\limits_{i=1}^{n}{{{({\hat{y}_{i}-y_{i}})}^{2}}}}}{n} \tag{25}\]

\[MAPE=\frac{1}{n}{\sum\limits_{i=1}^{n}{\left|{\frac{{{y_{i}-\hat{y}_{i}}}}{{{y_ {i}}}}}\right|}} \tag{26}\]

### Parameter Adjustment of the Model

This subsection discusses the parameter tuning process of the model. There are six tuning parameters in the model, among which \(\sigma_{\mu}\) and \(\sigma_{\phi}\) act on the hyperparametric variables \(\mu\) and \(\phi\), and \(\sigma_{\gamma}\) and \(\sigma_{\beta}\) act on the variables \(\gamma\) and \(\beta\). These parameters are mainly used to smooth the estimation results of the above variables. Empirically, the setting of these parameters does not have a significant effect on the prediction results. Therefore, for the convenience of adjustment, set these parameters as 1, and let \(\alpha\) be \(\sigma_{y}{}^{-2}\). Different from the above parameters, the parameters \(\alpha\) and \(H\) directly act on the observation data \(y\), so the selection of \(\alpha\) and \(H\) has a direct impact on the performance of the model. This work focus on the regulation of \(H\) and parameter \(\alpha\). For datasets DS-1-3, the product sales volumes from 1 March 2017 to 29 October 2017 are used as the training data, and the product sales volumes from 30 October 2017 to 5 November 2017 are used as the test set to adjust parameter \(H\). The first 90% of the data in datasets DS-4-6 were selected as training data for model fitting, and the last 10% of the data as model validation. #### 4.3.1 Adjustment of Parameter H

During the adjustment of parameter \(H\), the training set in the dataset traverses all values of \(H\in\) [1,30]. Fixed \(\sigma_{y}\) is the variance of the training set used for fitting, and RMSE is used as the measurement standard. The experimental results are shown as follows:

Based on the results in Figure 6, it can be seen that the variation trend of the value of period \(H\) presents different characteristics in different datasets. Therefore, it is further verified that the selection of the period \(H\) value plays a crucial role in the prediction performance of the model. Figure 6: _Cont._

Parameter \(H\) is the periodic factor of the volatility factor \(\gamma_{t}\) in the model. If the sample data are sensitive to parameter \(H\), it indicates that the fluctuation of the sample data is regular, which may be because the customer's behavior of purchasing the product usually has certain regularity. Therefore, choosing an appropriate period \(H\) has a great influence on the accuracy of prediction. If the variation range of prediction error is small with the change of \(H\), then \(H\) is generally selected within a reasonable range, and the prediction accuracy of the algorithm can be guaranteed. Finally, according to Figure 6, the value of \(H\) on each dataset can be obtained, as shown in Table 2:

#### 4.3.2 Adjustment of Parameter \(\alpha\)

This section discusses the tuning of the parameter \(\alpha\). Similar to the above section, each training set of DS-1 to 6 is used to verify the possible value of \(\alpha\).