# One-Class SVM Model-Based Tunnel Personnel Safety Detection Technology
## 2 Introduction of One-Class SVM Algorithm  
This subsection introduces the basic principle of the OCSVM algorithm (one-class support vector machine) [15]. We train the OCSVM on normal data samples and establish an optimal hyperplane in the feature space, in accordance with the principle of maximizing the interval value to achieve the separation of the training samples and their origin. A schematic diagram of the algorithm is shown in Figure 1.  
Figure 1: Schematic diagram of support vector classifier.  
We let the dataset of normal samples be \(X=[x_{1},x_{2},\ldots,x_{n}]^{T}\in R^{N\times L}\), and the target decision hyperplane be \(f(x)=\omega\phi(x)-\rho=0\). We construct and solve the optimization problem:  
\[\underset{\omega\in F,\xi}{min}\frac{1}{2}\parallel\omega\parallel^{2}+\frac{ 1}{N_{v}}\underset{i=1}{\overset{N}{\underset{i=1}{\sum}}}\xi_{i}-\rho \tag{1}\]  
\[s.t.\ \omega\phi(x_{i})\geq\rho-\xi_{i},\xi_{i}\geq 0 \tag{2}\]  
In the above equation, \(N\) is the length of the dataset used for training; \(v\) is the regularization parameter; \(\xi_{i}\) is the slack variable corresponding to each dataset; \(\omega\) and \(\rho\) are the decision planes that can be decided with participation; and \(\phi\) is the way the data are spatially mapped [16]. Next, the OCSVM model is solved by introducing Lagrange multipliers \(\alpha_{i}\geq 0\) and \(\beta_{i}\geq 0\) and solving the Lagrange equations [17] as follows.  
\[L(\omega,\xi,\rho,\alpha,\beta)=\frac{1}{2}\parallel\omega\parallel^{2}+\frac {1}{N_{v}}\sum_{i=1}^{N}\xi_{i}-\rho-\sum_{i=1}^{N}\alpha_{i}[\omega\phi(x_{i} )-\rho+\xi_{i}]-\sum_{i=1}^{N}\beta_{i}\xi_{i} \tag{3}\]  
The pairwise form of the optimization problem can be obtained by partial differentiation of the variables in the above equations [11]:  
\[\underset{\alpha}{\min}^{T}H\alpha \tag{4}\]  
\[s.t.\ \leq\alpha_{i}\leq\frac{1}{N_{v}},\sum_{i=1}^{N}\alpha_{i}=1 \tag{5}\]  
\(H\) is the kernel matrix consisting of \(H_{ij}\), and \(H_{ij}\) can be expressed as:  
\[H_{ij}=K\big{(}x_{i},x_{j}\big{)}=\phi(x_{i})\phi\big{(}x_{j}\big{)} \tag{6}\]  
\(K\big{(}x_{i},x_{j}\big{)}\) is the kernel function, which in this paper are linear and Gaussian kernel functions [17]. As for the RBF kernel function, there is only one parameter \(\sigma\) to be adjusted, which directly affects the width of the RBF kernel function, and the calculation formula is shown in Equation (7).  
\[K\big{(}x_{i},x_{j}\big{)}=e^{\frac{-\|x_{i}-x_{j}\|^{2}}{2\sigma^{2}}} \tag{7}\]  
By solving the above quadratic programming problem, \(\alpha\) can be solved, whereupon \(\omega\) and \(\rho\) can be computed separately [18]:  
\[\omega=\sum_{i=1}^{N}\alpha_{i}\phi(x_{i}) \tag{8}\]  
\[\rho=\sum_{j=1}^{N}\alpha_{j}K\big{(}x_{i},x_{j}\big{)} \tag{9}\]  
A decisional hyperplane in the feature space can be found from the solved \(\omega\) and \(\rho\).  
For the training set \(Z=[z_{1},\cdots,z_{M}]^{T}e^{R\times L}\), a decision function \(F(z_{k})(k=0,1,\cdots,M)\) based on the Euclidean distance is established for classifying the test sample \(z_{k}\)[19].  
\[F(z_{k})=sign[\omega\ \phi(z_{k})-\rho] \tag{10}\]  
The decision function \(F(z_{k})\) of the test sample \(z_{k}\) is calculated by determining the position of \(z_{k}\) in relation to the decision hyperplane. If \(F(z_{k})=+1\), \(z_{k}\) falls within the decision hyperplane and is classified as a positive class, which can be judged as a normal sample; if \(F(z_{k})=-1\), \(z_{k}\) falls outside the decision hyperplane and is classified as a negative class, which can be judged as an abnormal sample [20].  
The flow chart of the algorithm is shown in Figure 2.