Advanced mobile devices, such as smartphones, are usually integrated with several sensors capable of any-time sensing and data collection. With different types of motions sensors, such as accelerometers, gyroscopes and magnetometers, mobile devices can obtain substantial user-related information by monitoring and tracking movements of their users. Human Activity Recognition (HAR) is a classification task focused on the use of sensing technologies to classify humans activities or to infer human behavior . Research in this area has been used, for instance, in health care and well-being , mobile security  and elderly care .
, most approaches focus on HAR based on supervised learning techniques, assuming the learning data to be always labeled. However, this assumption may not be feasible in real online HAR tasks, when labeled data is rare and the system feedback has to occur at runtime. As an example, in a fall detection system for elderly care, the classification feedback needs to occur as close as possible to the real moment of the user’s fall.
To keep a similar accuracy over time, a HAR system needs to adapt itself to the current user. However, due to limitations of most mobile devices, the system needs to manage different resources, such as battery and execution power, to be accurate and functional. Thus, there is a trade-off between amount of processed information and resource management. For example, most work in the literature considers only a fixed window size for all activities and users. As human beings perform activities differently, dissonant input signals are expected for the same activity .
In this work, we provide an extensive study of the impact of two hyperparameters, window size and overlapping between windows, on activity classification accuracy, for each user, using a leave-one-user-out evaluation approach. Furthermore, we conducted some experiments with an ODROID-XU+E board in order to evaluate the performance of these hyperparameters in terms of energy consumption and execution time. These experiments allow us to establish a trade-off between classification accuracy and resource consumption, in terms of window size and window overlap.
The rest of the paper is structured as follows. Section II presents related work on HAR and window parameterization. Section III describes the methodology applied in this study. Section IV presents and discusses the main results obtained in the experiments. Finally, in Section V, our final conclusions and future work are summarized.
Ii Related Work
HAR applications have been extensively researched in recent literature [4, 5, 6, 7], specially due to the benefits for human life quality. There are many evidences of the beneficial influence of regular physical activities in reducing problems associated with aging and prevention of various diseases, such as obesity . Since wearable technologies and smartphones have become more ubiquitous, abundant information about a person’s life is available. However, since each person has a unique way of performing an activity , a HAR system needs to be adapted to the characteristics of a person in order to maintain, or improve, accuracy. In addition, in smartphones devices, it is necessary to manage its limited resources in order to keep the system efficiently working for long periods of time.
Dobbins et al.  propose an approach that uses personal data to better infer lifestyle choices for its users. Considering only labeled data, they evaluate the predictive performance of supervised HAR classifiers in terms of accuracy and mobile system performance (execution time and energy consumption). They have used an experimental setup based on a fixed window size of sensor samples with an overlapping window of , i.e., samples are reused from the previous window and only new samples are used for the current window. They suggest that the sensing data should be processed in the cloud and not in the device. However, personal privacy and Internet connection time are not considered. Furthermore, all data used are labeled, which cannot be guaranteed in a real online mobile system. The datasets used in the experimental section contain complex activities and different user’s data, but the results are not compared in terms of accuracy differences per user.
Mannini et al.  proposed the use of an SVM classifier to detect four activities of different users. The classifier performance was tested for different window sizes, but not the overlap between consecutive windows. It does not compare the classification with different window size in terms of execution time. The results show large variability between users performing the same activity, due to the sensor body location problem.
Window size has also been discussed by other authors. For example, [11, 12, 13, 14] compare the predictive performance of classifiers over a set of window sizes. However, most of the studies do not consider the use of overlapping window and the impact of the user on the obtained accuracy.
In  an extensive review of the literature in window size and HAR is presented. The accuracy of several classifiers is analyzed for different window sizes, but not regarding users, especially because the experimental setup is not elaborated with a leave-one-user-out experimental methodology. Instead, a cross validation approach is used, which is less affected by user variability than leave-one-participant-out, which would be a more realist approach.
The study conducted in this paper uses the PAMAP2 public dataset 111http://archive.ics.uci.edu/ml/datasets/pamap2+physical+activity+monitoring , which includes a vast number of sensors and more complex activities than the experimental data used by many of the studies regarding hyperparameter configurations for HAR. This dataset allowed us to study the impact on HAR accuracy for different window sizes for distinct users and activities.
Iii Activity Recognition Overview
Sensor data are an important source of information for HAR and current mobile devices usually integrate several types of sensors. As the data from these sensors are user-specific, HAR systems can learn and adapt themselves to their users over time. Since it is not feasible to assume that activity data will be provided with labels, HAR systems need to be able to deal with the situation where none or just a few incoming data are labeled.
In online semi-supervised learning approach, a classification algorithm has access to a dataset where most of the data are unlabeled and can use the labeled data to predict the label for the unlabeled data, as shown inFigure 1. This process consists of two main phases: (1) an offline phase for training; and (2) an online phase for user-specific classification.
It starts by training the ensemble classifier with labeled data from several users. A generic version of the classification model is obtained to be used as the basic model. After the training phase and when running the classification for a specific user, the model is updated with user data only if the classification is inferred with a high confidence factor (higher than ).
The process carried out by this system can be divided into six main steps, the first two steps depict the training phase and the other four steps the online user-specific classification. This work was firstly described in . The main contribution of this paper is the study on hyperparameter configuration that results from the last task described. The other tasks are herein described for better understanding of the work done.
The raw sensors data is initially collected by a smartphone. Each user has a unique signal to execute the same activity. The more complex the activity performed, more sensors might be required to gather enough information. A typical set of sensors includes a 3D accelerometer, a 3D gyroscope and a 3D magnetometer. However, in this study we use the sensing raw data provided by the PAMAP2 dataset .
Then, a sliding window of raw sensor data is processed and converted into a single instance containing the features calculated based on the raw data 
. This new instance is used to train (or classify with) an ensemble classifier composed by three classifiers: kNN, VFDT and Naive Bayes. The implementation of the ensemble classifier is a combination of Democratic Co-Learning and Tri-Training .
The ensemble training phase is executed in an offline stage, in which the label data is available for training. The label dataset contains raw sensors data from different users performing specifics activities. The first step is the collection of sensors data.
Figure 1 shows the raw data extracted from different wearable sensors and/or smartphones, placed in different body parts. The raw data samples are stored in a sliding window (a first-in/first-out collection removing the oldest data) which is used in the following step. Since the data from a given classification may be meaningful for the following classification, a between-window overlap factor can be used to reuse samples from the current window in the next window. This means that the new samples collected are reduced by the overlap factor, allowing more classification phases with less collected data.
Since this type of data is usually susceptible to noise, especially accelerometers data , it is important to process and convert the data into meaningful values. A pre-processing step may also include calibration and filtering of the input signals in order to reduce noise. In a second step, Feature Extraction processes the sliding window to calculate a single instance containing features to be used for the classification. These features (see, e.g., 
) include time-domain calculus, specifically mean and standard deviation for each sensor signal and correlation (Pearson correlation) between axes for the 3D sensors. In the online phase, sensors data are collected from a single user and, similarly to the training phase, it can be obtained from wearable sensors and/or smartphones. The second step is also identical to the offline phase.
Each generated instance is classified by the ensemble, which classifies the given instance and provides a confidence factor for that classification. The instances classified with high confidence, more than , are used to update the ensemble model. As shown in Section IV, using instances with high confidence factor to update the ensemble model is a powerful mechanism to improve accuracy in HAR systems.
Iv Experimental Results
We conducted several experiments with our approach using the PAMAP2 dataset . The objective of these experiments is twofold. First, we intend to compare the accuracy of a supervised HAR versus a semi-supervised HAR when using different configurations of two hyperparameters: window size and overlap factor. Then, we intend to study the system behavior with the different hyperparameters configurations in terms of classification accuracy, energy consumption and execution time.
Iv-a The PAMAP2 Dataset
PAMAP2  is a public dataset for physical HAR. The data from this dataset was collected from three devices positioned in different body areas: wrist, chest and ankle. Each device contributes with data from three sensors: a 3-axis accelerometer, a 3-axis gyroscope and a 3-axis magnetometer.
The PAMAP2 dataset contains 18 different activities, which can be divided in basic activities (walking, running, Nordic walking and cycling), posture activities (lying, sitting and standing), everyday activities (ascending and descending stairs), household (ironing and vacuum cleaning) and fitness activities (rope jumping). Also, the users were encouraged to perform optional activities (watching TV, computer work, car driving, folding laundry, house cleaning and playing soccer).
PAMAP2 contains 1,926,896 samples of raw sensor data from 9 different users. Table I shows the number of samples for each activity and user.
|User||Lying||Sitting||Standing||Walking||Running||Cycling||Nordic Walking||Asc. Stairs||Desc. Stairs||Vac.Clean||Ironing||Rope Jump.|
Iv-B Experimental setup
Most work in HAR set a signal segmentation in sliding window with fixed size and window overlap. For example, in , the window size in the experiment was set to 200 samples, which represents four seconds of data collected at a frequency of 50 Hz. In the work presented in this paper we verify experimentally the influence in accuracy of overlap and window size when considering activity and user.
In order to confirm the influence of window size and overlapping in the final classification performance, we use the accuracy metric. The classification accuracy is analyzed by class and user. We train the ensemble classifier with data from eight users and test with data from one isolated user, in a leave-one-user-out approach. For each window, features are processed from raw sensors data resulting in one instance test processed per window.
The experiments were conducted using the PAMAP2 dataset  with the leave-one-user-out validation technique. The hyperparameters explored were: the sampling window size (from 100 to 1000 with increments of 100) and the overlapping between windows (from 0.0 to 0.9 with increments of 0.1). We conducted four experiments with a HAR system featuring an ensemble classifier consisting of three classifiers: kNN, Naïve Bayes, and Hoeffding Tree (VFDT), as in . As verified in , these three classifiers have good classification performance.
The box-plots correspond to the ensemble accuracy over the changes in the window size and overlapping. The heat-map tables are included to facilitate the visualization in terms of how the hyperparameters influence the classification of each activity for each user.
We also intend to analyze the impact of using a semi-supervised approach for activity recognition with a leave-one-user-out implementation. Considering that each user produces different input signals for the same activity, hence influencing the accuracy of the classifier, it is necessary for the classifier to adapt itself to the user. We show accuracy results by: window size, overlapping size, user and activity.
Iv-C HAR Accuracy Results
Semi-supervised can improve accuracy, but not significantly. In Figure 7
the semi-supervised approach reduces variance for most of overlapping window and has average accuracy close to 90%. Overlapping has more influence on accuracy for values higher than 0.7, but semi-supervised is less susceptible to that influence than the supervised approach. Semi-supervised also improves accuracy for window size hyperparameter, as shown inFigure 10. Windows with small sizes has worse results, especially for sizes equal to 100 and 200.
In Figure 13, we analyze the impact of accuracy when the hyperparameters of window size and overlapping for each user are changed. For user 5, either in supervised approach or semi-supervised, the variance is higher than users 2 and 1. The semi-supervised ensemble reduces accuracy variance in users 4 and 8.
User 9 is an interesting case to analyze. For most of the cases, the accuracy is 100%, however, as is shown in Table I, user 9 only has instances for the Rope Jumping activity, which means that this user influences the results to higher values, but in comparison with users 2 and 1 for some cases the individual accuracy can be lower, justifying the analyses by user instead of analyzing all population.
Figure 4 is a heatmap table in which the highest values are red, the lowest are yellow and the intermediate values are orange. For window size 500 and overlapping of 0.8, the accuracy of each activity has notable differences depending on the user. For example, for user 1 the highest accuracy is for the activities Running, Cycling, Vacuum Cleaning and Ironing, but is not the same for user 7, where activities, such as: Lying, Standing, Walking and Nordic Walking, have better accuracy values. Both users have a significant amount of instances for each activity, as seen in Table I.
Figure 2 and Figure 3 show the impact on accuracy per class over user 1. Figure 2 has overlapping window of 0.8 and Figure 3 has overlapping window of 0.2. With overlapping of 0.2, activity Cycling is less affected to window size than with overlapping 0.8. However, Figure 2 shows higher accuracy results. This is noticeable for the others activities too. Especially for window size 100, accuracy values are higher for most of the activities with overlapping 0.2.
As expected we can see with these results that window size and window overlapping do influence the accuracy. Based on these results and depending on the HAR application, one can decide about the window size and overlapping level that makes possible a certain minimum desired classification accuracy. The exhaustive exploration allows us to also understand the acceptable ranges to explore within a runtime autotuning system, e.g., to keep a minimum accuracy (e.g. 80%). These ranges can be used, at runtime, to search for the best combination of the hyperparameters that provide the best results, e.g., in terms of execution time or energy consumption. The following subsection shows the impact on execution time and energy consumption of different window sizes and overlapping levels.
Iv-D Time and Energy Consumption
We conducted some experiments in an ODROID-XU+E 222ODROID-XU+E is a board mainly consisting of an Exynos5 Octa SoC, which includes 2 quad cores ARM CPUs and a PowerVR GPU, and a power measurement circuit to measure CPU, GPU and DRAM power consumption. The Exynos5 Octa SoC has been used in a number of families of smartphones. 333https://www.hardkernel.com/ system running Android to observe the execution time and energy consumption for processing all the data from the PAMAP2 dataset. The experiments focus on a single user, user 6 in Table I, and the execution time and energy required to process the 250,096 raw samples. We also limit the exploration space of window size and overlap factor to a narrowed range of values that keep the classification accuracy under certain limits.
Figure 14 shows the execution time necessary to process all the data of user 6 and with the time divided into three parts. The first part, samplingTime, represents the time required to access all the data from the user and the instantiation of each data window as an instance. The second part, featureTime is the feature extraction and “final instance” instantiation and depends on the window size and overlap factor used. The last part, classificationTime is the total time required to classify all the instances calculated in the feature extraction phase.
Since the feature extraction depends on the window size, the time to calculate all instances increases as the window size also increases, despite the decreasing number of calculated features. This means that the feature extraction phase is sensitive to the number of raw instances to process. Furthermore, as we increase the overlap factor, due to the increased number of instances that are calculated, the time also increases. The classification time is rather small and slightly increases as the number of calculated features augments.
Figure 15 shows a heat map representing the energy (J) spent to process the PAMAP2 raw data for the different window sizes and overlap factors. The colors represent a range of Joules, where the red color depicts more energy consumption and, reversely, green color depicts less energy. The accuracy is also shown in the map over each circle depicting the energy color to compare the energy spent with the classification accuracy.
We can see that smaller windows result in less energy consumption than bigger windows. This may be due to the increased effort to calculate features for larger window sizes. It is also perceivable that increasing the overlap factor also increases the energy spent, essentially due to the increased number of feature calculations and classifications to be carried out. Relating the energy consumption with the accuracy achieved for a given configuration, it is observable that the best accuracy values reside in more “heated” zones, i.e., where energy consumption is higher. Lower window sizes present less accuracy while higher window sizes provide more accuracy. For instance, in configurations without overlapping (i.e., with an overlap factor of 0), the accuracy rises from 85% for a window of size 500 to 90% for a window of size 1000. The overlap shows more fluctuations in terms of accuracy, however with the best factors concentrated between 0.1 and 0.5. This shows that it is not trivial to select a single window size and overlap factor if it is intended to have two possible scenarios, one where accuracy is the most important factor and another one where energy consumptions is the top priority but still with a minimum accuracy value in mind.
Human activity recognition (HAR) is a classification task for which raw sensors data are crucial. Humans perform activities in unique ways reflected in distinct signals from sensors, which influence accuracy performance. In this paper we presented an analysis of the impact of hyperparameters as window size and overlapping on classification accuracy, execution time and energy consumption. The analysis was focused on a public dataset, which includes raw sensor data from different users.
The results provided confirm the need of adapting the classification model to the current user. Due to the impact of window size and overlapping, each activity requires a specific configuration of these hyperparameters in order to improve classification accuracy. Furthermore, the results also motivate the development of a system that is able to adapt the application at runtime when trade-offs between performance accuracy and energy consumption need to be considered. Bearing in mind this, the window size and overlap factor can be used to develop runtime strategies able to adapt these parameters according to the target goals.
Ongoing work focuses on further studies considering other hyperparameter configurations, as the sampling rate and classifier parameters (e.g., the value of k in kNN). As future work we plan to implement a system able to dynamically adjust at runtime the window size and overlapping factor and aware of activities and users. The dynamic adaptation needs to consider an exploration of possible parameter configurations to find the best configurations for each adaptation scenario and thus the experimental results presented in this paper are also part of that exploration phase.
-  Krishnan, Narayanan C., and Diane J. Cook. ”Activity recognition on streaming sensor data.” Pervasive and mobile computing 10 (2014): 138-154.
-  Dobbins, Chelsea, Reza Rawassizadeh, and Elaheh Momeni. ”Detecting physical activity within lifelogs towards preventing obesity and aiding ambient assisted living.” Neurocomputing 230 (2017): 110-132.
-  E. Miluzzo, A. Varshavsky, S. Balakrishnan, and R. R. Choudhury. ”Tapprints: your finger taps have fingerprints.” In MobiSys, 2012.
-  Aggarwal, J.K., and Ryoo, M.S. (2011). ”Human activity analysis: A review,” ACM Comput. Surv. 43, 3, Article 16 (April 2011), 43 pages. http://dx.doi.org/10.1145/1922649.1922653
-  Lara, O. D., and Labrador, M. A. (2013). ”A Survey on Human Activity Recognition using Wearable Sensors,” in IEEE Communications Surveys & Tutorials, vol. 15, no. 3, pp. 1192-1209, Third Quarter 2013.
Ramamurthy, Sreenivasan R., Roy, Nirmalya (2018) ”Recent trends in machine learning for human activity recognition - A survey.” Wiley Interdisc. Rew.: Data Mining and Knowledge Discovery 8(4), 2018.
-  Shoaib, M., Bosch, S., Incel, O., Scholten, H., and Havinga, P. (2015). ”A Survey of Online Activity Recognition Using Mobile Phones,” In Sensors, vol. 15, pages 2059–2085.
-  Cardoso, Hugo, and João Mendes-Moreira. ”Improving Human Activity Classication through Online Semi-Supervised Learning.” Workshop StreamEvolv co-located with ECML/PKDD 2016, 15-26, 2016.
-  Pisani, Paulo Henrique, and Ana Carolina Lorena. ”A systematic review on keystroke dynamics.” Journal of the Brazilian Computer Society 19.4 (2013): 573-587.
-  Mannini, Andrea, et al. ”Activity recognition using a single accelerometer placed at the wrist or ankle.” Medicine and science in sports and exercise 45.11 (2013): 2193.
-  Banos, Oresti, et al. ”Window size impact in human activity recognition.” Sensors 14.4 (2014): 6474-6499.
Harasimowicz, Adam, T. O. M. A. S. Z. Dziubich, and Adam Brzeski. ”Accelerometer-based Human Activity Recognition and the Impact of the Sample Size.” Proceedings of the 13th International Conference on Artificial Intelligence, Knowledge Engineering and Data Bases, Gdansk, Poland. 2014.
-  Baños, Oresti, et al. ”Evaluating the effects of signal segmentation on activity recognition.” IWBBIO. 2014.
-  Niazi, Anzah H., et al. ”Statistical Analysis of Window Sizes and Sampling Rates in Human Activity Recognition.” HEALTHINF. 2017.
-  Reiss, Attila, and Didier Stricker. ”Creating and benchmarking a new dataset for physical activity monitoring.” Proceedings of the 5th International Conference on PErvasive Technologies Related to Assistive Environments. ACM, 2012.
-  Figo, Davide, Diniz, Pedro C., Ferreira, Diogo R., and Cardoso, João M.P. (2010). ”Preprocessing techniques for context recognition from accelerometer data. Personal Ubiquitous Comput.,” 14, 7 (October 2010), 645-662. http://dx.doi.org/10.1007/s00779-010-0293-9
-  Zhou, Y.,Goldman, S. (2004). ”Democratic co-learning”. In 16th IEEE International Conference on Tools with Artificial Intelligence (pp. 594–602). IEEE Comput. Soc. http://doi.org/10.1109/ICTAI.2004.48
-  Zhou, Z. H.,Li, M. (2005). ”Tri-training: Exploiting unlabeled data using three classifiers”. IEEE Transactions on Knowledge and Data Engineering, 17(11), 1529–1541. http://doi.org/10.1109/TKDE.2005.186