## 3 Materials and Methods
### Experimental Setup  
This section outlines the experimental setup used to assess the performance of various machine learning and deep learning models for human activity recognition tasks utilizing smartphone sensor data. The hyperparameters for each model were carefully tuned to achieve optimal performance. Table 4 provides a detailed summary of the hyperparameter configurations explored for each model, enabling a systematic comparison across diverse machine learning and deep learning approaches. The feature set was standardized using a Standard Scaler to ensure that each feature has a mean of 0 and a standard deviation of 1, transforming each feature \(x\) as follows:  
\[z=\frac{x-\mu}{\sigma}, \tag{7}\]  
where \(z\) is the standardized value, \(\mu\) is the mean of the feature, and \(\sigma\) is the standard deviation. Standardization was particularly crucial for models like SVC, KNN, and neural networks (e.g., GRU and Transformer), which are sensitive to the scale of input data. Standardizing the features improves the convergence of gradient-based optimization algorithms and ensures that all features contribute equally to distance calculations in KNN and margin maximization in SVC. Nested Cross-Validation (CV) was employed to assess the generalizability of the models to unseen data. The outer loop used five folds, while the inner loop used three folds. The input tensor shape was defined as (window size, number of features): specifically, (2,3) for the three-input configurations and (2,4) for the four-input configurations. [PERSON] K-Fold was used for dataset splitting, with a random state of 42 to ensure reproducibility. The dataset was split into 80% for training and 20% for testing, ensuring adequate data for model evaluation. This approach allowed each model to train and test multiple times on different folds, maximizing the utility of the available data while avoiding overfitting. This two-level cross-validation technique provided an unbiased estimate of model performance and minimized overfitting during hyperparameter tuning. The outer loop ensured generalization to unseen data, while the inner loop rigorously selected the best hyperparameters based on the training data. This consistent setup was applied across all models, from traditional classifiers like DT, KNN, RF, and SVC to advanced gradient-boosted models like XGBoost, and further to deep learning architectures such as GRU, LSTM, TCN, and Transformer, providing a robust evaluation across the full spectrum of models used in this study. Table 4 illustrates the range of hyperparameters adjusted for each model to achieve optimal performance. For DT, hyperparameters such as the splitting criterion (gini or entropy), maximum depth (None, 10, 20, 30), and minimum samples per split and leaf were fine-tuned to balance model complexity and prevent overfitting. The KNN model's parameters, including the number of neighbors and weight functions, were adjusted to enhance sensitivity to local data variations. Support Vector Classifier (SVC) was optimized by experimenting with different kernels, regularization constants, and gamma values to refine the decision boundary and handle non-linear relationships effectively. RF was optimized with hyperparameters including the number of estimators, maximum depth, and maximum features to balance performance and computational efficiency. RF's ensemble structure and its ability to handle complex interactions in sensor data make it a robust model choice for activity recognition tasks. XGBoost was tuned with parameters such as learning rate, maximum depth, number of estimators, and gamma. The model's gradient-boosting framework allows it to capture intricate patterns in the data, while careful tuning of these parameters ensures that it achieves high performance without overfitting. LSTM networks required the tuning of several parameters, including the number of LSTM layers, units per layer, dropout rates, optimizers (Adam, Adamax, RMSProp, SGD), and learning rates.