# Towards a Complete Set of Gym Exercises Detection Using Smartphone Sensors

Authors: Usman Ali Khan; Iftikhar Ahmed Khan; Ahmad Din; Waqas Jadoon; Rab Nawaz Jadoon; Muhammad Amir Khan; Fiaz Gul Khan; Abdul Nasir Khan
Journal: Scientific Programming
 (2020)

---

## Abstract

Smartphones with gym exercises predictors can act as trainers for the gym-goers. However, various available solutions do not have the complete set of most practiced exercises. Therefore, in this research, a complete set of most practiced 26 exercises was identified from the literature. Among the exercises, 14 were unique and 12 were common to the existing literature. Furthermore, finding suitable smartphone attachment position(s) and the number of sensors to predict exercises with the highest possible accuracy were also the objectives of the research. Besides, this study considered the most number of participants (20) as compared to the existing literature (maximum 10). The results indicate three key lessons: (a) the most suitable classifier to predict a class (exercise) from the sensor-based data was found to be KNN (K-nearest neighbors); (b) the sensors placed at the three positions (arm, belly, and leg) could be more accurate than other positions for the gym exercises; and (c) accelerometer and gyroscope when combined can provide accurate classification up to 99.72% (using KNN as classifier at all 3 positions).


---

## Body

## 1. Introduction

The advancement in the technology troubled humans by making their lives busy. This is affecting their health negatively [1]. However, the technology also helps humans to improve their health, education, business, and social relationships [2]. The beneficial impact of technology is tremendous, especially in the health sector. Multiple hardware and software [3, 4] are used to improve overall human health. Among various sources of maintaining health, gyms are the major source of physical fitness.People join gyms to achieve goals like bodybuilding, physical fitness, or losing weight. In the modern world, technology has replaced the traditional concepts of guidance and training to stay healthy and fit. The tools like smartphones and devices like wearable gadgets are among the many resources that are helping to stay healthy and fit [5–8]. There is also some researches like [9–11] that support the notion that technology can help to achieve fitness objectives. Besides, there are various smartphone applications like [12–14] that can track different physical activities, e.g., walking, running, sitting, and standing with the corresponding calorie burn out. The sensors (accelerometer, gyroscope, etc.) are used to track the activities.Many wearable devices and smartphone applications track physical activities and calorie burnout like [3, 4]. However, none of the studies provides the information appropriate to measure major gym activities. For example, research studies such as [9, 11, 15] targeted a group of upper body muscles along with some warm-up exercises only. This research is a similar attempt yet is different in many aspects. First, in this research, 14 exercises of different muscle groups (abdominal, upper body, and lower body) are added to move towards a complete solution.Second, in most of the existing research, the position of the sensors or the devices was only at the arm. Seeger et al. [16] used three sensors at the following positions: a single accelerometer at the wrist, a hand glove, and a sensor at torso position. We hypothesized that the use of accelerometer and gyroscope at three body positions (arm, leg, and belly) could enhance accuracy because of the dependence of various gym exercises on either of the positions individually or in combination.The third aim is to determine the number of sensors required to detect an exercise accurately. At the hypothesized three positions, five sensors are used: at the arm and the leg, the accelerometer and gyroscope together, while on the belly, only the accelerometer. The single sensor at the belly will only be used to determine the laying (x-axis), standing (y-axis), or in-between position that is often used in the gym exercises (e.g., angle leg press). The contribution of these sensors towards the accuracy has been analyzed in this research as well.The classification algorithms used to detect exercises in the related work such as [7, 9, 11, 15–17] are linear discriminant analysis (LDA), quadratic discriminant analysis (QDA), K-nearest neighbor (KNN), Naïve Bayes (NB), support vector machine (SVM), and dynamic time wrapping (DTW) algorithms. The result of the accuracies achieved by the studies was promising. However, their used datasets were quite sparse (collected from 8 to 10 persons) for 43 unique exercises. The exercises were also related to each other or were exercises from the same muscle groups having the same activity motion/patterns. The fourth aim of this study is to increase the number of participants in the real-world settings to bring more rigor to the findings. The increase in the number of participants and thus dataset could also affect the choice of the exercise detection algorithm. This forms the fifth aim, the selection of the most appropriate algorithm(s) to detect gym exercises.The rest of the paper is organized as follows. Section2 discusses the relevant literature in the context of the aims of this study. Section 3 is about the materials and methods. In Section 4, experimental setup is elaborated. In Section 5, the analysis and results are discussed. Section 6 concludes the paper as well as identifies some limitations. The section also embarks upon the possible future work.


## 2. Literature Review

In this section, related work is discussed in the context of the aims of this study. Therefore, this section is divided into the following three subsections: (1) exercise detection, (2) positioning and the number of sensors, and (3) exercise detection algorithms. The participant’s selection is described in the Materials and Methods section.


### 2.1. Exercise Selection

The first activity recognition study based on wearable sensors device [18] was published in 2000. In this study, they attached two accelerometers inside the trousers’ pocket to recognize daily life activities. The study [19] examines the use of a single smartphone accelerometer in activity recognition. The reported results showed accuracies between 80% and 97% depending on the set of activities used and the processing techniques. Muehlbauer et al. [7] used the arm position to attach an Arm-Hostler with a fixed sensor to recognize a set of ten upper body gym exercises. They reported 93.6% accuracy in more than 90% of the cases they studied. MyHealthAssistant [16] classified the gym exercises using three accelerometers (on the hand glove, wrist, and torso). They trained a Bayesian classifier on the mean and variance features collected via an accelerometer. They collected the data of 11 exercises and achieved 92% accuracy. Chang et al. [8] used 2 accelerometers (on the hand and waist position) and examined a Hidden Markov Model (HMM) and a Bayes Classifier to identify exercises. They achieved 90% accuracy for the set of nine exercises and around 5% of the overall miss-count rate.The activity recognition data collected from the literature corresponding from the years 2006–2018 found only 6 of 25 research studies related to gym exercises while the remaining 19 of 25 research papers were about daily life physical activities, emotional recognition, and elderly fall detection [20]. All the 25 papers were used to extract the information like the type of sensors used, features used to recognize activities, and the classification algorithms used.


### 2.2. Position and Number of Sensors

In most of the literature, only a single sensor for activity recognition is utilized. However, some studies used more than one sensor as well. For example, the authors in [21] put both an accelerometer and a gyroscope together and stated that the gyroscope adds nothing to the recognition results. However, some contradictory results are reported by the authors in [22]. The study [10] reported a 3.1 to 13.4 percent increase in recognition accuracy for 08 of 09 activities when an accelerometer is combined with a gyroscope while using the KNN classification algorithm. The average accuracy reported was 83.7% with an accelerometer and 90.2% with both accelerometer and gyroscope with an increase of 6.5% in average accuracy. The study also revealed that the sensor combination provides better results as compared to accelerometer alone. However, the paper does not report individual accuracies, thus resulting in an ambiguity whether the gyroscope or the accelerometer played a major role in the accuracies.Table1 provides the details of the number of sensors and device positions as per the literature while Table 2 describes the use of the combination of sensors (sensor fusion) as well as their accuracies.Table 1
Details of sensors/positions used.
S. no.(Number)/position of smartphones/devicesNames of sensors usedAccuracy acquired (%)Reference1(01)/armAccelerometer, gyroscope, magnetometer, electromyography EMG75.70[11]2(01)/armAccelerometer89.00[15]3(01)/armAccelerometer and gyroscope93.00[9]4(03)/01 wrist, 01 hand glove, and 01 torso03 accelerometers only92.00[16]5(01)/armAccelerometer and gyroscope93.60[7]6(01)/armAccelerometer90.00[17]Table 2
Detail of sensors.
Sensor nameTimes usedReasonAccuracies min., max., and avg.ReferencesAccelerometer12The accelerometer is the most powerful sensor in smartphones. It can be used for activity recognition by inferring the user’s movements, such as walking, standing, running, sitting, and gym activities.Min. accuracy = 82.2%[15, 23–33]Max. accuracy = 97.3%Avg. accuracy = 87.7%Accelerometer and gyroscope08Accelerometer and a gyroscope, to be used in recognizing physical activity and providing the strongest result.Min. accuracy = 67.8%[10, 11, 31, 34–38]Max. accuracy = 97%Avg. accuracy = 88.3%Accelerometer, gyroscope, and magnetometer05Adding a magnetometer with an accelerometer and gyroscope. The results are not encouraging because magnetometer causes overfitting in training classifiers due to its dependence on directions.Min. accuracy = 71.6%[10, 11, 34, 37, 39]Max. accuracy = 96%Avg. accuracy = 82.6%From the analysis of Table2, it can be argued that the combination of accelerometer and gyroscope provides the strongest accuracy results. Moreover, in most cases, a gyroscope does improve the recognition accuracy from 3.1% to 13.4% when used in combination with an accelerometer [10]. The magnetometer’s role in activity recognition was poor.


### 2.3. Exercise Detection Algorithms

The related literature has also used different classification algorithms. For example, the authors of [21] used KNN combined with support vector machine (SVM) and the authors of [22] used KNN combined with decision tree and Naïve Bayes, while the authors of [40] used J48 Decision Tree combined with Naive Bayes for exercise recognition. They reported an average accuracy of 95%, 90.2%, and 88%, respectively. Table 3 shows the top three classifiers Naïve Bayes (NB), decision trees (J48), and K-nearest neighbor (KNN) being abundantly used for the activity recognition purpose.Table 3
Details of classifier algorithms.
AlgorithmTimes usedReferencesNaïve Bayes5[4, 5, 12, 14, 15]Decision trees5[4, 9, 11, 12, 14]K-neaest neighbor3[3, 4, 14]Linear discriminant analysis2[21, 40]Hidden Markov model (HMM)2[10, 15]Quadratic discriminant analysis QDA1[40]Logistic regression2[2, 9]Support vector machine1[16]Dynamic time warping (DTW)1[13]The accuracy of the results depends on the suitable selection of the classification algorithm as well as on the selection of the suitable parameters for them. Table4 shows the top three most used features in the literature, that is, mean, standard deviation, and minimum and maximum as classification algorithm parameters.Table 4
Details of features.
FeaturesNo. of papers in which usedReferencesMean15[2–4, 6–9, 11, 14–16, 19, 21, 22, 40]Standard deviation11[3, 4, 8, 9, 14, 15, 18, 19, 21, 22, 40]Minimum/maximum09[3, 4, 13, 15, 16, 18, 32, 33, 40]


## 2.1. Exercise Selection

The first activity recognition study based on wearable sensors device [18] was published in 2000. In this study, they attached two accelerometers inside the trousers’ pocket to recognize daily life activities. The study [19] examines the use of a single smartphone accelerometer in activity recognition. The reported results showed accuracies between 80% and 97% depending on the set of activities used and the processing techniques. Muehlbauer et al. [7] used the arm position to attach an Arm-Hostler with a fixed sensor to recognize a set of ten upper body gym exercises. They reported 93.6% accuracy in more than 90% of the cases they studied. MyHealthAssistant [16] classified the gym exercises using three accelerometers (on the hand glove, wrist, and torso). They trained a Bayesian classifier on the mean and variance features collected via an accelerometer. They collected the data of 11 exercises and achieved 92% accuracy. Chang et al. [8] used 2 accelerometers (on the hand and waist position) and examined a Hidden Markov Model (HMM) and a Bayes Classifier to identify exercises. They achieved 90% accuracy for the set of nine exercises and around 5% of the overall miss-count rate.The activity recognition data collected from the literature corresponding from the years 2006–2018 found only 6 of 25 research studies related to gym exercises while the remaining 19 of 25 research papers were about daily life physical activities, emotional recognition, and elderly fall detection [20]. All the 25 papers were used to extract the information like the type of sensors used, features used to recognize activities, and the classification algorithms used.


## 2.2. Position and Number of Sensors

In most of the literature, only a single sensor for activity recognition is utilized. However, some studies used more than one sensor as well. For example, the authors in [21] put both an accelerometer and a gyroscope together and stated that the gyroscope adds nothing to the recognition results. However, some contradictory results are reported by the authors in [22]. The study [10] reported a 3.1 to 13.4 percent increase in recognition accuracy for 08 of 09 activities when an accelerometer is combined with a gyroscope while using the KNN classification algorithm. The average accuracy reported was 83.7% with an accelerometer and 90.2% with both accelerometer and gyroscope with an increase of 6.5% in average accuracy. The study also revealed that the sensor combination provides better results as compared to accelerometer alone. However, the paper does not report individual accuracies, thus resulting in an ambiguity whether the gyroscope or the accelerometer played a major role in the accuracies.Table1 provides the details of the number of sensors and device positions as per the literature while Table 2 describes the use of the combination of sensors (sensor fusion) as well as their accuracies.Table 1
Details of sensors/positions used.
S. no.(Number)/position of smartphones/devicesNames of sensors usedAccuracy acquired (%)Reference1(01)/armAccelerometer, gyroscope, magnetometer, electromyography EMG75.70[11]2(01)/armAccelerometer89.00[15]3(01)/armAccelerometer and gyroscope93.00[9]4(03)/01 wrist, 01 hand glove, and 01 torso03 accelerometers only92.00[16]5(01)/armAccelerometer and gyroscope93.60[7]6(01)/armAccelerometer90.00[17]Table 2
Detail of sensors.
Sensor nameTimes usedReasonAccuracies min., max., and avg.ReferencesAccelerometer12The accelerometer is the most powerful sensor in smartphones. It can be used for activity recognition by inferring the user’s movements, such as walking, standing, running, sitting, and gym activities.Min. accuracy = 82.2%[15, 23–33]Max. accuracy = 97.3%Avg. accuracy = 87.7%Accelerometer and gyroscope08Accelerometer and a gyroscope, to be used in recognizing physical activity and providing the strongest result.Min. accuracy = 67.8%[10, 11, 31, 34–38]Max. accuracy = 97%Avg. accuracy = 88.3%Accelerometer, gyroscope, and magnetometer05Adding a magnetometer with an accelerometer and gyroscope. The results are not encouraging because magnetometer causes overfitting in training classifiers due to its dependence on directions.Min. accuracy = 71.6%[10, 11, 34, 37, 39]Max. accuracy = 96%Avg. accuracy = 82.6%From the analysis of Table2, it can be argued that the combination of accelerometer and gyroscope provides the strongest accuracy results. Moreover, in most cases, a gyroscope does improve the recognition accuracy from 3.1% to 13.4% when used in combination with an accelerometer [10]. The magnetometer’s role in activity recognition was poor.


## 2.3. Exercise Detection Algorithms

The related literature has also used different classification algorithms. For example, the authors of [21] used KNN combined with support vector machine (SVM) and the authors of [22] used KNN combined with decision tree and Naïve Bayes, while the authors of [40] used J48 Decision Tree combined with Naive Bayes for exercise recognition. They reported an average accuracy of 95%, 90.2%, and 88%, respectively. Table 3 shows the top three classifiers Naïve Bayes (NB), decision trees (J48), and K-nearest neighbor (KNN) being abundantly used for the activity recognition purpose.Table 3
Details of classifier algorithms.
AlgorithmTimes usedReferencesNaïve Bayes5[4, 5, 12, 14, 15]Decision trees5[4, 9, 11, 12, 14]K-neaest neighbor3[3, 4, 14]Linear discriminant analysis2[21, 40]Hidden Markov model (HMM)2[10, 15]Quadratic discriminant analysis QDA1[40]Logistic regression2[2, 9]Support vector machine1[16]Dynamic time warping (DTW)1[13]The accuracy of the results depends on the suitable selection of the classification algorithm as well as on the selection of the suitable parameters for them. Table4 shows the top three most used features in the literature, that is, mean, standard deviation, and minimum and maximum as classification algorithm parameters.Table 4
Details of features.
FeaturesNo. of papers in which usedReferencesMean15[2–4, 6–9, 11, 14–16, 19, 21, 22, 40]Standard deviation11[3, 4, 8, 9, 14, 15, 18, 19, 21, 22, 40]Minimum/maximum09[3, 4, 13, 15, 16, 18, 32, 33, 40]


## 3. Materials and Methods

In this section, the materials and methods used in the study are discussed. Section3.1 discusses the selection of gym exercises for the current study. Section 3.2 is about the development of the application used for the data collection process. Section 4 is about experiment and data collection methods used in the study.


### 3.1. Selection of the Exercises

The process of the selection was started by collecting a list of all the gym exercises from the two sources [41, 42]. The sources listed a total of 74 gym exercises which will be called set TE (Total Exercises). To verify the repeatability of the exercises in gyms, one of the authors visited four most known and commonly used gyms of the city to meet with the gym-goers. They were interviewed about the most common exercises the gym-goers trained on. The results were a subset of 54 most used gym exercises. The set will be called the set SE (Subexercises).The set SE was compared with a set of the common exercises mentioned in the literature which resulted in (Common Exercises) set CE having 35 exercises. The exercises in CE were further categorized into exercises group along with information like exercise positions and equipment used to do the exercise.Further analysis of the set CE revealed that five exercises were repeating in different muscle groups with different names. One of the exercises occurred three times and the rest of the four exercises twice in each muscle group. Removing the repetitions from the set CE resulted in a set of 29 exercises.From the 29 exercises, 3 exercises were related to the head and are considered as warm-up exercises in the literature [43]. These 3 exercises are also removed from the list of 29 exercises reducing the final exercise set (Total Final Exercises) TFE to 26.The exercises mentioned in the above paragraph were extracted from research papers like [7, 9, 11, 15–17]. Among these references, the study in [17] was related to only gym warm-up exercises and thus was not included in the exercise selection. The remaining five papers were used to form 5 exercise sets (EP1–EP5). Here, E stands for exercise and P for the paper. Thus, EP1 represents exercise set extracted from paper 1, that is, reference [7] and so on. The union of the exercise sets EP1–EP5 was taken resulting in set (Total Exercises from Papers) TEP containing 43 exercises considered in the literature. The set TFE was subtracted from the set TEP to provide 14 unique exercises and 12 exercises that are considered in the literature (Table 5).Table 5
The set of final 26 exercises considered in this paper.
S. no.Repeating R/unique UExercise groupExercise nameExercise positionEquipment used1Unique exercises groupShoulderFace pullStandingCable/rope2ShoulderCable front raiseStandingCable/rope3BicepsScott curlSitting bendDumbbell4BicepsSmith machine drag curlSittingBarbell5TricepsTriceps with barStandingCable/rope6TricepsDecline close grip bench pressLying bench declineBarbell7ChestStanding cable crossStandingCable/rope8BackWide grip pull upStanding hangingFix rods9BackT bar rowsSitting hangingBarbell10BackChin upsStanding hangingFix rods11AbsAdjustable sit-up benchSitting and lyingBench12AbsAbs wheelLyingAbs wheel13AbsRoman chairsLyingRoman chair14AbsFlutter kickLyingFlat surface15Common exercises groupLegsLeg pressLyingLeg press machine16LegsRomanian deadliftStandingBarbell17LegsBarbell squatSit-standBarbell18ShoulderIncline press wide gripLyingBarbell19ShoulderStanding barbell pressStandingBarbell20BicepsInclined dumbbell curlSitting inclineDumbbell21BicepsBarbell preacher curlSittingBarbell22TricepsTriceps press with cableStandingCable/rope23ChestMachine bench pressSittingBench machine24ChestDipsStanding hangingFix rods25ChestPec deck machine (butterfly)SittingPec deck machine26ShoulderSeated barbell shoulder pressSittingBarbell


### 3.2. Application Development

To accomplish the objectives of this research, the first requirement was to develop an application to collect data from the participants. For the purpose, an android based smartphone application was developed. The users could add, view, edit, and delete personal profiles. The user interface of the developed application is depicted in Figure1, whereas the flow of the user’s interaction with the application is elaborated in Figure 2. The application is also provided as a supplementary file with the paper for the researchers who want to replicate the research.Figure 1
Application user interface.Figure 2
Application activity flow diagram.Figure2 shows the overall process followed in the developed application for the data collection. The start screen provides options for the new users to register themselves, while already registered users can go to the registered users' screen. After the selection of the new registration option, the user could move to the signup screen option. There they either can enter their profile information such as height and weight to register themselves with the new user profile or could go back to the main screen without registration. After clicking already registered users option, users could move to already registered users profile list to select their profile by name. The selected profile screen with information appears about the users from where they can start recording the exercise data and will also start doing the exercise. They can also view their stored records or could go back to the main screen. The users could exit the application from the main screen.


## 3.1. Selection of the Exercises

The process of the selection was started by collecting a list of all the gym exercises from the two sources [41, 42]. The sources listed a total of 74 gym exercises which will be called set TE (Total Exercises). To verify the repeatability of the exercises in gyms, one of the authors visited four most known and commonly used gyms of the city to meet with the gym-goers. They were interviewed about the most common exercises the gym-goers trained on. The results were a subset of 54 most used gym exercises. The set will be called the set SE (Subexercises).The set SE was compared with a set of the common exercises mentioned in the literature which resulted in (Common Exercises) set CE having 35 exercises. The exercises in CE were further categorized into exercises group along with information like exercise positions and equipment used to do the exercise.Further analysis of the set CE revealed that five exercises were repeating in different muscle groups with different names. One of the exercises occurred three times and the rest of the four exercises twice in each muscle group. Removing the repetitions from the set CE resulted in a set of 29 exercises.From the 29 exercises, 3 exercises were related to the head and are considered as warm-up exercises in the literature [43]. These 3 exercises are also removed from the list of 29 exercises reducing the final exercise set (Total Final Exercises) TFE to 26.The exercises mentioned in the above paragraph were extracted from research papers like [7, 9, 11, 15–17]. Among these references, the study in [17] was related to only gym warm-up exercises and thus was not included in the exercise selection. The remaining five papers were used to form 5 exercise sets (EP1–EP5). Here, E stands for exercise and P for the paper. Thus, EP1 represents exercise set extracted from paper 1, that is, reference [7] and so on. The union of the exercise sets EP1–EP5 was taken resulting in set (Total Exercises from Papers) TEP containing 43 exercises considered in the literature. The set TFE was subtracted from the set TEP to provide 14 unique exercises and 12 exercises that are considered in the literature (Table 5).Table 5
The set of final 26 exercises considered in this paper.
S. no.Repeating R/unique UExercise groupExercise nameExercise positionEquipment used1Unique exercises groupShoulderFace pullStandingCable/rope2ShoulderCable front raiseStandingCable/rope3BicepsScott curlSitting bendDumbbell4BicepsSmith machine drag curlSittingBarbell5TricepsTriceps with barStandingCable/rope6TricepsDecline close grip bench pressLying bench declineBarbell7ChestStanding cable crossStandingCable/rope8BackWide grip pull upStanding hangingFix rods9BackT bar rowsSitting hangingBarbell10BackChin upsStanding hangingFix rods11AbsAdjustable sit-up benchSitting and lyingBench12AbsAbs wheelLyingAbs wheel13AbsRoman chairsLyingRoman chair14AbsFlutter kickLyingFlat surface15Common exercises groupLegsLeg pressLyingLeg press machine16LegsRomanian deadliftStandingBarbell17LegsBarbell squatSit-standBarbell18ShoulderIncline press wide gripLyingBarbell19ShoulderStanding barbell pressStandingBarbell20BicepsInclined dumbbell curlSitting inclineDumbbell21BicepsBarbell preacher curlSittingBarbell22TricepsTriceps press with cableStandingCable/rope23ChestMachine bench pressSittingBench machine24ChestDipsStanding hangingFix rods25ChestPec deck machine (butterfly)SittingPec deck machine26ShoulderSeated barbell shoulder pressSittingBarbell


## 3.2. Application Development

To accomplish the objectives of this research, the first requirement was to develop an application to collect data from the participants. For the purpose, an android based smartphone application was developed. The users could add, view, edit, and delete personal profiles. The user interface of the developed application is depicted in Figure1, whereas the flow of the user’s interaction with the application is elaborated in Figure 2. The application is also provided as a supplementary file with the paper for the researchers who want to replicate the research.Figure 1
Application user interface.Figure 2
Application activity flow diagram.Figure2 shows the overall process followed in the developed application for the data collection. The start screen provides options for the new users to register themselves, while already registered users can go to the registered users' screen. After the selection of the new registration option, the user could move to the signup screen option. There they either can enter their profile information such as height and weight to register themselves with the new user profile or could go back to the main screen without registration. After clicking already registered users option, users could move to already registered users profile list to select their profile by name. The selected profile screen with information appears about the users from where they can start recording the exercise data and will also start doing the exercise. They can also view their stored records or could go back to the main screen. The users could exit the application from the main screen.


## 4. Methods

The developed application was installed on 3 smartphones and was positioned as shown in Figure3. An LG Model F180 was attached to the leg while another similar model was attached to the arm. This model supports both the accelerometer and gyroscope sensors providing the values of acceleration and rotation. For the belly position, we required only one sensor to determine the state (sitting, laying) of the participant. For the purpose Q-Mobile model, i7 was attached at the belly position having the support of only the accelerometer sensor.Figure 3
Smartphone positioned on participant body.The research also aimed to increase the number of participants and to collect varying data. Therefore, 20 participants with two sets of a total of 10 repetitions for each participant were used for the purpose. The 10 repetitions are used in the related literature before such as [11]. The data were collected against a selected set of 26 exercises. The smartphones were attached at three different body positions (arm, belly, and leg). All the gym-goers taking part in data collection were asked to behave normally as their usual exercising day. The sensors X, Y, and Z values were being recorded and stored in a file by the application while performing exercises. All the activities were carried out indoors in a gym.


### 4.1. Experimental Setup

The experimental setup section is divided into a further four subsections. Section4.1.1 is about ethical compliance as per involvement and data collection of the participant. Section 4.1.2 explains the demographics of the participants. Section 4.1.3 is about the data collection process. The preparation of the data for the analysis is discussed in Section 4.1.4.


#### 4.1.1. Ethical Compliance

The departmental ethics committee, called Project Research and Evaluation Committee (PREC), approved the study design and the procedure as defined in the above section. Informed consent for the study was obtained from the participants of this study.


#### 4.1.2. Participants

For the selection of the participants, the busiest gym in the center of the city was selected. The gym-goers used to visit the gym regularly were approached and the aims and objectives of the data collection were explained to them. The 20 participants all males volunteered to participate in the data collection process. The participants were between the age brackets of 20 and 35. Their mean age was 25.85 years with SD of 4.13. Their heights ranged from 162 to 181 cm with a mean of 171.1 cm and SD of 5.34. Their weights ranged from 62 to 80 kg with a mean of 68.1 kg and SD of 5.56, respectively. The gym experience of the participant was between 2 and 19 months with a mean of 9.35 months and SD of 4.90. All the exercises were completed with free weights (participants choose weights themselves).


#### 4.1.3. Data Collection

The data were recorded from 5 sensors (two sensors of the smartphone attached at the leg, two attached at the arm, and one attached at belly). All the sensors recordedX, Y, and Z values while the participant was doing the exercise. A triaxial accelerometer estimates the acceleration along X, Y, and Z axis and gyroscope (Pitch, Yaw, and Roll) helps the accelerometer to predict the orientation of the sensor. Three smartphones were synchronized to get the time from the server. The time was recorded up to millisecond along with X, Y, and Z values. This resulted in the 15 X, Y, and Z values along with a timestamp, the category of the exercise, and the exercise name. The dataset available from the literature [17, 44, 45] was not used because of the nonavailability of the data of 14 unique exercises. We also decided to collect data for the exercises whose data was available because of the probable setup differences between the existing studies and this study. This may have help in countering the bias and variations.


#### 4.1.4. Data Preparation

The recognition process includes a collection of exercises data using multiple sensors. The data is preprocessed and segmented and the features are extracted and classified as the last step [11, 46]. The same process is followed in this research as well.Three different files containing exercise data from each smartphone were combined carefully to match the participant's assigned ids and time stamps. In the second step, the recorded data from CSV files were preprocessed to remove the extra noise. For example, at the start and the end of an exercise, the participant's movements were very random as well as jerky and were not aligned with the required exercise. Therefore, to remove this noise we removed the data from the first 3 seconds and the last 3 seconds of the recorded data of each exercise. For each exercise, there were 2 sets, each set of 10 repetitions and with an average participant time consumption for an exercise of 38 seconds. After preprocessing, we considered the data of 32 seconds only. The application was programmed to record 4 samples in a minute.Various previous studies such as [11] used a 4-second window to extract required features and 1 minute of the slide to vary the data. We adopted the same strategy. The features extracted were based on the most used features (mean, standard deviation, and minimum and maximum) for the similar nature of the data as presented in Table 3. For each of the X, Y, and Z values, these four features were extracted forming a total of 60 features (36 accelerometer features and 24 gyroscope features).To analyze the preprocessed data, we used WEKA (Waikato Environment for Knowledge Analysis) [47]. The preprocessed data (extracted features) were converted to ARFF (Attribute-Relation File Format). The listed attributes were named as per the following strategy. In the name of the attribute, the first position character ‘a’ stands for an arm, ‘b’ stands for the belly, and ‘l’ stands for the leg. The second position character ‘a’ or ‘g’ stands for accelerometer or gyroscope. The third position character ‘x’, ‘y’, or ‘z’ stands for axis values X, Y, and Z. The selected classifiers NB, KNN, and J48 as per Table 3 were utilized with default configuration settings. In the test options, the percentage split with 80% training and 20% testing option was selected as used also by [38, 48] to evaluate the performance and accuracy of the classifiers.


## 4.1. Experimental Setup

The experimental setup section is divided into a further four subsections. Section4.1.1 is about ethical compliance as per involvement and data collection of the participant. Section 4.1.2 explains the demographics of the participants. Section 4.1.3 is about the data collection process. The preparation of the data for the analysis is discussed in Section 4.1.4.


### 4.1.1. Ethical Compliance

The departmental ethics committee, called Project Research and Evaluation Committee (PREC), approved the study design and the procedure as defined in the above section. Informed consent for the study was obtained from the participants of this study.


### 4.1.2. Participants

For the selection of the participants, the busiest gym in the center of the city was selected. The gym-goers used to visit the gym regularly were approached and the aims and objectives of the data collection were explained to them. The 20 participants all males volunteered to participate in the data collection process. The participants were between the age brackets of 20 and 35. Their mean age was 25.85 years with SD of 4.13. Their heights ranged from 162 to 181 cm with a mean of 171.1 cm and SD of 5.34. Their weights ranged from 62 to 80 kg with a mean of 68.1 kg and SD of 5.56, respectively. The gym experience of the participant was between 2 and 19 months with a mean of 9.35 months and SD of 4.90. All the exercises were completed with free weights (participants choose weights themselves).


### 4.1.3. Data Collection

The data were recorded from 5 sensors (two sensors of the smartphone attached at the leg, two attached at the arm, and one attached at belly). All the sensors recordedX, Y, and Z values while the participant was doing the exercise. A triaxial accelerometer estimates the acceleration along X, Y, and Z axis and gyroscope (Pitch, Yaw, and Roll) helps the accelerometer to predict the orientation of the sensor. Three smartphones were synchronized to get the time from the server. The time was recorded up to millisecond along with X, Y, and Z values. This resulted in the 15 X, Y, and Z values along with a timestamp, the category of the exercise, and the exercise name. The dataset available from the literature [17, 44, 45] was not used because of the nonavailability of the data of 14 unique exercises. We also decided to collect data for the exercises whose data was available because of the probable setup differences between the existing studies and this study. This may have help in countering the bias and variations.


### 4.1.4. Data Preparation

The recognition process includes a collection of exercises data using multiple sensors. The data is preprocessed and segmented and the features are extracted and classified as the last step [11, 46]. The same process is followed in this research as well.Three different files containing exercise data from each smartphone were combined carefully to match the participant's assigned ids and time stamps. In the second step, the recorded data from CSV files were preprocessed to remove the extra noise. For example, at the start and the end of an exercise, the participant's movements were very random as well as jerky and were not aligned with the required exercise. Therefore, to remove this noise we removed the data from the first 3 seconds and the last 3 seconds of the recorded data of each exercise. For each exercise, there were 2 sets, each set of 10 repetitions and with an average participant time consumption for an exercise of 38 seconds. After preprocessing, we considered the data of 32 seconds only. The application was programmed to record 4 samples in a minute.Various previous studies such as [11] used a 4-second window to extract required features and 1 minute of the slide to vary the data. We adopted the same strategy. The features extracted were based on the most used features (mean, standard deviation, and minimum and maximum) for the similar nature of the data as presented in Table 3. For each of the X, Y, and Z values, these four features were extracted forming a total of 60 features (36 accelerometer features and 24 gyroscope features).To analyze the preprocessed data, we used WEKA (Waikato Environment for Knowledge Analysis) [47]. The preprocessed data (extracted features) were converted to ARFF (Attribute-Relation File Format). The listed attributes were named as per the following strategy. In the name of the attribute, the first position character ‘a’ stands for an arm, ‘b’ stands for the belly, and ‘l’ stands for the leg. The second position character ‘a’ or ‘g’ stands for accelerometer or gyroscope. The third position character ‘x’, ‘y’, or ‘z’ stands for axis values X, Y, and Z. The selected classifiers NB, KNN, and J48 as per Table 3 were utilized with default configuration settings. In the test options, the percentage split with 80% training and 20% testing option was selected as used also by [38, 48] to evaluate the performance and accuracy of the classifiers.


## 4.1.1. Ethical Compliance

The departmental ethics committee, called Project Research and Evaluation Committee (PREC), approved the study design and the procedure as defined in the above section. Informed consent for the study was obtained from the participants of this study.


## 4.1.2. Participants

For the selection of the participants, the busiest gym in the center of the city was selected. The gym-goers used to visit the gym regularly were approached and the aims and objectives of the data collection were explained to them. The 20 participants all males volunteered to participate in the data collection process. The participants were between the age brackets of 20 and 35. Their mean age was 25.85 years with SD of 4.13. Their heights ranged from 162 to 181 cm with a mean of 171.1 cm and SD of 5.34. Their weights ranged from 62 to 80 kg with a mean of 68.1 kg and SD of 5.56, respectively. The gym experience of the participant was between 2 and 19 months with a mean of 9.35 months and SD of 4.90. All the exercises were completed with free weights (participants choose weights themselves).


## 4.1.3. Data Collection

The data were recorded from 5 sensors (two sensors of the smartphone attached at the leg, two attached at the arm, and one attached at belly). All the sensors recordedX, Y, and Z values while the participant was doing the exercise. A triaxial accelerometer estimates the acceleration along X, Y, and Z axis and gyroscope (Pitch, Yaw, and Roll) helps the accelerometer to predict the orientation of the sensor. Three smartphones were synchronized to get the time from the server. The time was recorded up to millisecond along with X, Y, and Z values. This resulted in the 15 X, Y, and Z values along with a timestamp, the category of the exercise, and the exercise name. The dataset available from the literature [17, 44, 45] was not used because of the nonavailability of the data of 14 unique exercises. We also decided to collect data for the exercises whose data was available because of the probable setup differences between the existing studies and this study. This may have help in countering the bias and variations.


## 4.1.4. Data Preparation

The recognition process includes a collection of exercises data using multiple sensors. The data is preprocessed and segmented and the features are extracted and classified as the last step [11, 46]. The same process is followed in this research as well.Three different files containing exercise data from each smartphone were combined carefully to match the participant's assigned ids and time stamps. In the second step, the recorded data from CSV files were preprocessed to remove the extra noise. For example, at the start and the end of an exercise, the participant's movements were very random as well as jerky and were not aligned with the required exercise. Therefore, to remove this noise we removed the data from the first 3 seconds and the last 3 seconds of the recorded data of each exercise. For each exercise, there were 2 sets, each set of 10 repetitions and with an average participant time consumption for an exercise of 38 seconds. After preprocessing, we considered the data of 32 seconds only. The application was programmed to record 4 samples in a minute.Various previous studies such as [11] used a 4-second window to extract required features and 1 minute of the slide to vary the data. We adopted the same strategy. The features extracted were based on the most used features (mean, standard deviation, and minimum and maximum) for the similar nature of the data as presented in Table 3. For each of the X, Y, and Z values, these four features were extracted forming a total of 60 features (36 accelerometer features and 24 gyroscope features).To analyze the preprocessed data, we used WEKA (Waikato Environment for Knowledge Analysis) [47]. The preprocessed data (extracted features) were converted to ARFF (Attribute-Relation File Format). The listed attributes were named as per the following strategy. In the name of the attribute, the first position character ‘a’ stands for an arm, ‘b’ stands for the belly, and ‘l’ stands for the leg. The second position character ‘a’ or ‘g’ stands for accelerometer or gyroscope. The third position character ‘x’, ‘y’, or ‘z’ stands for axis values X, Y, and Z. The selected classifiers NB, KNN, and J48 as per Table 3 were utilized with default configuration settings. In the test options, the percentage split with 80% training and 20% testing option was selected as used also by [38, 48] to evaluate the performance and accuracy of the classifiers.


## 5. Analysis and Results

The existing research mostly used three classifiers, namely, NB, KNN, and J48 (cf. Table3) and hence they were also utilized in this research. All of the above-mentioned algorithms can create multiform class boundaries and, therefore, are suitable for the data collected via sensors and devices [10]. Furthermore, for practical applications, these methods are fast and are easily implementable [10].We examined the values of both the sensors (accelerometer and gyroscope) with the above-mentioned classifiers at three different body positions (arm, belly, and leg). The analysis was done in five ways: firstly, the analysis of the exercises considering the data from three sensors of the same nature, that is, accelerometer (rows 1, 2, and 3 of Table6) attached at three positions (arm, leg, and belly). As there were only two gyro sensors at arm and leg positions, data from the positions are analyzed and presented as per rows 4 and 5 of Table 6. The same process is continued for the combination of three, four, and five sensors as illustrated in Table 6.Table 6
Table of classification results.
S numberSensor nameSmartphone positionsNaïve Bayes classification accuracy in percentage (%)K-NN classification accuracy in percentage (%)Decision tree (J-48) classification accuracy in percentage (%)Sensors features (mean, std. deviation, min, and max) A (x, y, z) G (x, y, z)Single sensor used1AccelerometerArm52.6195.8787.73122Belly40.9995.1686.29123Leg47.5996.3991.58124GyroscopeArm31.9391.8380.23125Leg23.2787.3975.0012Two sensors used6Accelerometers = 2Arm and belly69.9298.4092.96247Arm and leg74.1899.1795.31248Belly and leg63.1098.6593.85249Gyroscopes = 2Arm and leg42.5296.2986.402410Accelerometer + gyroscopeArm62.49%98.0490.632411Leg47.7297.7691.4024Three sensors used12Accelerometers = 2, gyroscope = 1Arm and belly77.4299.4193.943613Accelerometer = 2, gyroscope = 1Belly and leg77.5999.0294.213614Accelerometers = 3Arm, belly, and leg79.5999.5189.036Four sensors used15Accelerometers = 2, gyroscopes = 2Arm and leg79.3299.6396.0548Five sensors used16Accelerometers = 3, gyroscopes = 2Arm, belly, and leg80.7299.7296.2960In Table6, column “sensor name” represents the name of the sensor from which the data is acquired. The number in front of the sensor name represents the count of sensors used to acquire and analyze the data. For example, S numbers 6, 7, and 8 in Table 6 display “accelerometer = 2” which is an indication that two accelerometers attached at the body positions (displayed in the next column) were used to analyze the data. The results of the input data from the chosen three classifiers are presented in the classifier names columns in the form of accuracy. The last column represents the number of features used in the analysis. A single sensor used at body position will have 12 features, two sensors will have 24 features, and so on.The results revealed that the best accuracy of 99.72% was achieved with the KNN classifier using five sensors at three attachment positions (arm, belly, and leg). However, as can be seen from the summary as per Table7, this is not a big variation from the accuracy of the KNN using two sensors at two attachment positions. A minimum of two sensors used at the arm and leg position provided an accuracy of 99.27% which is equatable to five sensor positions.Table 7
Table for best accuracy with the number of sensors used.
Sensors usedSmartphone positionClassifier usedMaximum accuracy achieved (%)VarianceSingle sensor usedLegKNN96.39——Two sensors usedArm and legKNN99.272.88%Three sensors usedArm, belly, and legKNN99.510.23%Four sensors usedArm and legKNN99.630.12%Five sensors usedArm, belly, and legKNN99.720.14%For each (exercise) activity, the accuracies achieved using the KNN classifier with both the accelerometer and gyroscope are a little better than using only the accelerometer. The accuracy results and their difference are shown in Table8.Table 8
Comparison table for KNN classification results at three body positions (exercisewise) of the only accelerometer and both accelerometer and gyroscope sensors.
Exercise groupExercise nameThree accelerometers’ accuracy (%)Three accelerometers + two gyroscopes’ accuracy (%)Difference (%)Avg. time (in sec) consumed at exercise, 2 sets each of 10 repsUnique exercises groupFace pull1001000.026.8Cable front raise1001000.038.5Scott curl98.499.2+0.633.2Smith machine drag curl95.6100+4.430.9Triceps with bar98.199.0+0.926.8Decline close grip bench press1001000.026.3Standing cable cross1001000.028.7Wide grip pull up99.599.7+0.223.8T bar rows1001000.024.2Chin ups1001000.023.7Adjustable sit-up bench1001000.037.9Abs wheel1001000.046.5Roman chairs1001000.037.8Flutter kick1001000.028.7Common exercises groupSeated barbell shoulder press10097.4−2.627.1Incline press wide grip99.1100+0.926.6Standing barbell press97.099.1+2.927.4Inclined dumbbell curl1001000.037.2Barbell preacher curl99.399.30.034.4Triceps press with cable98.999.0+0.129.2Machine bench press1001000.025.2Leg press1001000.041.3Romanian deadlift1001000.037.2Barbell squat1001000.030.2Dips1001000.025.3Butterfly99.5100+0.541.0Both groupsAll exercises average accuracy99.5199.72+0.2131.4The classification confusion matrix in Figure4 shows that the highest accuracy is achieved using data from all the sensors of the smartphones and with a KNN classifier. Examining the confusion matrix, the results show that most of the classes (exercises) are accurately being predicted. However, a couple of classes (exercises) were not differentiable because of the similarity in the exercise position and nature. For example, the Triceps group (triceps press with cable and triceps press with bar) are having similar motion patterns. However, we still can differentiate between them based on the execution time differences as per Table 8. The table shows that triceps press with bar takes 26.8 seconds for 20 repetitions while triceps with cable take 29.2 seconds for the same 20 repetitions thus having a difference of 2.4 seconds.Figure 4
Confusion matrix of KNN classification using all smartphones and sensors.


## 6. Conclusion and Future Work

The goal of this study was to predict gym exercises with the help of smartphone sensors in real-world settings. To achieve the goal, exercises from the literature were extracted for which prediction research work was conducted and was intersected with a set of the most used exercises in the gym. The result was 14 unique exercises for this study. Besides, 12 common exercises were also considered for comparison purposes. Furthermore, finding the sensors suitable attachment positions, as well as the number of sensors to utilize in predicting the exercise accurately, was also one of the goals of this research. Also, we conducted the exercises with the greatest number of participants (20) as compared to the existing literature (avg. max. 10). The results indicated three key lessons derived from this study while examining the goals. (a) The most suitable classifier to predict a class from the sensor-based data was found to be KNN. (b) The sensors placed at three positions (arm, belly, and leg) could provide better accuracy than other positions when the gym exercises are under the question and (c) smartphone sensors accelerometer and gyroscope in combination can provide accurate classification (using KNN as classifier at all 3 positions) in most of the activities averaging up to 99.72% accuracy. Their combination can increase accuracy by up to 0.21%.The research can be implemented in the form of a smartphone application that can be turned on by the users while doing exercises in the gym. In the future, this application can be embedded with a calorie burn out tracker that should be able to guide gym-goers to do which exercise and for how much time? The output could be in the form of sound notifications as well as sound messages that could advise to change or stop the exercise.The research has some limitations as well. In this research, only 14 unique exercises are considered taking the considered exercises in the literature to 55 exercises. In this context, of the total of 74 exercises as per sources [41, 42], nineteen (19) gym exercises still remain to be predicted though not most often used. The future research work can consider these exercises as well. In addition, in this research, no female participants were involved thus having a probability of nonapplicability of this research for the female participants. The future research could also hire female participants to increase further accuracy.



---

*Source: 6471438-2020-07-22.xml*