## 2 Materials and Methods
### LSTM Model Training and Evaluation  
LSTM is a type of recurrent neural network (RNN) commonly used for feature recognition in time-dependent data, as it can capture long-term dependencies [43; 44]. Its gating mechanisms allow it to selectively remember or forget information, leading to the enhancement of memory process [45] and making it effective in tasks like HAR, where understanding patterns over time is of central importance [46].  
The LSTM model was constructed using TensorFlow's Keras API, featuring two LSTM layers with 50 units each, a dense output layer with six units and a softmax activation function. The model was trained to capture temporal patterns in the data using the Adam optimizer, after first testing the impact on model performance of the several optimizers(Adam, RMSprop, SGD, Adagrad, and Adadelta). In addition, the cross-entropy loss function was utilized to quantify the error between the predicted values and the actual values, while a low learning rate of 0.001 was employed to improve the model's fitting capability. A range of batch sizes was also tested to ensure both high F1-scores and low generalization gaps. This approach aimed to balance the model's ability to accurately classify the data (as indicated by high F1-scores) while minimizing overfitting, as reflected in low generalization gaps between the training and testing datasets.  
For the purpose of avoiding the dependence of the results on a specific random choice, the trained model was validated using a 10-fold cross-validation. Thus, the training set was split into 10 smaller sets. The LSTM model was trained using nine of the folds as training data, while the resulting model was validated upon the rest of the data (i.e., they were utilized as test data to calculate performance measures like F1-score). The performance metrics provided by the 10-fold cross-validation were the average of the calculated values during the loop [47]. A flowchart outlining the cross-validation workflow in model training is provided in Figure 1. It begins with the dataset in the form made after data pre-processing and feature extraction, which is split into training and test data. The parameters for the model are initialized, and cross-validation is performed only on the training data to tune these parameters. Based on the cross-validation results, the best parameters are identified, and the model is retrained using the optimal parameters. Finally, the test data are evaluated on the retrained model to produce a final evaluation of its performance using appropriate metrics. Early stopping was applied to prevent overfitting by halting training when the validation loss did not improve for 10 consecutive epochs.  
Finally, in order to identify the most effective combinations of anatomical locations for the IMUs, a systematic analysis was performed. This involved generating all possible combinations of the five anatomical locations--cervix, chest, lumbar region, right wrist, and left wrist. Additionally, all possible combinations of sensor types were evaluated. This included single sensor types (e.g., accelerometers only), as well as combinations of multiple sensors (e.g., accelerometers and gyroscopes, or accelerometers, gyroscopes, and magnetometers). F1-score, preferred in datasets with imbalanced classes [48], was calculated for each set to determine which combinations provided the best classification accuracy.