## 3 Pattern Recognition of Magnetic Field Data
### Classification Algorithm  
kNN classification algorithm is preferred to classify explosive and non-explosive materials. In the literature, it is clear that explosives can be detected by a kNN classification algorithm and significant results have been obtained [37; 39].  
kNN is a simple and widely used classification method [40]. kNN is a non-parametric approach that was widely applied to statistics in the early 1970s [41; 42; 43]. kNN is regarded as one of the top 10 algorithms in data mining, due to its simplicity, effectiveness, and implementation [41; 44]. The kNN-based classification technique can be effectively applied in real world and practical classification tasks in several fields, such as expert and intelligence systems [41]. The kNN algorithm is divided into two phases: the training phase and the classification phase [45]. The training examples are vectors in the multidimensional feature space. Each vector has a class label. The training phase of the algorithm only stores the feature vector (reference vector library) and class label of the training samples [45]. In the classification phase, k is a user-defined constant, and an unlabeled vector is classified by assigning the label which is most frequent among the k training samples nearest to that query point. In other words, the kNN method compares the query point or an input feature vector with a library of reference vectors, and the query point is identified to be of the class of library feature vectors to which it has the closest distance [45]. Several distance criteria have been used in previous studies, such as the Euclidean distance, correlation between samples, city block distance, cosine distance, and Hamming distance [46]. In this study, Euclidean distance criteria were used. which can be formulated as Equation (3).  
\[dist(x_{i},x_{j})=\sqrt{\sum_{d=1}^{D}(x_{i,d}-x_{j,d})^{2}}, \tag{3}\]where \(\text{dist}(\text{x}_{i}\text{x}_{j})\) represents the Euclidean distance between two data points \(\text{x}_{i}\) and \(\text{x}j\), and samples are represented by \(d\) feature dimensions [46].  
Success rate is one of the most important parameters giving information about whether the classifier is working effectively. Another parameter that is used to evaluate the success of the classifier is the reliability coefficient (\(\kappa\)), and it is described as the criterion used for giving the same result every time for the data being classified [47]. \(\kappa\) can be formulated as in Equation (4) [48].  
\[\kappa= \frac{\pi_{A}-\pi_{E}}{1-\pi_{E}}. \tag{4}\]  
\(\pi_{A}\) and \(\pi_{E}\) can be formulated as in Equations (5) and (6), respectively.  
\[\pi_{A}= \frac{TP+TN}{TP+TN+FP+FN} \tag{5}\]  
\[\pi_{E}= \frac{(TP+FP).(TP+FN)}{(TP+TN+FP+FN)^{2}}+\frac{(FN+TN).(FP+TN)}{(TP+ TN+FP+FN)^{2}}. \tag{6}\]  
In the Equations (5) and (6), TP, FP, TN, and FN are the predicted true positive, false positive, true negative, and false negative values, respectively.  
The basic success criteria and parameters of a classification or test are accuracy (ACC), sensitivity (SNS), specificity (SPC), positive/negative predictive values, and positive/negative likelihood ratios [47; 49]. ACC, SNS, and SPC can be formulated as Equation (7)-(8), respectively.  
\[ACC= \frac{TP+TN}{TP+TN+FP+FN} \tag{7}\] \[SNS= \frac{TP}{TP+FN} \tag{8}\]  
\[SPC= \frac{TN}{TN+FP}. \tag{9}\]  
FAR is an expression of performance used for misclassification of explosive detection. FAR can be formulated as Equation (9) [47].  
\[FAR= \frac{FP+FN}{TP+TN+FP+FN}. \tag{10}\]