## 3 Machining Quality Prediction Method Based on XGBoost Hyperparameter Optimization
### Bayesian Optimization of Hyperparameters  
In the XGBoost model, hyperparameter settings directly impact the model's predictive performance. Bayesian optimization (BO) is a sequential model optimization method used for black-box function optimization. The pseudocode for the Bayesian optimization algorithm is shown in Table 1. It primarily consists of two core components: the probabilistic surrogate model and the acquisition function. The surrogate model fits the objective function and is recursively estimated based on the known data-optimal value [33]. Common surrogate models include the Gaussian process, random forest, Beta-Bernoulli model, etc. Among these, the Gaussian process has a significant advantage due to its integration of parameter uncertainty [34]. Therefore, this study employs the Gaussian process as the surrogate model for Bayesian optimization. A Gaussian process is characterized by its mean function \(\mu(x)\) and covariance function \(k(x,x^{\prime})\), as follows:  
\[f(x)\,\sim GP\bigl{(}\mu(x),k\bigl{(}x,x^{\prime}\bigr{)}\bigr{)} \tag{15}\]  
where the mean function \(\mu(x)\) satisfies \(\mu(x)=\mathrm{E}[q(x)]\), and the covariance function \(k(x,x^{\prime})\) satisfies \(k(x,x^{\prime})=\mathrm{E}[(q(x)-\mu(x))(q(x^{\prime})-\mu(x^{\prime}))]\). \begin{table}
\begin{tabular}{c c} \hline \hline \multirow{2}{*}{**Input:**} & **The Initial Sample Number N, the Maximum Number of Iterations T, the Decision Space \(\boldsymbol{\
abla}\), and the Optimal Sampling Point \(x^{*}\) Are Initialized.** \\ \hline Step 1 & In the decision space \(\boldsymbol{\
abla}\), N sample points are extracted according to uniform distribution. \\ Step 2 & The objective function value is obtained by evaluating the initial sample points, and the dataset \(\zeta\) is constructed to obtain the current optimal \(x^{*}\). \\ Step 3 & The Gaussian surrogate model GP is constructed. \\ Step 4 & For \(t=1,2,3,\cdots,\,T\) do \\ Step 5 & The maximum value of the acquisition function is calculated, and a new sampling point is obtained at the maximum value. \\ Step 6 & Evaluate the new sampling point, update the dataset \(\zeta\), and update the optimal sampling point \(x^{*}\). \\ Step 7 & Update the Gaussian surrogate model GP. \\ Step 8 & End For \\ output: & Optimal sampling point \(x^{*}\) \\ input: & The initial sample number N, the maximum number of iterations T, the decision space \(\boldsymbol{\
abla}\), and the optimal sampling point \(x^{*}\) are initialized. \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Bayesian optimization pseudocode. In practical engineering applications, it is often challenging to provide a highly reasonable prior mean function, so \(\mu(x)\) is frequently set to 0 [34]. The covariance function characterizes the degree of correlation between two points in the decision space. The norm is commonly used to measure the distance between two points. A smaller norm between two points indicates a higher correlation and a larger value of the covariance function, which satisfies the following Equation (16):  
\[k(x,x_{1})>k(x,x_{2}),if||x-x_{1}||<||x-x_{2}|| \tag{16}\]  
Selecting an appropriate covariance function is crucial. Common stationary covariance functions include the Matern, exponential, and Gaussian kernel functions. This paper chooses the Matern function for its flexibility [35], as shown in Equation (17). The hyperparameters in the following Equation (17) are optimized by maximizing the marginal likelihood [35]:  
\[k(x,x^{\prime})=\frac{2^{1-\
u}}{\Gamma(\
u)}\Bigg{(}\frac{\sqrt{2\
u}r}{l} \Bigg{)}^{\
u}K_{\
u}\Bigg{(}\frac{\sqrt{2\
u}r}{l}\Bigg{)} \tag{17}\]  
where \(\Gamma(\cdot)\) is the \(\Gamma\) function; \(r=|x-x^{\prime}|;\
u,l\) is a constant greater than 0; \(K_{\
u}\) is the improved Bessel function. In iterative Gaussian process regression, the actual function value \(q(\mathbf{x})\) of the input \(\mathbf{x}\) can be theoretically calculated. However, in practical applications, \(q(\mathbf{x})\) is often not calculated but observed.