# Machine Learning Prediction of Turning Precision Using Optimized XGBoost Model
## 3 Proposed Method
### Model Optimization  
Following the over-sampling process, optimization algorithms [21] were applied to further tune the parameters of the ML model. Four algorithms were considered, namely GA, GW, PSO and CPSO. The details of each algorithm are described in the following. The genetic algorithm (GA) optimizer [22] was a randomized search algorithm which imitated the processes of selection and reproduction in nature. The algorithm commenced by constructing an initial population of potential candidate solutions, where each candidate was encoded in the form of a string. A set of these candidates was then selected as the initial guessed values, and selection, crossover, and mutation operations were performed based on the fitness of these guessed values in order to create a new population of improved candidate solutions. The algorithm iterated in this way until the specified termination criteria were satisfied, at which point the candidate with the best fit was decoded and taken as the optimal solution. Figure 9 illustrates the basic workflow of the GA algorithm. Figure 8: Conceptual representation of the SMOGN algorithm. Figure 9: Conceptual representation of the GA algorithm. The grey wolf (GW) optimizer [23] is an intelligent optimization algorithm that mimics the group hunting behavior of grey wolves, and involves three main steps, namely, establishing hierarchy, encircling, and attacking. As shown in Figure 10, three solutions (alpha, beta, and delta) are first selected as the best solutions among the initial population. In each iteration, the position of the prey (i.e., the optimal solution) is updated according to the positions of these wolves, based on  
\[D=C\cdot X_{p}(t)-X(t) \tag{4}\]  
\[X(t+1)=X_{p}(t)-A\cdot D \tag{5}\]  
\[A=2\alpha\cdot r_{1}-\alpha \tag{6}\]  
\[C=2r_{2} \tag{7}\]  
where \(t\) is the current iteration; \(A\) and \(C\) are the auxiliary coefficient vectors; \(X_{p}(t)\) is the position vector of the prey; and \(X(t)\) is the current position vector of the wolves. \(\alpha\) drops from 2 to 0 as the iteration process proceeds, and \(r_{1}\) and \(r_{2}\) are random vectors in the interval of [0, 1]. In the hunting process, when \(\left|\overset{\rightarrow}{A}\right|>1\), the wolves diverge. By contrast, when \(\left|\overset{\rightarrow}{A}\right|<1\), they converge, and search a more localized area in order to pinpoint the prey. The particle swarm optimization (PSO) algorithm [24] encodes each candidate solution as a particle within the feasible search space, and gradually converges toward the optimal solution based on the individual and collective experiences of all the members of the swarm. As shown in Figure 11, the optimization process involves three iterative steps: (one) assigning the initial positions of all the particles and recording the position of the best solution among them, (two) calculating the acceleration vector for each particle and moving the particle to a new position, and (three) updating the personal best solutions of the individual particles and the global best solution. The related PSO equations are expressed as follows:  
\[X_{i}^{k+1}=X_{i}^{k}+V_{i}^{k+1} \tag{8}\]  
\[V_{i}^{k+1}=\omega V_{i}^{k}+c_{1}r_{1}\times\left(\textit{Pbes}t_{i}^{k}-X_{i }^{k}\right)+c_{2}r_{2}\times\left(\textit{Gbest}^{k}-X_{i}^{k}\right) \tag{9}\]  
Figure 10: Conceptual representation of the GWO algorithm. where \(V_{i}^{k}\) is the velocity of individual i in the k-th iteration, \(\omega\) is the weight, \(c_{1}\) and \(c_{2}\) are the acceleration constants, and \(r_{1}\) and \(r_{2}\) are random values in the interval [0, 1]. In addition, \(X_{i}^{k}\) is the position of individual \(i\) in the \(k\)-th iteration, \(\textit{Pbest}_{i}^{k}\) is the best position of individual \(i\) in each iteration, and \(\textit{Gbest}^{k}\) is the best solution in the entire domain.