## 5 Detection of the Robot Mounting Release from the Base Using Machine Learning Algorithms
### Testing Results and Discussion  
To prove that the selected machine learning algorithms can detect the robot's releasing at the base with an accuracy of 95% or higher by using specific parameters of the vibration signal, we tested the chosen machine learning models using new data gathered from sensor 2. The test data considered a total of 590 observations, including 297 normal sequences and 293 anomaly sequences. The resulting testing accuracy is shown in Table 9, sorted by highest accuracy. As can be seen, all models except Subspace KNN achieved a resulting accuracy on the test data above 95%. However, the percentage accuracy shows only the number of correct predictions (both positive and negative) out of all predictions (Formula (2)). Even though the test dataset can be considered consistent since the numbers of normal and abnormal samples are almost the same, we took a closer look at the performance of the models since, in real operations, misclassification of an anomalous sequence as normal can have serious consequences. \[Accuracy=\frac{TP+TN}{TP+TN+FP+FN} \tag{2}\]  
To examine the performance of the models using the new data, we used confusion matrices compiled for the Wide Neural Network model, which was the model with the highest accuracy, and the Subspace KNN model, which proved to have the lowest percentage accuracy. Using the confusion matrix helps to summarize the prediction results and gives an overview of how well the models perform in different classes. The confusion matrix allows a comprehensive view of the models using three more metrics, namely, recall, precision, and specificity, in addition to accuracy. Confusion matrices for the selected models are shown in Figure 10. \begin{table}
\begin{tabular}{c c c} \hline \hline
**Model Type** & **Preset** & **Accuracy \% (Test)** \\ \hline Neural Network & Wide Neural Network & 98.47 \\ Neural Network & Narrow Neural Network & 98.35 \\ Neural Network & Trilayered Neural Network & 97.97 \\ Neural Network & Bilayered Neural Network & 97.97 \\ Neural Network & Medium Neural Network & 97.29 \\ Ensemble & RUSBoosted Trees & 96.95 \\ Ensemble & Bagged Trees & 96.61 \\ Ensemble & Subspace KNN & 93.22 \\ \hline \hline \end{tabular}
\end{table} 
Table 9: Tested classification accuracy. The resulting accuracy of the model (Precision) is given by Equation (3), where _TP_, or true positive, refers to a sample that belongs to the class \"Normal\" and is correctly classified. _FP_, or false positive, represents the number of samples that have been classified as normal even though they represent anomalous data. This metric shows how many of the predicted positive cases were truly positive. High precision means a low rate of false positive cases [45]. \[Precision=\frac{TP}{TP+FP} \tag{3}\]  
Recall for the positive class shows the number of samples correctly predicted as belonging to the positive class out of all samples that truly belong to the positive class. This metric is represented by Equation (4), where _FN_, or false negative, refers to a sample that belongs to the normal class but is misclassified as belonging to the anomalous class [45]. \[Recall=\frac{TP}{TP+FN} \tag{4}\]  
Another particularly useful metric for the defined problem is specificity, which is the number of samples correctly assigned to the anomalous class out of all samples in the dataset that truly belong to the anomalous class. Specificity is calculated using Equation (5), where _TN_, or true negative, refers to the sample that belongs to the anomalous class and is correctly classified [45]. \[Specificity=\frac{TN}{TN+FP} \tag{5}\]  
These metrics were calculated for all tested models. The results are presented in Table 10. Calculated evaluation metrics.