# Dynamic Segmentation for Physical Activity Recognition Using a Single Wearable Sensor
## 4 Proposed Method
### Determining Segment Boundaries
First, a magnitude (\(m\)) value was calculated using the signals (\(x\), \(y\), and \(z\)) from the accelerometer (\(m=\sqrt{x^{2}+y^{2}+z^{2}}\)). Furthermore, six time-domain features were considered and extracted from raw data of the three axes (\(x\), \(y\), and \(z\)), as well as (\(m\)). A list of the features used along with their definitions is presented in Table 1.

### Model Training and Validation Strategies

Support vector machine (SVM) was used to train and test the classification model due to its frequent use in previous physical activity studies [16; 29; 30]. Ten-fold cross-validation was used to train the model, which means that data from nine subjects were randomly divided into training and testing sets using 90 and 10% of the data, respectively. The Waikato Environment for Knowledge Analysis (WEKA) toolkit was used in this work. Using a personal computer with an Intel Core i5-2430M CPU (Toshiba International Corporation, Texas, USA), the total time taken to build the model was 0.43 s.

Ten-fold cross-validation and leave-one-user-out (LOUO) were the evaluation protocols intensively used in the literature. Although 10-fold cross-validation is the most accurate approach for model selection, LOUO performs better in terms of model robustness, and it is recommended for human activity recognition [20]. In the latter protocol, instead of randomly splitting data into evaluation and training sets, it selects data from some subjects for training and data from the remaining for evaluation. As a result, the protocol is considered robust to the overfitting problem since training, and testing data never share samples belonging to the same subject [15]. Algorithm accuracy in this work was evaluated using LOUO, which means that the algorithm was trained using data from nine subjects and then evaluated on the remaining one. This process was repeated until data from each subject were evaluated exactly once, and an average of performance was obtained. \begin{table}
\begin{tabular}{c c} \hline \hline
**Name** & **Definition** \\ \hline Minimum & min(\(d\)) = lowest \(d_{i}\), \(i=1,2,\,\ldots,\,N\) \\ Maximum & max(\(d\)) = highest \(d_{i}\), \(i=1,2,\,\ldots,\,N\) \\ Range & range(\(d\)) = max(\(d\)) - min(\(d\)) \\ Mean & mean(\(d\)) = \(\frac{1}{N}\)\(\sum_{i=1}^{N}x_{i}\) \\ Standard Deviation & SD(\(d\)) = \(\sqrt{\frac{1}{N}\)\(\sum_{i=1}^{N}\)\((d_{i}-mean(d))^{2}\) \\ Root Mean Square & RMS(\(d\)) = \(\sqrt{\frac{1}{N}\)\((d_{1}^{2}+d_{2}^{2}+\cdots+d_{N}^{2})\) \\ \hline \hline \end{tabular}
\end{table} 
Table 1: List of features used (notation: \(d\in(x,y,z,m)\); \(N\) is the number of data points; \(i\) is the index). Figure 7: Acceleration signal of four repetitions of EF segmented using sliding window (**lower part**) and the proposed method (**dotted lines**). ## 6 Results

Various performance metrics have been used in prior works, including accuracy, which refers to the ratio of correctly predicted observations to the total observations; recall, which refers to the ratio of correctly predicted positive observations to all observations in the actual class; precision, which is the ratio of correctly predicted positive observations to the total predicted positive observations; and F-measure, which is a combination of the precision and recall measures that are used to represent the detection result. To evaluate the performance improvement of the proposed method, the experiment was conducted in two phases. First, the abovementioned performance metrics were used to determine the recognition performance using both segmentation methods: sliding window and the proposed method. For comparison purposes, only values of similar activities, as in [15], were presented. This study was chosen because it has the greatest number of shared activities with the ones provided in this work (i.e., the shared activities are abduction, flexion, and EF). In addition, it used the fixed-size sliding window protocol for segmentation.