## 3 Machining Quality Prediction Method Based on XGBoost Hyperparameter Optimization
### Quality Prediction of Key Machining Characteristics of Marine Diesel Engine Piston
Some of the training data after anomaly detection are shown in Table 5.  
Before training the model, it is necessary to identify which hyperparameters should be optimized. XGBoost has many hyperparameters, and some of the more critical ones are listed in Table 6. When using Bayesian optimization to optimize the hyperparameters of the XGBoost model, the more hyperparameters that are optimized, the greater the computing power required. Therefore, optimizing essential hyperparameters can significantly improve model performance with less computation. This paper focuses on optimizing the first five hyperparameters--eta, min_child_weight, max_depth, alpha, and lambda--as shown in Table 6. \begin{table}
\begin{tabular}{c c c c c c c c} \hline \hline \multirow{2}{*}{**Serial Number**} & \multicolumn{5}{c}{**Input**} & \multicolumn{5}{c}{**Output**} \\ \cline{2-7}  & \(n\) **(r/min)** & \(v\) **(m/min)** & \(f\) **(mm/min)** & \(a_{p}\) **(mm)** & \(\varepsilon_{1}\) **(mm)** & \(\varepsilon_{2}\) **(mm)** & **Processing Quality (mm)** \\ \hline
1 & 500 & 50.265 & 20 & 0.30 & \(-\)0.035 & 0.064 & 80.211 \\ \hline
2 & 500 & 50.265 & 25 & 0.40 & \(-\)0.032 & 0.117 & 80.209 \\ \hline
3 & 500 & 50.265 & 30 & 0.50 & \(-\)0.030 & 0.174 & 80.207 \\ \hline \(\ldots\) & \(\ldots\) & \(\ldots\) & \(\ldots\) & \(\ldots\) & \(\ldots\) & \(\ldots\) \\ \hline
25 & 900 & 90.478 & 40 & 0.5 & \(-\)0.024 & 0.103 & 80.258 \\ \hline \hline \end{tabular}
\end{table} 
Table 5: Partial training dataset after anomaly detection. Figure 6: Partial piston machining process network. The dataset in Table 5 is divided, and the model's hyperparameters are optimized with the minimization of the evaluation results of five-fold cross-validation as the optimization goal. During the hyperparameter optimization process, each parameter's setting is shown in Table 7.  
Table 8 records the data of the first five iterations of Bayesian optimization and the obtained optimal hyperparameters (last row). The objective function values corresponding to different hyperparameter combinations vary, and the hyperparameter set corresponding to the smallest objective function value is considered optimal. It should be noted that the objective function value is the negative of the five-fold cross-validation test results. This transformation is necessary because the optimization program aims to maximize the objective function, so taking its negative converts it into the minimization of the five-fold cross-validation test results. After obtaining the optimal hyperparameters, the XGBoost model can be trained, with the training process illustrated in Figure 7. \begin{table}
\begin{tabular}{c c c} \hline \hline
**Parameter Name** & **Default Value** & **Parameter Description** \\ \hline eta & 0.3 & Learning rate, eta \(\in[0,1]\), commonly used values are 0.01–0.2. \\ min\_child\_weight & 1 & Child nodes contain the smallest sum of instance weights, \\  max\_depth & 6 & Maximum depth of tree, max\_depth \(\in[1,\infty]\), commonly used values are 3–10. \\ \(\alpha\) & 1 & The L1 regular term of the weight, the larger the value, the more conservative the model is. \\ \(\lambda\) & 1 & The L2 regular term of the weight, the larger the value, the more conservative the model is. \\ \(\gamma\) & 0 & Minimum loss reduction required for leaf node splitting, gamma \(\in[0,\infty]\). \\ max\_delta\_step & 0 & Maximum incremental step size allowed for each tree weight estimation, \\  scale\_pos\_weight & 1 & The balance of positive and negative sample weights is controlled when the \\  subsample & 1 & Sampling rate of training samples, subsample \(\in(0,1]\). \\........ &........ &........ \\ \hline \hline \end{tabular}
\end{table} 
Table 6: XGBoost partial hyperparameters.