## 4 Methodology
### Machine Learning Algorithm and Evaluation Metrics  
The development of machine learning algorithms for the detection of activity and emotion is very important. [PERSON] et al. [35] leveraged machine algorithms to fetch semantic information from data. Moreover, [PERSON] et al. [36] plotted the usefulness of machine learning methods for extracting abstract patterns from mobile phones and wearable devices. Therefore, for this work, multiple machine learning algorithms were developed and a comparative analysis was performed to determine the best possible algorithm based on the evaluation metrics. As in previous studies performed by [PERSON] et al. [37], it was found that SVM, ANN, and tree-based classifiers could be leveraged for healthcare-based uses. Additionally, [PERSON] et al. [38], showed that SVM, naive Bayes, and ANN are potentially much more reliable when it comes to human activity detection. Therefore, for the learning process in this particular study, 5 different machine learning algorithms, namely, random forest, SVM, KNN, naive Bayes, and ANN, were developed. [PERSON] et al. [39] used an SVM-based diagnosis model for fault detection using sensors that were connected to the equipment, and they achieved an accuracy of 98.7%. [PERSON] et al. [40] used SVM, KNN, decision tree, and naive Bayes classifiers to distinguish the freezing of gait patients from not freezing, and they attained accuracy of 88% with SVM. The initial hypothesis for the activity detection stated that the recall of all the 7 classes must be over 85% and all the classes must maintain a fixed classification rate. On the other hand, the hypothesis for emotion detection was devised in a way where it was stated that the recall of each class must be more than 85% and the correct number of samples in the positive class and negative class must be more than the neutral class. Tables 5 and 6 below show the specifications and the hyperparameters of all the machine learning algorithms that were used for the classification tasks of activity detection and emotion detection respectively. \begin{table}
\begin{tabular}{c c} \hline \hline
**Feature** & **Description** \\ \hline Number of Peaks & This feature gives out the number of peaks for a subject on a specific data fold of 33 samples \\ \hline Peak Average Amplitude & This feature gives out the average amplitude of the peaks for a subject on a specific data fold of 33 samples \\ \hline Peak Value Difference Mean & This feature pursues the mean difference between the amplitude of consecutive detected peaks for a subject on a specific data fold of 33 samples \\ \hline Peak Sample Difference Mean & This feature provides us with the mean time difference between each detected peak for a subject on a specific data fold of 33 samples \\ \hline \hline \end{tabular}
\end{table} 
Table 4: Peak-based features. \begin{table}
\begin{tabular}{c c} \hline \hline
**Classifier** & **Specifications** \\ \hline Random Forest & n\_estimators: 500, criterion = ‘gini’, max\_depth:8, min\_samples\_split = 8, min\_samples\_leaf = 10 \\ Support Vector Machine & Kernel = ‘rbf’, degree = 3, gamma = ‘auto\_deprecated’, \\  & C = 1.0, tol = 0.001, cache\_size = 200 \\  & n\_neighbors = 50, weights = ‘uniform’, algorithm \\ K—Nearest Neighbors & \(\text{\textasci{}}\) = \(\textasci{}\) = \(\textasci{}\) = \(\textasci{}\) = \(\textasci{}\) = \(\textasci{}\) = \(\textasci{}\) = \(\textasci{}\) = ‘auto’, \\  & leaf\_size = 40, p = 2, metric = ‘minkowski’ \\ Naive Bayes & Gaussian \\ Artificial Neural Network & Layers: [64, 128, 256, 32, 16, 7], Loss: Categorical \\ (Multi-Layer Perceptron) & Cross-Entropy, \\  & Optimizer: AdaGrad \\ \hline \hline \end{tabular}
\end{table} 
Table 5: Activity detection: classifiers and specifications. Moreover, in Figure 4, it can be duly observed that the numbers of samples in the 7 different classes of activity are highly imbalanced. The presence of imbalanced data deeply affects the performance of machine learning and deep learning models [41; 42; 43; 44].