# Real-time Monitoring for Disk Laser Welding Based on Feature Selection and SVM
## 2 Methods  
### Support Vector Machine (SVM)  
The SVM [17; 18; 19] method can be briefly described as follows.  
Given a binary classification task with datapoints \(x_{i}\) (\(i=1,...,N\)) and corresponding labels \(y_{i}=\pm 1\). Each datapoint represents a \(d\)-dimensional input.  
Assuming that the given datapoints are linearly separable, there exist hyperplanes that correctly separate all the points. The SVM method attempts to identify these separating hyperplanes. The definition for the separating hyperplane in multidimensional space is:  
\[w\cdot x+b=0,\ w\in R^{d},\ b\in R \tag{1}\]  
The vector \(w\) determines the orientation of the discriminant plane and the scalar \(b\) determines the offset of the hyperplane from the origin.  
The margin between two classes determines the generalization ability of a separating hyperplane; therefore, the support vector algorithm simply looks for the separating hyperplane with the largest margin. While the margin of a separating hyperplane is calculated as \(2/||w||\), where \(||w||\) is the Euclidean norm of \(w\), the problem can be formulated as:  
\[\begin{split}\min_{w,b}&\ \frac{1}{2}||w||^{2}\\ s.t.&\ y_{i}(w\cdot x_{i}+b)-1\geq 0,i=1,2,\ldots,N \end{split} \tag{2}\]As a constrained optimization problem, the Lagrange multiplier vector \(\alpha=\{\alpha_{i}|\alpha_{i}\geq 0,i=1,\ldots,N\}\) is introduced and the Lagrange function is:  
\[L(w,b,\alpha)=\frac{1}{2}||w||^{2}-\sum\limits_{i=1}^{N}\alpha_{i}y_{i}(w\cdot x _{i}+b)+\sum\limits_{i=1}^{N}\alpha_{i} \tag{3}\]  
Then the primal optimization problem can be rewritten as the dual problem:  
\[\begin{split}\min\limits_{\alpha}\frac{1}{2}\sum\limits_{i=1}^{N }\sum\limits_{j=1}^{N}\alpha_{i}\alpha_{j}y_{j}(x_{i}\cdot x_{j})-\sum\limits _{i=1}^{N}\alpha_{i}\\ s.t.\sum\limits_{i=1}^{N}\alpha_{i}y_{i}=0\\ \alpha_{i}\geq 0\ i=1,\ldots,N\end{split} \tag{4}\]  
In most cases, outliers exist, which means the data set is linearly separable when a few data points are removed. The SVM method tolerates these outliers by adding the penalty factor \(C\) and changing the dual problem to:  
\[\begin{split}\min\limits_{\alpha}\frac{1}{2}\sum\limits_{i=1}^{N }\sum\limits_{j=1}^{N}\alpha_{i}\alpha_{j}y_{j}(x_{i}\cdot x_{j})-\sum\limits _{i=1}^{N}\alpha_{i}\\ s.t.\sum\limits_{i=1}^{N}\alpha_{i}y_{i}=0\\ 0\leq\alpha_{i}\leq C\ i=1,\ldots,N\end{split} \tag{5}\]  
\(C\) determines the punishment for the outliers.  
This is a convex quadratic programming problem, and there are many effective robust algorithms for solving it. The solution \(\alpha^{*}\) can be used to calculate \(w^{*}\) and \(b^{*}\). Then, the optimal separating hyperplane is:  
\[w^{*}\cdot x+b^{*}=0 \tag{6}\]  
and the SVM classification function is:  
\[f(x)=sign(w^{*}\cdot x+b^{*}) \tag{7}\]  
The method above is called linear SVM, which assumes the training data set is linearly separable (or almost linearly separable), and that a linear separating surface can be found. But in many cases, the datapoints are not linearly separable, and the function of the optimal separating surface may be nonlinear. By using a method called kernel trick, the SVM method can be extended to handle this kind of problem. The main idea is mapping the input data onto a higher dimensional space called feature space and then performing linear classification there. This can be done implicitly by replacing the inner product with kernel function.  
Several kernel functions have been explored, such as polynomial kernels, sigmoid kernels and radial basis function (RBF) kernels. The RBF kernel is one of the most widely applied kernel functions, usually in its Gaussian form:  
\[k(x,x^{\prime})=\exp(-\frac{||x-x^{\prime}||^{2}}{2\sigma^{2}}) \tag{8}\]  
The parameter \(\sigma\) determines the radial range of the function.  
Generally, the performance of the RBF kernel is satisfactory, and the parameter setting is relatively simple, thus the RBF kernel is applied in this study.