# Efficient Human Activity Recognition Using Machine Learning and Wearable Sensor Data
## 2 Data Collection and Preprocessing
### Data Preprocessing  
Before modeling, the collected data were preprocessed to address missing values and manage outliers. Subsequently, the data were standardized to ensure that each feature was uniformly processed within the same scale and distribution range, promoting consistency \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Participant Number** & **Gender** & **Age** & **Weight (kg)** & **Height (cm)** \\ \hline
1 & Female & 27 & 43 & 164 \\
2 & Female & 23 & 52 & 168 \\
3 & Male & 27 & 50 & 164 \\
4 & Female & 35 & 63 & 170 \\
5 & Female & 30 & 60 & 171 \\
6 & Male & 22 & 76 & 180 \\
7 & Male & 49 & 68 & 166 \\
8 & Male & 21 & 71 & 178 \\
9 & Female & 34 & 48 & 165 \\
10 & Male & 36 & 80 & 170 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Relevant information for the 10 participants. for the subsequent analysis. Representative time-domain and frequency-domain features were then extracted to characterize the activity states of the different groups. Firstly, missing values were identified and imputed. Next, outliers were detected using the standard deviation method. Below is a brief explanation of how the standard deviation method works for outlier detection. We firstly calculated the mean value and the standard deviation for given dataset \(x=\{x_{1},x_{2}\ldots x_{n}\}\). Next, we determined the outlier threshold, which is based on the standard deviation. A common method is to use the mean (\(\mu\)), plus or minus k times the standard deviation (\(\sigma\)), where k is set to 5 in this case. The threshold has been correspondingly determined to be equal to \(\mu\pm 5\sigma\). Finally, the data were examined for outliers by comparing each data point against the threshold. If a data point falls outside the defined range, it is considered an outlier and removed from the dataset. After removing the outlier data, we proceeded with data standardization. For this, we used the Z-score method, a widely employed technique for data standardization. The Z-score method transforms the data into a standard normal distribution with a mean of 0 and a standard deviation of 1 [18]. This approach eliminates scaling differences between features, allowing for comparisons under the same criteria. It is commonly used in various machine learning algorithms, as well as in data preprocessing, outlier detection, and feature engineering. Here is a brief introduction to the steps to applying this method. Firstly, we calculated the mean and standard deviation. For each feature \(x_{j}\) in the dataset, we calculated the mean value \(\mu_{j}\) and standard deviation \(\sigma_{j}\).Then, we applied the Z-score normalization using Equation (1). \[z_{ij}=\frac{x_{ij}-\mu_{j}}{\sigma_{j}} \tag{1}\]  
Here, \(x_{ij}\) is the \(j\)th eigenvalue of the \(i\)th sample and n is the total number of samples. The Z-score of each sample \(x_{ij}\) is then calculated: the score represents the standard deviation distance from the data point \(x_{ij}\) to the mean \(\mu_{j}\). After the data standardization, we need to classify the activity states in each experiment, so we need to extract representative features to represent different activity states. In the time domain, we extract the mean, standard deviation, maximum value, and minimum value as time-domain features. Some of the data are shown in Table 2. In the frequency domain, we convert the time-domain signal to the frequency domain through the Fourier transform and extract peak values as frequency-domain features.