**1. Introduction**

Regular physical activity plays a vital role in improving the health of individuals, whether it is a child under 5 or an elderly above 65. Physical activity has well-documented health benefits and can extensively improve the health and well-being of individuals and reduce the risks from noncommunicable diseases. Both moderate- and vigorous-intensity physical activity improve health. Physical inactivity increases the risk of noncommunicable disease mortality and puts inactive people at a 20–30% higher risk of death in comparison to physically active people [1]. Physical inactivity is among the leading factors which cause mortality and is estimated to contribute to 6% of worldwide deaths [2]. Therefore, World Health Organization (WHO) also recommends people of all ages indulge in physical activity and recommends the duration and intensity of physical activity for different age groups [1]. It has been noted that physical activity improves muscular and cardiorespiratory

**Citation:** Alsareii, S.A.; Awais, M.; Alamri, A.M.; AlAsmari, M.Y.; Irfan, M.; Aslam, N.; Raza, M. Physical Activity Monitoring and Classification Using Machine Learning Techniques. *Life* **2022**, *12*, 1103. https://doi.org/10.3390/ life12081103

Academic Editor: Yudong Cai

Received: 16 June 2022 Accepted: 18 July 2022 Published: 22 July 2022

**Publisher's Note:** MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations.

**Copyright:** © 2022 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https:// creativecommons.org/licenses/by/ 4.0/).

fitness, bone health and mental fitness while reducing the risk of heart diseases, diabetes, hypertension, obesity and fractures [1].

Physical activity and the promotion of healthy living can significantly lower the risks of non-communicable diseases. It also serves as the best remedy for obesity [3]. Obesity is one of the major chronic illnesses and increases the risk of developing many serious comorbidities, such as hypertension, sleep apnea, type 2 diabetes, depression, etc. [3]. Furthermore, obesity is becoming an increasingly prevalent issue. Obesity has become a global epidemic, with global stats suggesting nearly one-third of the world population is obese or overweight. Obesity has also added a significant burden to healthcare services, with nearly 10% of the medical costs in the US being spent on obesity-related issues. It also has been among the major causes of death in the US. Similarly, in Saudi Arabia, with 36% of the population being obese and 69% being categorized as overweight, nearly 20,000 lives are claimed to obesity each year. Therefore, under such circumstances, the provision of physical activity (PA) as a measure to control obesity has become increasingly important [4].

Obesity is one of the prevailing problems responsible for several health issues and medical conditions. Weight loss surgery, also referred to as bariatric or metabolic surgery, is one of the possible solutions for extremely overweight people. While the surgery can result in significant weight losses, it is still not termed a cure for obesity. Obesity is not a matter of concern only for the younger and older adults as it has become very common in children as well [5,6]. Therefore, suitable lifestyle changes should be introduced to avoid regaining weight. Patients who have undergone weight loss surgery need a balanced diet along with regular exercise once they have recovered from surgery. They also need to maintain a regular appointment schedule to keep everything in check. It is therefore important that a technology-driven framework for long-term support is developed to assist these patients in prolonging their healthy living choices and balancing exercise and diet accordingly. With the emergence of digital technologies, information and communications technology (ICT) solutions, machine intelligence and system analytics, post-surgery and long-term support can be efficiently managed with technology-driven solutions. This work primarily focuses on devising effective solutions for monitoring the physical activity levels of the patients in the post-surgery phase to maintain healthy living and discourage weight gain.

The increasing stress on the healthcare systems and the need to promote healthy living urge new measures to promote physical activities. The initial step in encouraging the physical activity is the ability to be able to quantify the physical activity into individual components of tangible impact. As such, physical activity classification can serve as a foundation by recording and transforming physical activities of an individual to give accurate quantification of a daily routine, thus encouraging active and healthy living. This highlights a clear need to develop feasible solutions to monitor the activities of daily living (ADLs) as a measure to avoid/overcome obesity.

Physical activities and exercise both serve as necessary measures for healthy living and maintaining healthy weights. Exercise is the subbranch of physical activity, and it is more structured, repetitive and planned with an intention to maintain or improve body fitness [7]. The promotion of physical activities is towards establishing and maintaining healthy living habits, such as walking to work, using stairs instead of lifts, use of muscles instead of motorized tools, etc. While promoting physical activities offer a more sustainable solution for staying active, it still needs to be quantized to give a better estimation of the efforts put in by the individuals and how these have impacted their healthy living. Quantifying the physical activities performed offers a means to relay the impact to the individuals as well as the medical staff to better evaluate the active status and suggest/intervene accordingly.

The physical activities are logged in several ways where questionnaires and direct observations are conventionally used. The logging of activities requires information on the type of activity performed, the duration for which it was performed and the intensity of the activity. An example could be walking, where the information about how much time is spent walking in a day/week, walking pace, etc. However, these are not as accurate and add additional time commitments from the observee and observer. Therefore, novel techniques are needed to use technology-driven solutions to log the type of activity performed, its duration and intensity.

The recent developments in the miniaturization of inertial sensors equipped with stateof-the-art processing and communication capabilities lay the foundations for the smart health and activity monitoring using machine learning techniques [8,9]. Wearable inertial measurement units (IMUs) use accelerometers and gyroscopes to measure acceleration and angular velocities to offer unobtrusive, reliable, and low-cost measurement of sensory data for physical activity classification. Single or multiple wearable IMUs can be placed on various body locations to classify daily life activities [10].

These small battery-operated wearable IMUs not only offer ease of use but are also equipped with transceivers to accumulate the vitals and activity data of patients to fog/cloud. The data accumulated at cloud or fog devices can be further processed using machine learning techniques [11,12] to identify the activity performed, its duration and intensity. While some existing works offer activity classification, however, there is still much room for improvement.

In [13], the authors proposed a solution for activity classification to identify strange behavior using support vector machines (SVM); however, it used surveillance videos instead of wearable sensors, and the focus of the work was security. Another similar study was carried out in [14], where abnormal behavior of a person was identified using pose estimation. Both these techniques, while detecting physical attributes, are still much further from the objectives of this work and use visual sensors/cameras instead of wearable devices.

In [15], the authors use the asymmetric 3D Convolutional Neural Networks for action recognition. The work was tested on the UCF-101 dataset, which combines actions from YouTube videos. While the claimed results were promising, the work was more tilted towards the general-purpose activity classification and use of visual sensing. Another work presented in [16] provides a unified framework for exploring multidimensional features in conjunction with body part models for pose estimation. A maximum entropy Markov model was used as a recognition engine which was claimed to have accurately detected body parts and recognized physical activity performed.

In [17], the authors used multimodal feature-level fusion for activity recognition. Knearest neighbor and SVM were used for the classification of activities. As an input to the classification system, RGB camera, depth and inertial sensors data were used. While diversity was exploited, the camera usually conflicts with personal and security preferences and offers a limited field of view. Similarly, the depth sensor can also work only in a constrained field of view, which limits the scope of the work. In addition, the study was not focused on activities inspiring healthy living and controlling obesity.

In [18], the authors examined the relationship between physical activity and weight status. The performance of several machine learning techniques was evaluated on a largescale dataset. The objective of the study was to link physical activity with obesity. However, no sensory data were used to classify or log physical activities.

The existing literature and research studies use diverse techniques for activity classification with a wide scope of applications [18–21]. These applications range from security, autonomous transportation, expression evaluation, healthcare, etc. A relatively wide variety of sensors are also used, with some less suitable for the proposed work. While there are a variety of studies focusing on activity classification in healthcare using wearable IMUs [11,12,22–25], these focus on well-balanced data where all the physical activities performed are of equal samples. However, it is important to mention that in real life setting, physical activities (e.g., sitting, standing, walking, lying, stairs up, stairs down, etc.) are unstructured. Therefore, the natural occurrence and frequency of each activity cannot be controlled. This can lead to an imbalanced set of activities where certain classes of activities have more samples, data instances and sensory data than others [10,26]. Joana et al. [27] also found that underrepresented physical activities can affect the performance of the machine learning classifiers due to the availability of limited data at the training stage of the classifier. Therefore, it is important to not only study the impact of class imbalance

on the performance of machine learning classifier when classifying physical activities but also investigate how such machine learning classifiers behave when more than one class of physical activities are imbalanced at their training stage. To the best of our knowledge, none of the existing studies have investigated the effect of multi class imbalance induced at the classifier training stage and its impact on the performance of physical activity classification. Moreover, the study also investigated a variety of machine learning classifiers to observe, which are more sensitive to class imbalance than others considering the overall performance of the physical activity classification system. Therefore, the work presented in this paper offers a unique contribution to evaluating physical activity to support healthcare professionals and medical staff in making correct interventions, maintaining diet and mandatory active living style for overweight and obese patients.

The main contributions of the paper are:


The rest of the paper is organized as follows: Section 2 presents the proposed system model including a data communication and activity classification framework, dataset used, feature computation, experimentation and implementation of machine learning algorithms. Research and discussion are covered in Sections 3 and 4, respectively, whereas the concluding remarks and future directives are presented in Section 5.
