## 3 Machining Quality Prediction Method Based on XGBoost Hyperparameter Optimization
### Quality Prediction of Key Machining Characteristics of Marine Diesel Engine Piston
\begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Initial Random** & **Maximum Number** & **Selected Acquisition** & **Eta Optimization** \\
**Sampling Count** & **of Iterations** & **Function** & **Interval** \\ \hline
10 & 50 & EI & (0, 1) \\ \hline
**min\_child\_weight** & **max\_depth** & **\(\alpha\) optimization** & \(\lambda\)**optimization** \\
**optimization interval** & **optimization interval** & **interval** & **interval** \\ \hline (0, 10) & (3, 10) & (1, 5) & (1, 5) \\ \hline \hline \end{tabular}
\end{table} 
Table 7: Parameter settings of Bayesian optimization. \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Objective** & **Eta** & **Max\_Depth** & **Min\_Child\_Weight** & \(\alpha\) & \(\lambda\) \\ \hline \(-\)0.031 & 1.000 & 8.206 & 7.092 & 1.646 & 3.499 \\ \(-\)0.039 & 1.000 & 9.282 & 5.922 & 3.498 & 1.988 \\ \(-\)0.037 & 0.038 & 9.092 & 4.810 & 1.000 & 3.789 \\  
The XGBoost model needs to be verified on the training set, and its prediction accuracy and generalization ability on datasets other than the training set must be tested. The test set data is shown in Table 9. For testing the XGBoost model and finding the optimal parameters, it is necessary to predefine the testing range. Therefore, we set five groups of variables for parameter optimization, as shown in Table 9.  
The XGBoost model is trained iteratively 50 times. As the number of iterations increases, the change in root mean square error (RMSE) of the model on the training set and test set is shown in Figure 8. It can be seen from the figure that, with an increasing number of training iterations, the RMSE of the model on both the training set and the test set shows a decreasing trend. In the first 30 iterations, the RMSE of the model on both sets decreases rapidly. With the same number of iterations, the RMSE of the model on the training set is smaller than that on the test set. Figure 8: Change of root mean square error during model training. Figure 7: XGBoost model training process. \begin{table}
\begin{tabular}{c c c c c c c c} \hline \hline
**Serial Number** & \(n\) **(t/min)** & \(v\) **(m/min)** & \(f\) **(mm/min)** & \(a_{p}\) **(mm)** & \(\varepsilon_{1}\) **(mm)** & \(\varepsilon_{2}\) **(mm)** &
\begin{tabular}{c} **Processing** \\ **Quality (mm)** \\ \end{tabular} \\ \hline
1 & 500 & 50.265 & 25 & 0.30 & 0.117 & \(-0.033\) & 80.211 \\
2 & 600 & 60.319 & 30 & 0.40 & 0.099 & \(-0.017\) & 80.217 \\
3 & 700 & 70.372 & 40 & 0.50 & 0.023 & \(-0.027\) & 80.238 \\
4 & 800 & 80.425 & 20 & 0.45 & 0.126 & \(-0.030\) & 80.200 \\
5 & 900 & 90.478 & 35 & 0.35 & 0.019 & \(-0.044\) & 80.283 \\ \hline \hline \end{tabular}
\end{table} 
Table 9: Test dataset. The predicted and actual values of the trained XGBoost model on the test set are shown in Figure 9. The predicted values are consistent with the trends of the actual values, and the numerical differences are slight. The RMSE of the XGBoost model on the test set is 0.0307, which meets the accuracy requirements. XGBoost provides five indicators to measure the importance of features: the number of times a feature is used as a split feature (weight), the average feature return (gain), the average feature usage coverage (cover), the total feature return (total_gain), and the total feature usage coverage (total_cover). In this paper, weight is used as the evaluation index of feature importance, and each feature is sorted according to its importance in the XGBoost model. The ranking results are shown in Figure 10.  
Default values are assigned to each hyperparameter in the XGBoost framework, as shown in Table 6. To verify the effectiveness of hyperparameter optimization based on Bayesian optimization, the model is re-trained (referred to as Model 2) using default hyperparameters and compared with the previously trained model (referred to as Model 1). The root mean square error (RMSE) of Model 2 on the test set is 0.042, which is 0.03 higher than that of Model 1 (0.012).