Do you ever wonder how your smartwatch or smartphone can differentiate between walking and jogging while tracking your exercise routine? This aspect is known as Human Activity Recognition (HAR) and is based on the analysis of various sensors’ data including GPS, accelerometer, gyroscope, magnetometer, barometer, etc. The human activities to be identified may include sitting, standing, walking, going upstairs, going downstairs, jogging, running, cycling, etc. and various locations such as indoor, outdoor, underground, etc. Additionally, motorized travel modes may also be included such as bike, car, bus, train, subway, etc.

A general methodology for Human Activity Recognition as followed by most researchers is described below.

  1. Annotated data collection from the required sensor(s)
  2. Data wrangling
  3. Feature extraction
  4. Formation of training and testing datasets
  5. Training of machine learning algorithm(s)
  6. Testing of the trained algorithm(s) 
  7. Post-processing, if required
  8. Reporting of performance measures

Our study on Human Activity Recognition had the following two main objectives.

  • Investigate the impact of information sharing on the accuracy of activity detection.
  • Develop a low-cost methodology for activity detection.

Information sharing between the training and testing datasets is undesirable since it increases the detection accuracy erroneously. Such sharing may happen at three levels. 1) Data level: If various features are extracted using sliding windows then each extracted data point will share some information with its neighboring data points. Hence, it would become easier for the algorithm to predict a certain data point based on the trends learned from its neighbors. 2) Trip level: Each trip of a certain activity would follow a certain trend. If part of the trip is used to train the algorithm and the remaining part is used for prediction, the accuracy would become high. 3) Participant level: Each participant follows a certain activity pattern. Thus, it becomes comparatively easy for an algorithm to detect an activity recoded by the same participant whose activity pattern has already been learned. 

To reduce the computational cost and preserve smartphone battery, only accelerometer data was used in the study. Features were extracted and data was divided among training and testing datasets following three different stratification methods, having varying levels of information sharing. Several algorithms were tested and compared based on their performance metrics including computation time. The results reveal that XGBoost takes the least computation time while providing high prediction accuracy. The final detection accuracy ranges from 99.8% to 77.6% depending on the level of information sharing. This strongly suggests that when reporting accuracy values, the associated information sharing levels should be provided as well to allow the results to be interpreted in the correct context.

(Full paper available at

By Muhammad Awais Shafique and Sergi Saurí Marchán

Share This