## 4 Methodology
### Machine Learning Algorithm and Evaluation Metrics
In the present day, there are multiple techniques that have been found for dealing with imbalanced datasets, such as oversampling, undersampling, synthetic minority oversampling technique (SMOTE) [45], etc. But in the present study, the usage of such sampling techniques was not leveraged to increase the cardinality of the datasets; rather, a class weight-based approach was undertaken. The class weights were basically used to create a weighting mechanism for the calculation of a loss function, which means the minority samples that had a smaller number of samples were focused on more during the training process. For determining the class weights of the classes, a specific technique was used which is given as follows:  
\[weight\_of\_particular\_class=log\bigg{(}\frac{tuning\_parameter*number\_of\_total\_samples}{(number\_of\_particular\_class)}\bigg{)},\]  
where tuning_parameter is a constant value that needs to be iteratively tuned. For this paper, the chosen class weights are defined in Table 7.  
The evaluation of the machine learning algorithms was done by considering accuracy, average recall, average precision, and average f1 score as the evaluation metrics. Accuracy in the particular task was used to understand the overall accuracy across all the 7 classes for activity detection and the 3 classes of emotion detection. In the current scope of the work, the recall was being calculated for each class where it provided the information regarding the number of data samples that the model correctly identified for a particular class. Therefore, in the study, average recall was calculated, which determined the average percentage of correct predictions in each class of both activity detection and emotion detection respectively. Additionally, the precision of the predictions has been derived, which determines the confidence of a particular prediction to belong to a particular class. Further, for evaluation purposes, average precision was derived, which allowed us to identify the average of \begin{table}
\begin{tabular}{c c} \hline
**Classifier** & **Specifications** \\ \hline Random Forest & n\_estimators: 200, criterion = ‘gini’, max\_depth:4, \\  & min\_samples\_split = 4, min\_samples\_leaf = 5 \\  & Kernel = ‘rbf’, degree = 2, gamma = \\ Support Vector Machine & ‘auto\_deprecated’, \\  & C = 1.0, tol = 0.001, cache\_size = 200 \\  & n\_neighbors = 10, weights = ‘uniform’, algorithm = \\ K—Nearest Neighbours & ‘auto’, \\  & leaf\_size = 40, p = 2, metric = ‘minkowski’ \\ Naive Bayes & Gaussian \\ Artificial Neural Network & Layers: [64; 128; 256; 512; 32; 3], Loss: Categorical \\  & Cross Entropy, \\  & Optimizer: Stochastic Gradient Descent \\ \hline \end{tabular}
\end{table} 
Table 6: Emotion detection: classifiers and specifications. \begin{table}
\begin{tabular}{c c} \hline
**Class** & **Weight** \\ \hline Walking (0) & 1.0 \\ Sitting (1) & 1.0 \\ Say (2) & 1.0 \\ Eating (3) & 1.012589412 \\ Sideway (4) & 1.156774801 \\ Nosework (5) & 1.203320 \\ Jump (6) & 1.216978244 \\ \hline \end{tabular}
\end{table} 
Table 7: Class weights for activity detection model training. all the precision scores for each class. Finally, an f1-score was derived, which provides a weighted average between both the precision and recall of each class, and therefore, penalizes the score for all the wrongly-predicted samples of a particular class. Furthermore, during the learning procedure, the complete data of 10 subjects were divided into the ratio of 70:30, where the data of 7 subjects were used for the training and the data of 3 subjects for the validation/testing.