# Quality Prediction and Parameter Optimisation of Resistance Spot Welding Using Machine Learning
## 2 Proposed Approach
### Cgo-MLSSVR Prediction Model  
Support vector regression, which is widely used in prediction tasks for small sample data, produces a better generalisation ability and can solve the dimensional catastrophe problem. By introducing kernel functions, SVR effectively solves the nonlinearity problem [26]. To solve the problem of accurate prediction with multiple inputs and multiple outputs in a small sample, the multi-output least squares support vector regression model was used. The multi-output least squares support vector regression prediction model needs to determine three parameters \(\theta=\left[\gamma,\,\lambda,\,\epsilon\right]\); the values of these parameters have a significant impact on the prediction accuracy of the model, where \(\gamma\) and \(\lambda\) are positive real regularisation parameters. The optimal parameter \(\theta\) for MLSSVR is obtained by the CGO method. The flow chart for the CGO-MLSSVR prediction method is shown in Figure 1. The following set of samples is used: \(\left\{\left(\mathbf{X_{i}},\mathbf{y_{i}}\right)\right\}_{i=1}^{1}\) with \(\mathbf{X_{i}}\in\mathbb{R}^{d}\) and \(\mathbf{y_{i}}\in\mathbb{R}^{m}\). Due to the large difference in the order of magnitude between the welding process parameters \(\mathbf{X_{i}}\) (welding voltage 1,welding voltage 2,welding time 1,welding time 2,cooling time, slow rise time, and slow drop time) and the welding quality indicators \(\mathbf{Y_{i}}\) (positive electrode nugget diameter, negative electrode nugget diameter, and tensile shear load), the data are first normalised to map the same dimension to [0, 1] to fit the calculations. Next, the normalised data are divided into training data and test data, and the relevant parameters of the MLSSVR and CGO algorithms are initialised. The CGO algorithm is used to continuously perform the adjustment of various parameter combinations to optimise the training MLSSVR model until the maximum number of iterations is reached. Finally, the MLSSVR model is trained under the optimal hyperparameters \(0^{\star}\) and the test data are used to predict the weld quality results and renormalise the predicted results. The regression function for the MLSSVR model is shown in Equation (1), the kernel function of the radial basis function (RBF) is adopted, the formula is Equation (2), and the fitness function for CGO is shown in Equation (3).  
\[\overline{y_{\mathrm{i}}}=\mathrm{repmat}(\sum\limits_{\mathrm{i=1}}^{\mathrm{ m}}\sum\limits_{\mathrm{j=1}}^{\mathrm{1}}\alpha_{\mathrm{ij}}^{\star}\kappa( \mathbf{X},\mathbf{X}_{\mathrm{j}}),1,\mathrm{m})+\frac{\mathrm{m}}{\lambda} \sum\limits_{\mathrm{j=1}}^{\mathrm{1}}\mathrm{a}^{\mathrm{j}\star}\kappa( \mathbf{X},\mathbf{X}_{\mathrm{j}})+\mathrm{b}^{\star\mathrm{T}} \tag{1}\]  
\[\kappa(\mathbf{X},\mathbf{X}_{\mathrm{j}})=\exp(-\varepsilon\|\mathbf{X}, \mathbf{X}_{\mathrm{j}}\|^{2}),\varepsilon>0 \tag{2}\]  
\[\mathrm{RMSE}=\sqrt{\frac{1}{\mathrm{n}}\sum\limits_{\mathrm{i=1}}^{\mathrm{ n}}\left(y_{\mathrm{i}}-\overline{y_{\mathrm{i}}}\right)^{2}} \tag{3}\]  
where \(\overline{y_{\mathrm{i}}}\) is the predicted value of the MLSSVR model, \(\alpha^{\star}\) is a vector consisting of Lagrange multipliers, \(\mathrm{b}^{\star}\) is the bias amount, \(\varepsilon\) is the coefficient of the kernel function, \(y_{\mathrm{i}}\) is the true value of the weld quality, and \(\mathrm{n}\) is the number of samples.