## 2 Materials and Methods
### Feature Selection for Physical Activity Detection
After running the simulation with 10 max_workers (allowing Python to create 10 concurrent subprocesses), the performance metrics for each feature combination were saved. In Figure 6, the distributions for each model are illustrated, with the upper limit being the maximum accuracy for the specific number of features, while the lower limit represents the minimum accuracy. As observed, starting with attribute sets containing at least six features, the accuracy values exceed 85%, while all combinations of at least nine features have a minimum accuracy of 90%. It is noteworthy that relevant information can be extracted with fewer features. In Table 3, the first 5 feature combinations are sorted based on accuracy, in descending order, according to the average of the chosen 3 models. As observed, in terms of percentages, the differences are insignificant. Also, considering the randomness of training data, the actual combinations of features presented in table can be similar, and further analysis is required. It should be mentioned that, after analyzing the top 100 combinations by average accuracy, an average value of 7.18 features per attribute set was determined to achieve optimal results. The best 100 feature combinations were determined in terms of accuracy, with a median value of accuracy among the three classifiers of 0.9524, ranging from 0.9607 to 0.9456. It is plausible to state that a combination of 7 collected features leads to an average 95% accuracy for the models considered. During the feature combination search, the confusion matrix was computed. A confusion matrix is a metric used to evaluate the performance. It consists of a table that summarizes the number of correct and incorrect predictions, categorized by each class. Figure 7 shows the distribution of the sums of diagonal values of the confusion matrix for the same 100 best combinations of characteristics. The average diagonal sum for all records is 1050, which is 95% from the 1100 maximum sum (20% of total attributes, 5515). The random forest diagonal elements sum ranges around 1070-1073, while the gradient boosting range is 1064-1070. Correlated with Figure 6, the decision tree has the lowest sum. After manual analysis, an automated analysis using the sklearn.feature_selection module, used for the automatic selection of features, was performed. The methods used were as follows:  
* Recursive Feature Elimination (RFE), a feature selection technique that recursively removes the least important feature and evaluates the performance for the new set of features;
* SelectKBest, a method that helps to select the K best features, with a predefined K, with chi-squared test that is specific for classification. \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Features** & **Random Forest** & **Gradient Boosting** & **Decision Tree** & **Average** \\ \hline Accelerometer\_x, Accelerometer\_y, Gyroscope\_x, Gyroscope\_y, Gyroscope\_z, AccMagnitude, Roll, Pitch, Yaw & 0.9728 & 0.9701 & 0.9393 & 0.9607 \\ \hline Accelerometer\_x, Accelerometer\_y, Accelerometer\_z, Gyroscope\_y, Gyroscope\_z, Roll, Yaw & 0.9692 & 0.9646 & 0.9474 & 0.9604 \\ \hline Accelerometer\_x, Accelerometer\_y, Accelerometer\_z, Gyroscope\_y, Gyroscope\_z, Roll, Pitch, Yaw & 0.9710 & 0.9655 & 0.9447 & 0.9604 \\ \hline Accelerometer\_x, Accelerometer\_y, Gyroscope\_y, Gyroscope\_z, AccMagnitude, Roll, Pitch, Yaw & 0.9683 & 0.9674 & 0.9456 & 0.9604 \\ \hline Accelerometer\_x, Accelerometer\_y, Accelerometer\_z, Gyroscope\_y, Gyroscope\_y, Gyroscope\_z, AccMagnitude, Roll, Pitch, Yaw & 0.9710 & 0.9655 & 0.9438 & 0.9601 \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Top 5 combination of features by median accuracy. Figure 6: Accuracy distribution for the number of features. SelectKBest was used with the chi-squared test, which helps to find a significant difference between the expected outcomes and predicted outcomes in different categories, which were activities in this specific case. Like in the RFE, the analysis was performed for various values of K, from 10 to 5.