5.2.2. Context Effects

We first evaluated the effects of orientation *IO* and personalization *IP*. Since we could recognize all three axes, if *IO* is known, then extract features and train all of these on three axes and compare them to the baseline accuracy, which is calculated based only on the magnitude of the sensor data. For the heuristic method and the signal processing method, we chose an axis that performs best on all three axes. Additionally, the accuracies under *IP* is known are obtained by averaging the accuracy of the test data on each subject. We show the results in Table 6.

If the prior information of orientation *IO* and personalization *IP* are independently known, then the performance of WD algorithms is shown in Table 6. If *IO* is known, then the feature extraction of machine learning algorithms is performed on all three axes, which means that the classifier is trained in the designed orientation. For the heuristic method and signal processing method, we chose the axis that performs best from a gravity axis and a forwarding axis.

We found that both heuristic methods (THR) and signal processing methods (STFT, DWT) are worse than machine learning methods (k-NN, SVM). In fact, heuristic methods and signal processing methods could be viewed as features of machine learning methods. We found that either providing orientation *IO* or personalization *IP* could enhance the recognition accuracy, and *IP* contributed more to the accuracy increasing. If we know the sensor orientation *IO*, there are many techniques to employ them such as extract features in all three dimensions or reconstruct the signal into the Earth coordinate system. Here, we use the common method to extract features in three dimensions of the sensor to observe the impacts. The orientation is different from placement since the sensor could be attached freely without control while the typical placements are fixed, so we could not give comparisons in every orientation. if *IP* is provided, we only use one's data to train the personalized model and test the model on him/herself.

Figure 5 shows the baseline accuracy of algorithms over different window sizes, which varies from 300 to 1200 samples (1.5 s to 6 s). The heuristic methods (THR) are nearly independent of the changing of the window size because the features are nearly time-invariant. The STFT method is best at the window size of 600 samples (3 s). The DWT method becomes slightly higher alongside the increase of window size. Machine learning methods overall become slightly lower along with the increase of window size mainly because the statistical features of different activities in a larger window size are not that easy to discriminate.

Figure 6 shows the relationship between various placements and accuracy. To evaluate the accuracies of the placements, we selected data only from the specified position to train and test the model and use the accuracies as criteria. The knowledge of placements boosts almost all the accuracies compared to the baseline accuracy, which indicates that placements make the dataset more discriminative. Although some placements slightly increase the accuracy of the heuristic method (THR), it is not sensitive to variations of placements. The STFT method and DWT method perform even worse than the baseline accuracy at some placements. The machine learning methods (k-NN and

SVM) display the largest increase in Figure 6. Lastly, the accuracies of STFT, DWT, k-NN and SVM all increased at FrontPocket.

**Figure 5.** Context effects: window size.

Figure 7 depicts the baseline accuracies under different sampling rates *R*. The accuracy decreases smoothly with the increase of *R*. Furthermore, 20 Hz is the transition point, where the accuracies of k-NN, SVM and STFT diminish quickly. THR is nearly independent of the changes of *R*, since the variance is steady. DWT becomes relatively low when the sampling rate is 100 Hz.

We observed that the machine learning algorithms outperform heuristic and signal processing methods in distinguishing walking activity from other periodic and walk-like activities. This is mainly because the heuristic and signal processing methods suffer from the indistinguishable patterns of variance and spectrum between walking activity and other activities. Besides, the accuracies of heuristic methods and signal processing methods are not noticeably improved even though more contextual information is provided. Besides, the false positives and false negatives of riding a bicycle are much lower than other activities because the sensor movement in the FrontPocket is highly restricted, and false positives are difficult to recognize.

The accuracy of heuristic methods and signal processing methods is a result of a balance among true positives, true negatives, false positives and false negatives. We chose the best accuracy that was larger than 50%, under the condition of both true positives and true negatives.

**Figure 7.** Context effects: sampling rate.
