# Prediction of Grain Porosity Based on WOA-BPNN and Grain Compression Experiment
## 5 Analysis of Prediction Results  
### Comparison of Porosity Prediction Results from Five Machine Learning Models  
The prediction of grain porosity involves a regression problem, and there are numerous machine learning algorithms that can be utilized. In order to construct a machine learning model with high prediction accuracy, this paper compared three hybrid models (GA-BPNN, PSO-BPNN, and WOA-BPNN) with two single models (BPNN and RF). Figure 6 displays the predicted and actual values of the BPNN, RF, GA-BPNN, PSO-BPNN, and WOA-BPNN models based on the test set. Figure 7 displays the absolute error between the predicted and actual values of the five machine learning models as determined by the test set. From Figure 6, it is evident that there was a significant difference between the predicted and actual values of the BPNN and RF models, while the predicted values of the three hybrid models GA-BPNN, PSO-BPNN, and WOA-BPNN were closer to the actual values. From Figure 7, it can be observed that the absolute errors of the three hybrid models were smaller than those of the two single models.  
Table 4 shows the computational efficiency of the five machine learning models. From Table 4, it can be seen that the random forest model had the shortest computational time (0.2570 s), while the WOA-BP model had the longest computational time (37.6912 s). Table 5 presents the values of the four evaluation metrics (R\({}^{2}\), RMSE, MAE, and MAPE) for the five machine learning models. From Table 5, it is evident that the WOA-BPNN model exhibited the highest R\({}^{2}\) value and the lowest RMSE, MAE, and MAPE values, while the RF model showed the lowest R\({}^{2}\) value and the highest RMSE, MAE, and MAPE values. Based on the values of the four evaluation metrics, it can be observed that the prediction accuracies of the five machine learning models were ranked from highest to lowest as WOA-BPNN, GA-BPNN, PSO-BPNN, BPNN, and RF. Combining Tables 4 and 5, it can be observed that while the computational efficiency of the RF model was high, the predictive performance of this model was poor. The computational efficiency of the WOA-BP model was lower than that of the other four models, but the prediction accuracy of the WOA-BP model was high. This high accuracy could meet the requirements for predicting grain porosity in this study. Figure 8 displays the radar charts of the four evaluation metrics, providing a more intuitive way to observe the prediction effect of each model. It can also be observed from Figure 8 that the WOA-BPNN model yielded the most accurate predictions.  
\begin{table}
\begin{tabular}{c c} \hline \hline
**Model** & **Running Time/Second** \\ \hline BP & 1.4812 \\ \hline RF & 0.2570 \\ \hline GA–BP & 7.5487 \\ \hline PSO–BP & 4.0655 \\ \hline WOA–BP & 37.6912 \\ \hline \hline \end{tabular}
\end{table}
Table 4: Computational efficiency of the five machine learning models.  
\begin{table}
\begin{tabular}{c c c c c} \hline
**Model** & **R2** & **RMSE** & **MAE** & **MAPE/\%** \\ \hline BPNN & 0.8874 & 0.0129 & 0.0088 & 2.2208 \\ \hline RF & 0.8572 & 0.0155 & 0.0094 & 2.3517 \\ \hline GA–BPNN & 0.9450 & 0.0081 & 0.0049 & 1.2735 \\ \hline PSO–BPNN & 0.9299 & 0.0102 & 0.0063 & 1.6213 \\ \hline WOA–BPNN & 0.9542 & 0.0079 & 0.0044 & 1.1467 \\ \hline \end{tabular}
\end{table}
Table 5: Values of the evaluation metrics for the five machine learning models.  
Figure 6: Predicted versus actual values of porosity for five machine learning models based on the test set: (**a**) BPNN; (**b**) RF; (**c**) GA–BPNN; (**d**) PSO–BPNN; (**e**) WOA–BPNN.  
Figure 7: Absolute error plots for the five machine learning models based on the test set: (**a**) BPNN; (**b**) RF; (**c**) GA–BPNN; (**d**) PSO–BPNN; (**e**) WOA–BPNN.