An Intelligent Cost-Efficient System to Prevent the Improper Posture Hazards in Offices Using Machine Learning Algorithms

In this research, an intelligent and cost-efficient system has been proposed to detect the improper sitting posture of a person working at a desk, mostly in offices, using machine learning classification techniques. The current era demands to avoid the harms of an improper posture as it, when prolonged, is very painful and can be fatal sometimes. This study also includes a comparison of two arrangements. Arrangement 01 includes six force-sensitive resistor (FSR) sensors alone, and it is less expensive. Arrangement 02 consists of two FSR sensors and one ultrasonic sensor embedded in the back seat of a chair. The K-nearest neighbor (KNN), Naive Bayes, logistic regression, and random forest algorithms are used to augment the gain and enhanced accuracy for posture detection. The improper postures recognized in this study are backward-leaning, forward-leaning, left-leaning, and right-leaning. The presented results validate the proposed system as the accuracy of 99.8% is achieved using a smaller number of sensors that make the proposed prototype cost-efficient with improved accuracy and lower execution time. The proposed model is of a dire need for employees working in offices or even at the residential level to make it convenient to work for hours without having severe effects of improper posture and prolonged sitting.


Introduction and Literature Review
e economic growth of any country around the globe is directly linked to the number of employees working in offices as it increases GDP, however, working nonstop sitting on office chairs can cause actual harm to mental and physical health. According to a survey, 60% of Americans experience real health problems because of the use of technology during the day, including insomnia, eye strain, headache, and more, out of which 30 percent have severe back pain and 27 percent have neck pain because of prolonged sitting in an improper posture [1]. Moreover, if a person sits on a chair in the wrong posture for a long time, it can cause more severe and painful diseases, such as pressure ulcers, back pain, spinal dysfunction, joint degeneration, rounded shoulders, and a potbelly. e wrong posture causes an increase in pressure, friction, and shear on the chair, and rubbing the chair with the skin for a long time can tear the skin apart, resulting in severe pressure ulcers, leading to death.
In general, the office timings are eight hours, and people also work overtime or work longer than that without noticing their improper sitting patterns. For example, sitting eight hours on a chair with no physical activity can increase pressure at specific points in the body. e continuous rubbing of the skin on the chair surfaces results in pressure ulcers and other joint pains. Moreover, if the table height and distance from the table to a chair are not correct, the person has to bend toward his laptop, making a curve in his spine. ese body curves can cause many hazards, such as back pain. Such improper postures, when taken for a prolonged period, can cause severe damage to health, and they must be prevented.
A good working environment is crucial in helping employees put their best foot forward. Sit-stand working stations provide a good environment and reduce discomfort. Studies conclude that sit-stand working stations reduce perceived discomfort and increase productivity [2]. Sitting on the chair in an awkward posture or in one posture for a long time will cause harmful diseases, including pressure ulcers. e severe impacts of improper posture increased the importance of pressure recognition systems. ere are many methods and techniques to detect the wrong posture to prevent getting improper posture and severe effects. One of the highest accuracy techniques to detect posture is FSR sensors and machine learning. Scientists and researchers have done much research on detecting posture accurately, mainly for wheelchair users. In addition to the traditional algorithms of the Naive Bayes classifier (NB), decision tree (DT), neural network (NN), multinomial logistic regression (MLR), and support vector machine, a system was developed to classify the sitting postures using different machine learning algorithms, such as the convolutional neural network (CNN) algorithm (SVM). A sensing cushion was created by installing a pressure sensor mat (8 8) within the children's chair seat cushion [3]. A pressure mapping device was used to measure the pressure in the right, one-sided prone, chin supported, and slumped sitting positions [4].
e WDI (XAP) found a statistically significant difference between the three incorrect sitting postures (one side prone, chin propped, and slumped sitting) and the correct sitting posture (one side prone, chin propped, and slumped sitting) [5]. An embedded device was utilized to acquire positionrelated information using a machine learning method termed dimensionality reduction (DR) and classification. e system includes a DR step based on the principal component analysis (PCA) [6]. For pose detection between the matrix stored (in the system) and new data obtained by pressure and distance sensors, K-nearest neighbours (KNN) classifiers are used [7][8][9][10][11][12][13]. Noninvasive optical fiber sensor architecture can be fitted to the bottom of a shoe for remote plantar pressure monitoring, which might be utilized in an IoT e-Health system to track people's health. e study looks at creating an optical fiber sensor multiplexed network (using fiber bragg gratings) to measure the distribution of foot plantar pressure during locomotion (walking) [8].
Picture data from the posture was captured using a film-type pressure sensor. e study enlisted the participation of twenty-six children, who were photographed in seven distinct poses. e authors employed a seven-layer convolutional neural networks (CNN) technique. In addition, the artificial neural networks (ANN) approach, one of the machine learning techniques, was utilized to compare classification accuracy [14][15][16][17][18][19][20]. e system (FPGA) is made of six flex sensors, an ADC board, and a machine learning algorithm based on a two-layer artificial neural network (ANN) developed on a Spartan-6 field programmable gate array [10].
e system achieves 97.78 percent accuracy with a floating-point evaluation and 97.43 percent accuracy with a 9-bit fixed-point implementation.
e maximum propagation delay for the ANN and ADC control logic is 8.714 ns [11]. Ahmad et al. employed the J48 algorithm to identify the five types of sitting postures using the pressure readings of twelve pressure sensors as features, achieving 99.47 percent experimental classification accuracy [12]. A center of pressure, contact area proportion, and pressure ratios are used in another article to identify five common trunk postures, two common left foot postures, and three common right foot postures. Lower-resolution mapping characteristics were compared to high-resolution sensor pressure mats on the backrest and seat pan features [21][22][23][24][25][26]. To recognize the postures of each body component, five distinct supervised machine-learning approaches are used [13]. Using a specific hardware system that interprets video in real-time using convolutional neural networks, a system based on the worker's postural detection is created, constructed, and tested.
is device can identify the worker's neck, shoulders, and arms position and provide advice to help them avoid health problems caused by bad posture [12]. Many additional efforts, such as clinical implication assessment for diabetes mellitus [27], are built on machine learning techniques. ere are also a slew of additional classification-based efforts to resolve health difficulties [28]. An intelligent way to forecast the accuracy of a model is to use an artificial neural network [29]. Multiple approaches are used in previous studies for the detection of posture, however, in this work, the cost is considered the main factor, and the higher accuracy of the system is achieved. Moreover, the proposed system is portable and multiple configurations of sensors are tested in this system [30]. Table 1 shows a comparison of prior research literature reviews. A system is designed to measure the variation in FSR sensor data on a chair according to the changing of the body sitting positions and the collection of that data.
(i) Two arrangements have been used in this study to find the cost-efficient and higher accuracy arrangement of sensors according to the weight distribution of a sitting person on a chair (ii) Different machine learning techniques are used to clean the dataset to make it more efficient and useful (iii) Four machine learning algorithms are applied to detect the posture of a sitting person e paper is divided into the following sections: designed system, materials and methods, hardware, software, configurations and specifications, data processing, results and discussion, conclusion, and future work.

Designed System
e sensors are connected to Arduino, and then the dataset is generated through serial communication, as shown in Figure 1. e data is stored in an excel file. In this way, data is stored, and then four different machine learning algorithms are applied to this data. is system supports mainly the table working in offices or at home. While working on laptops or computers in an office or at home, posture can easily be detected, and a warning of improper posture will be given on the laptop when that posture is taken for a prolonged period of time. e FSR sensors are very thin and small that they cannot be noticed, or no one can be annoyed or disturbed by these sensors. Hence, it is an easy and efficient system to detect a person's posture when working on a table. It is a regular practice that people bend over to focus on the screen, and it can impact their health badly and have severe health hazards. us, this system makes posture detection more straightforward and efficient.

Materials and Methods
e process of posture detection can be done in various ways and methods, one of which is the approach discussed in this paper, which is the analysis and computation of pressure distribution data on a chair. In this approach, the force resistive sensors FSR are placed in a meaningful manner on a standard ordinary office chair, and when a person sits on it, the pressure distribution on the chair is measured by the sensors, and the posture is predicted using machine learning algorithms. In this paper, four machine learning algorithms are applied, including logistic regression, KNN, random forest, and Naïve Bayes, to predict the four improper sitting patterns, such as bending forward, bending backward, bending left, and bending right, as in Figure 2.

System.
is study uses FSR (force-sensitive resistor) sensors that exhibit varying degrees of resistance to force directly proportional to the pressure exerted on them. Firstly, the FSR sensors are used to measure the pressure difference according to weight distribution on a chair. en, this data is refined into a functional form to apply machine learning algorithms for the prediction or detection of the posture. e embedded system consists of two main parts, such as hardware and software.

Hardware.
e weight distribution is evenly or unevenly divided on a chair when a person sits on it according to its sitting position. Hence, the pressure distribution on a chair is linked to a person's body mass and weight. erefore, for the better capturing of pressure sensor data, the placement of FSR sensors must be meaningful. In this paper, two sensor placements are discussed to study the change in accuracy by changing the sensor arrangement. e two arrangements of sensors are as follows: (1) Arrangement 01. In this arrangement, six FSR sensors are placed to cover the main pressure points of the human body, such as under the thighs, hip joints, and sides, as shown in Figure 3. When a person leans to the right, the right sensors have a higher-pressure value than the left ones and vice versa. In this way, the wrong posture is detected through the pressure distribution technique. e sensors work in a pair as the front two sensors are mainly used to detect the forward-leaning, and backward leaning is also detected by two sensors. When the pressure on the front two sensors increases, the person is sitting, leaning forward, and it is similar to backward leaning. Similarly, the left and right sensors are used to detect a person's left-and right-leaning positions. e chair used in this research is 16 × 16 inches in size, and the vertical distance between the forward and backward pair of sensors is 5 inches, while the left-right sensors are embedded at edges, with a distance of 10 inches.
e FSR sensor used in this study is approximately 1 inch long.
e need for a second arrangement arises because of the higher cost of FSR sensors. In this approach, an ultrasonic sensor is used instead of FSR sensors for backward or forward-leaning detection.  e optimal range for ideal posture is set on an ultrasonic sensor, and when the range exceeds, the forwardleaning posture is detected, and when the distance between the ultrasonic sensor and the person reduces to zero, it is predicted as a backward leaning position. Arduino mega is used for arrangement 01 because of the more significant number of FSR sensors, and Arduino UNO is used for arrangement 02 because of the smaller number of FSR inputs. For this reason, arrangement 02 is considered costefficient. Moreover, FSR sensors are reduced to more than half in arrangement 02. Figure 4 shows two FSR and one Ultrasonic sensor deployed in arrangement 2. A laptop processor is used for machine learning algorithms and Arduino serial communication. Table 2 shows hardware and specifications used for the proposed system. e cost comparison of arrangement 01 and arrangement 02 is given in Table 3.

Software.
e sensor data is sent to Arduino IDE via serial communication, and then Excel is used for storing the collected data.
e Google collab notebook is used for machine learning algorithms in this paper. e collab runs the code on local hardware. us, execution time may vary from system to system.

Data Acquisition.
e data is collected at COMSATS UNIVERSITY Islamabad, Lahore campus, and students of different weights, heights, and body mass contributed to this study. e teachers and staff also contributed to dataset generation. Hence, the age ranges from 20 to 45 years. e number of samples collected is 635 different persons, and among them, 155 samples are forward-leaning, 145 are backward-leaning, 160 are right-leaning, and 175 are leftleaning, as shown in Figure 5(a). e BMI range of collected sample data varies from 16 to 35.

Data Preprocessing.
Data preprocessing is an efficient technique to make raw data valuable and significant. Data preprocessing techniques refine the dataset into a functional form in this study. e repeated, corrupted, and null entries are eliminated from the dataset. Decreasing the irrelevant   column is a significant step in removing the data and time columns from the dataset. Moreover, outliers that lead to the wrong prediction are removed. Another major step in data preprocessing is extracting null rows and columns and then removing them and placing them by their primary values. e smote analysis also removes the values where repetition exists to make the dataset more significant.

Data Processing.
After the preprocessing of data, four machine learning algorithms are applied to detect the posture, and their accuracy and execution time are compared. Logistic regression predicts the output, which is present in categorical form. It can be either Yes or No, 0 or 1, true or False, etc., and it gives a value between 0 and 1. When applying logistic regression, the output is in categorical form. Logistic regression gives a value between 0 and 1, and it cannot go above this limit, forming an S-like curve. e S-form curve is called the Sigmoid function or the logistic function [32]. e probability of a record belonging to the positive class given feature prediction by the logistic regression (9).
(1) e other algorithm used in this study is KNN. Using KNN, the quick identification of the category or class is achieved [33]. e working of the KNN algorithm is as follows: (i) Selecting the number K of the neighbors (ii) Euclidean distance of K number of neighbors is calculated (iii) e K nearest neighbors from the calculated Euclidean distance

Hardware Specification
Arduino mega Arduino mega is a microcontroller kit for building digital devices based on the ATmega 2560. It has 54 digital input/output pins Laptop A laptop used for data collection and processing has the following specifications: intel core i5, 6 th generation, G3 2.40 GHz processor, and 8 GB ram Force-sensitive resistance A force-sensitive resistor (FSR) is a material that changes its resistance, when a force or pressure is applied, the output voltage varies from 0 to 5 V, depending on the amount of force applied to the sensor Sonar sensor Sonar sensors use ultrasonic sound waves to detect objects and distance. It sends an ultrasonic pulse out at 40 kHz, which travels through the air, and if there is an obstacle or object, it will bounce back to the sensor e working diagram of the random forest is as shown in a flow diagram in Figure 5(b).
Another algorithm used in this study is Naïve Bayes. In the naïve Bayes algorithm, the occurrence of a certain feature is independent of the occurrence of other features [34]. e working of the naïve Bayes algorithm is as follows: (1) Converting the given dataset into frequency tables (2) Likelihood table generation by finding the probabilities of given features (3) For calculating the posterior probability using the Bayes theorem e highest accuracy provider algorithm is random forest. Both big and small data can be handled using random forest. e random forest is a combination of multiple decision tree algorithms [35]. Figure 6 illustrates a complete overview, including working and back-end environment of the proposed system.
KNN is a lazy learner that stores data at the time of classification, however, the advantage of using KNN is that it is straightforward to implement. e logistic regression classification algorithm gives about 86.78% precision and an accuracy of 83.34%, just in a training time of 0.029 s. Logistic regression produces accurate results using binary classification tasks, while the proposed system consists of multiclass classification. Random forest contains several decision trees consisting of various subsets in the given dataset. It takes an average to improve the predictive accuracy of that dataset. As the number of trees increases in the forest, it leads to higher accuracy and prevents the problem of overfitting. Random forest generates a predicting precision of 97.3%, an accuracy of 97.08%, and the training time for data is just 0.662 s. Naïve Bayes generates the predicting precision of 82.22%, the accuracy of 77.38%, and the training time for data is just 1.5 s. It is a probabilistic classifier, which means it predicts based on the probability of an object. e examples of the Naïve Bayes algorithm are spam filtration, sentimental analysis, and classifying articles. Arrangement 01 results and comparison of different algorithms is given in Table 4.

Results and Discussion
Machine learning algorithms are used in this research to predict four improper sitting postures. Two different arrangements are used to study the accuracy and cost-efficient system.
is designed system has evaluated classification algorithms, including logistic regression, Naive Bayes, KNN, and random forest. Classifiers used in this system are judged based on their performance parameters, including precision, accuracy, and training time.

Results of Arrangement 01.
For this arrangement, the KNN (k-nearest neighbor) algorithm predicting precision is 89.8%, accuracy is 93.97%, and execution time is about 0.552 s. KNN is a nonparametric algorithm. It never makes any assumption on underlying data. Figure 7 shows the plots of random forest algorithm for arrangement 01.      Figure 8 and Table 2 show the plots of random forest algorithm for arrangement 02 and comparison, respectively. (Table 5)

Conclusion and Future Work
In this era of technology, everything and every solution is just a click away on technical gadgets and computers. Nevertheless, this technology stuff somewhere has a significant impact on the overall health factors of the human body. is study presents a solution to the improper sitting habits of any person who works a lot sitting at a desk. In this study, FSR sensors and an ultrasonic sensor are used to detect the sitting posture of a human body. Four machine learning algorithms are applied to the dataset generated on four different improper sitting postures: forward-leaning, backward-leaning, left-leaning, and right-leaning. e accuracy of 99.998% is achieved using the Random forest machine learning algorithm when applied to arrangement 02 data set: two FSR sensors and one ultrasonic sensor. e system can be used in offices and at home during desk work to prevent improper posture hazards and maintain fitness. is paper's vital scientific contributions are as follows: (1) compared to flex and textile sensor systems, the proposed technique reduces the number of sensors and processing complexity, resulting in lower hardware overhead. is energy-efficient and trustworthy continuous sitting position detection system will play a more critical role in reducing musculoskeletal disorders and protecting users' dignity. (2) e proposed solution does not have a drift problem, and hence, repetitive calibrations may be avoided. As a result, it is more dependable and power-efficient than the accelerometer-based system, resulting in a longer battery life. (3) e proposed approach provides a more private user experience than the camera-based system. For future work, the communication can be done wirelessly to send the sitting posture history to health professionals and analyze in a better/faster way to understand the medical history. Furthermore, the real-time posture detection on a smartphone can be done as it is easy to access and efficient to detect the posture while a person sits anywhere rather than specifically on an office chair or work desk.

Data Availability
No data were used to support this study.