# GNSS Spoofing Detection Based on Wavelets and Machine Learning
## 3 Methodology
### Application of Machine Learning Models for Spoofing Attack Detection
#### 3.4.1 Support Vector Machine (SVM)  
A support vector machine is a supervised machine learning method particularly used for classification and regression. The aim of the SVM method is to find an optimal hyperplane that separates the data points into different classes. An optimal hyperplane is defined as the linear decision function with the maximal margin between the vectors of the two classes [40]. In linearly separable data, SVM successfully finds separators, while in nonlinear separable data, it uses the kernel technique, projecting the data into a higher dimension where it is linearly separable.  
The support vector model is the simplest and is represented by the expression [40]  
\[h(\mathbf{x};\mathbf{w},w_{0})=\mathbf{w}^{\mathrm{T}}\mathbf{x}+w_{0} \tag{8}\]  
where \(\mathbf{x}\) is the input vector, \(\mathbf{w}\) is the weight vector, and \(w_{0}\) is a free member (bias). Often, the designation \(b\) is used instead of the \(w_{0}\) mark. The bias moves the hyperplane to the left or right. If \(w_{0}=0\), then the hyperplane always passes through the center of the coordinate system, which can limit the model and reduce its ability to properly separate the data. The boundary between the classes is the hyperplane \(h(\mathbf{x})=0\), which is mathematically defined by the following expression:  
\[\mathbf{w}^{\mathrm{T}}\mathbf{x}+w_{0}=0. \tag{9}\]  
The points closest to the margin are called support vectors and meet the following conditions:  
\[\mathbf{w}^{\mathrm{T}}\mathbf{x}_{i}+w_{0}=\pm 1. \tag{10}\]  
The supporting vectors lie on margins at a distance \(\frac{1}{\|\mathbf{w}\|}\) (this expression represents the width of the margin) from the hyperplane. They are important because they affect the limits of decision-making.  
The margin represents the distance of the hyperplane to the nearest sample. Since the goal of this method is to obtain the maximum margin, it is necessary to find such a hyperplane that will maximize this distance:  
\[\arg\max_{\mathbf{w},w_{0}}\biggl{\{}\frac{1}{\|\mathbf{w}\|}\min_{i}\Bigl{\{} y^{(i)}(\mathbf{w}^{\mathrm{T}}\mathbf{x}^{(i)}+w_{0})\Bigr{\}}\biggr{\}} \tag{11}\]  
where for each hyperplane (function _argmax_ iterates over all hyperplanes), the minimum distance to the nearest sample is calculated and the hyperplane for which this distance is the greatest is taken. For a hyperplane that maximizes the margin, the patterns on the left and right are equidistant from it.  
The final expression for the maximum margin optimization problem, or the so-called quadratic programming problem, is  
\[\arg\min\ \frac{1}{2}\|\mathbf{w}\|^{2} \tag{12}\]  
with the condition  
\[y^{(i)}(\mathbf{w}^{\mathrm{T}}\mathbf{x}^{(i)}+w_{0})\geqslant 1,\quad i=1, \ldots,N. \tag{13}\]  
If the data are not linearly separable, the SVM uses a kernel function to map the data into a multidimensional space where it becomes linearly separable. The most commonly used core functions are linear, polynomial, and radial base functions. Once the optimal hyperplane is found, the SVM can be used to classify new data points by checking which side of the hyperplane they are on. In summary, the support vector machine is an effective algorithm which solves complex classification problems by finding the optimal hyperplane that maximizes the margin between classes.