# GNSS Spoofing Detection Based on Wavelets and Machine Learning
## 3 Methodology
### Model Performance Parameters  
Classification models have a discrete output, and parameters that compare discrete classes are needed. The accuracy alone is not sufficient to determine the reliability of the model, and therefore additional performance metrics are used, which are described below.  
1. A confusion matrix, also known as an error matrix, is a special type of table that allows the performance of an algorithm to be visualized. Each row in the matrix represents patterns in the actual class, and each column represents patterns in the predicted class. The confusion matrix consists of four fields: true positive \(TP\), true negative \(TN\), false positive \(FP\), and false negative \(FN\)[47].
2. Accuracy is defined as the number of correctly predicted samples divided by the total number of predicted samples and is calculated as \[ACC=\frac{T_{p}+T_{n}}{T_{p}+F_{p}+T_{n}+F_{n}}\times 100.\] (15) where \(T_{p}\) is the number of true positive predicted samples, \(F_{n}\) is the number of false negative predicted samples, \(F_{p}\) defines the number of false positive predicted samples, and \(T_{n}\) defines the number of true negative predicted samples.
3. Precision or positive predictive value is the number of really positive predicted samples divided by the total number of positive predicted samples (\(T_{p}+F_{p}\)). The value of this parameter is between 0 and 1. \[P=\frac{T_{p}}{T_{p}+F_{p}},\quad 0<P<1.\] (16) Low precision (\(P<0.5\)) means that the classifier has a large number of false positive samples that may be the result of an unbalanced class or unadjusted model hyperparameters. When the precision value is close to 1, it means the model has not missed any real positive results and is able to classify correct and incorrect sample labeling well.  
The recall or sensitivity or real positive rate gives the percentage of positive results well predicted by a particular model. In other words, it gives the proportion of real positive samples that the model has correctly classified.  
\[R=TPR=\frac{T_{p}}{T_{p}+F_{n}},\quad 0<R<1. \tag{17}\]  
A low recall (\(R<0.5\)) means that the classifier has a large number of false negative samples that may be the result of an unbalanced class or unadjusted model hyperparameters. Ideally, \(R=1\), i.e., all positive samples are marked as such by the classifier. Ideally, all positively classified samples are really positive (\(P=1\)), and, conversely, all positive samples are also classified as positive (\(R=1\)).
5. F1-score is a key parameter in evaluating the performance of classification models. F1 measures the performance of the model by balancing the precision and recall which are two directly opposing measures (high response means low accuracy and vice versa), providing a unique score that reflects both false positives and false negatives. It is the harmonic mean of precision and recall.  
\[F1=\frac{2}{\frac{1}{P}+\frac{1}{R}}=\frac{2T_{p}}{2T_{p}+F_{p}+F_{n}},\quad 0 <F1<1. \tag{18}\]  
\(F1\) scores range from the best value of 1 to the worst value of 0. For example, if \(P=0.1\) and \(R=0.8\), the \(F1\)-score is 0.178, while the arithmetic mean would be 0.4, and therefore a stricter criterion should be taken when evaluating classifiers.