## 6 Data Analysis
### Analysis of Samples from Pure Datasets  
As stated in the previous section, the dataset that contains the recorded data per travel, is a matrix of 476 rows by 25 columns. The analysis of this dataset starts by exploring the behavior of the K-nearest-neighbors algorithm (KNN) against all dimensions. Table 3 presents the evaluation metrics of the KNN algorithm; the accuracy in the test and in the training is 80% in both cases. The Precision, Recall, and F1-score are also shown; these values are a direct measurement of the algorithm's performance.  
The same training and testing procedures were performed for a second-degree polynomial kernel support vector machine, the results were much better than those of the KNN algorithm. The results of this preliminary analysis are also presented in Table 4.  
However, seeking to improve these metrics and the general processing performance, a dimensional reduction is proposed for the dataset used with the ML algorithms. This reduction of the dimensions was carried out by exploring the importance that each one of the characteristics has when a decision tree is trained. This dimensional reduction also served as a method to avoid data leakage that leads to overfitting of the decision tree and to increase training and prediction time for different algorithms, without significant improvement in the tests results scores.  
\begin{table}
\begin{tabular}{c c c c} \hline \hline  & **KNN F1-Score** & **SVM F1-Score** & **Support Samples** \\ \hline Flatland & 0.8 & 0.99 & 45 \\ Cobblestone & 0.7 & 1.0 & 36 \\ Transit & 0.88 & 0.99 & 38 \\ Accuracy & 0.8 & 0.99 & 119 \\ Macro avg. & 0.8 & 0.99 & 119 \\ \hline \hline \end{tabular}
\end{table}
Table 4: KNN performance metrics.  
This process consisted of obtaining the contribution that each characteristic made to the decision tree at the time of being trained. Then, the following step was training and evaluating KNN and SVM algorithms with metrics against the different data tables obtained after eliminating the dimensions that led to overfitting or poor performance of the classification algorithms.  
Finally, after different tests and evaluations, it was found that the best performance of the classification task occurs in front of three-dimensions that are the standard deviation of the pitch (Pitchsd), the standard deviation of the Roll (Rollsd), and the average lateral or Y-axis acceleration (Aymm).  
Figure 9 presents the relationship that exists between each of these dimensions and how the data from the different samples are located within these point clouds. It can be seen that there are regions in which only the values of the same class are located and, thus, a good classification with these features can be achieved.  
After reducing the number of features in the dataset, the next step was to train and evaluate the nearest neighbor algorithms and the SVM again. This time, the result for the test accuracy of the KNN algorithm was 99.2%.  
Although the reduction of the characteristics improved the performance of the KNN going from an accuracy of 80% to one of 99.2%, the same did not happen with the SVM algorithm with the second-degree polynomial kernel function; it remained the same.