Advance Sustainable Science. Engineering and Technology (ASSET) Vol. No. January 2024, pp. 02401015-01 02401015-08 ISSN: 2715-4211 DOI: https://doi. org/10. 26877/asset. Comparison of Gradient Boosting and Random Forest Models in the Detection System of Rakaat during Prayer Raihan Aris Darmawan*. Erwin Yudi Hidayat Faculty of Computer Science. Universitas Dian Nuswantoro. Jl. Imam Bonjol No. Pendrikan Kidul. Kec. Semarang Tengah. Kota Semarang, 50131. Central Java. Indonesia *111202012770@mhs. Abstract. Errors in the execution of prayer among Muslims can occur due to a lack of profound understanding of the prayer procedure. This research aims to compare two machine learning models. Random Forest and Gradient Boosting, in classifying prayer movements, subsequently extending to calculate the number of prayer cycles . A total of 7220 manually gathered data based on 33 landmark coordinates using Mediapipe Pose Detection were employed. The research findings reveal that the Random Forest model with a 70:30 ratio achieves 99. accuracy, precision, and recall, with the fastest training time being 3. 8 seconds. Both models exhibit testing results close to 100%, but the Gradient Boosting model faces challenges in classifying specific movements. On the other hand. Random Forest successfully overcomes these challenges, enabling accurate prayer cycle calculations. The findings can contribute to the development of tools supporting Muslims in correct prayer execution, positively impacting religious and well-being aspects. Keywords: Classification. Machine Learning. Mediapipe. Random Forest. Gradient Boosting (Received 2023-12-20. Accepted 2023-12-27. Available Online by 2024-01-. Introduction Prayer is one of the pillars of Islam that plays a crucial role for Muslims . Although prayer has clear procedures and pillars, common mistakes often occur during its execution. These mistakes can happen due to a lack of deep understanding, negligence, or misunderstanding of the correct procedures for prayer. One example of a mistake in prayer is an excess or deficiency in the number of prayer cycles . This lack of understanding can have a negative impact on the quality of a person's prayer performance, as prayer plays a crucial role as one of the pillars of Islam. Therefore, the development of this prayer movement detection system is essential to improve the quality of prayer execution, serve as an educational tool, and contribute to future technological advancements. In recent years, the field of artificial intelligence (AI) has experienced tremendous advancements . Opening up new potential for innovation and solutions across various sectors of human life, the field of AI has witnessed remarkable progress in recent years. One of the most prominent aspects of AI advancement is the utilization of machine learning (ML), which serves as the backbone for processing vast amounts of data and involves systems learning from the provided data. By employing ML, computers can perform pattern recognition, make predictions, and make decisions. Therefore, the application of ML is highly relevant for use in classification, where systems can learn to categorize data into specific categories or classes. By integrating ML with Computer Vision (CV), computers can understand, analyze, and interpret visual data from the real world. With this capability, it becomes possible to perform human body detection. One way to implement pose detection is by utilizing the framework provided by MediaPipe. By using the framework provided by MediaPipe, it allows for the implementation of pose detection without the need for programming from scratch. Thus, integrating ML with CV and leveraging frameworks like MediaPipe provides an effective and efficient solution for automatically detecting and analyzing human body poses. There are several algorithms suitable for classification, and some examples include Gradient Boosting . and Random Forest . Gradient Boosting, with its incremental learning approach . , capable of building a highly adaptive and accurate model by focusing on correcting the prediction errors of the previous model . Its main strength lies in its ability to handle complex and irregular data, as well as its robustness in dealing with overfitting. Meanwhile. Random Forest stands out due to its ensemble nature, harnessing the power of multiple Decision Trees. By building a large number of trees independently and combining their prediction results . Random Forest can provide stable predictions and avoid overfitting, which is commonly observed in a single Decision Tree . To evaluate the trained model, a Confusion Matrix can be used . The use of model evaluation using a confusion matrix reflects the importance of understanding the performance of a classification model. In the context of machine learning model development, especially in classification tasks, accurate and informative evaluation is key to measuring how well a model can classify data The confusion matrix is an evaluation tool that provides in-depth insights into the model's It depicts the classification results of the model by dividing predictions into four matrices. With the confusion matrix, various evaluation metrics such as accuracy, precision, and recall can be calculated . , provides a more comprehensive understanding of the model's performance. The main objective of this research is to develop a prayer posture detection system using AI and CV technology. This system is designed to recognize movements and body positions during prayer with the primary goal of improving accuracy and precision in determining the number of prayer cycles . The system is expected to contribute positively to enhancing the implementation of prayers for Muslims. Methods Data Acquisition Figure 1. Sequence of Data Acquisition In this Data Acquisition process, the dataset to be used is manually created with the assistance of Mediapipe Pose Detection. Based on Figure 1, the initial stage involves ensuring that the detection using Mediapipe Pose Detection can work optimally and accurately detect the body parts of the object. Following this, columns are created for the Class of each prayer movement and the Coordinates of each The Class of prayer movements consists of Takbiratul Ihram. Bersedekap. Rukuk. Rukuk (Hadap Depa. Itidal. Sujud. Duduk Iftirosy. Duduk Ifirasy (Hadap Depa. Duduk Tawaruk. Duduk Tawaruk (Hadap Depa. Salam. As for the coordinate columns, since Mediapipe Pose Detection has a total of 33 Landmarks as shown in Figure 2, and each Landmark has 4 variables within it, namely x, y, z, and v . Therefore, in the coordinate column, there are a total of 132 columns starting from x1, y1, z1, v1 up to x33, y33, z33, v33. Figure 2. Mediapipe Pose Detection Landmarks After creating the class and coordinate columns in the CSV file, the next step is to determine which movement or class's coordinates will be captured in real-time. Then, capture the video of that movement in real-time. Automatically. Mediapipe Pose Detection will generate values for each landmark coordinate. These values are then exported to the previously created CSV file. This process is repeated, from determining the movement to exporting landmark values for each prayer movement or Modeling At this stage, experiments are conducted on the separation of training and testing data with several ratios, 70:30, 80:20, and 90:10. This separation is done to determine at which ratio the model can achieve its best performance. The main reason for using Random Forest and Gradient Boosting models is that both are Ensemble learning techniques capable of overcoming overfitting and handling complex data. Gradient Boosting works in a unique way to iteratively build a strong model. The process starts with the creation of a basic model, often a weak Decision Tree. The first model provides initial predictions, and subsequently, each iteration focuses on minimizing the loss function as indicated in formula . At each step, a new model is added by assigning weights to their prediction results. This creates a series of models that are increasingly complex and adaptive, capable of capturing finer and more intricate structures in the data. Oeycoycuyci ya1 = Oe OcycA ycn=1. cycn log. yce Random Forest employs an ensemble learning approach by constructing a large number of Decision Trees independently. In each tree, a small portion of the data and a random subset of features are used to avoid high correlation among the trees. The prediction results from each tree are combined through voting or averaging to create a stable prediction. By leveraging the strength of many trees operating independently. Random Forest demonstrates resilience to overfitting and can handle various types of data. The determination of the root node can use metrics like Entropy and Information Gain or Gini Index and Gini Split. Random Forest begins by specifying the number of decision trees to be created. performs bagging by sampling from features and rows, creating multiple decision trees. Afterward, formulas for Entropy and Information Gain or Gini Index . and Gini Split . are applied to build the tree and determine the majority prediction. ya yaycnycuycn. cI) = 1 Oe Ocycn=1. cEycn )2 . ycu yaycnycuycnycycyycoycnyc = Oc . cIycn | y yaycnycuycn( ycIycn ) ycn=1 . cI| . Evaluation Confusion Matrix is a crucial evaluation tool in measuring the performance of a classification model by providing a detailed overview of prediction outcomes. By breaking down predictions into four main groups, namely True Positive (TP). True Negative (TN). False Positive (FP), and False Negative (FN), the Confusion Matrix helps identify how well the model can correctly classify instances. The representation of the matrix with these four cells forms the basis for calculating several highly informative evaluation metrics. Accuracy, shown in formula 4, provides the percentage of total instances correctly classified by the model. Although accuracy gives a general picture of performance, it does not accommodate class imbalances that may exist in the dataset. Precision, shown in formula 5, evaluates how well the model can accurately identify the positive class. Precision is particularly useful when the focus is on reducing false positives to avoid undesired identification errors. Recall (Sensitivity or True Positive Rat. , shown in formula 6, measures how well the model can detect all positive instances that should be detected. Recall focuses on reducing false negatives and is useful in situations where false positives are more TP TN yaycaycaycycycaycayc = TP FP FN TN ycEycyceycaycnycycnycuycu = TP x 100% FP TP TP x 100% ycIyceycaycaycoyco = FN TP Results and Discussion Data Acquisition Data used in this research was obtained by recording each prayer movement based on the source from the Ministry of Religious Affairs of West Java, downloaded on October 1, 2023. During the data collection using Mediapipe Pose Detection, there were several conditions, including: Distance between the object and the camera is approximately 2. 5 meters. Only one type of object is used. The camera is positioned below, facing the front part of the object in the classes Takbiratul Ihram. Bersedekap. Rukuk (Hadap Depa. Itidal. Sujud. Duduk Ifirasy (Hadap Depa. Duduk Tawaruk (Hadap Depa. Salam. The camera is positioned below, facing the left side of the object in the class Rukuk. The camera is positioned below, facing the back part of the object in the classes Duduk Ifirasy and Duduk Tawaruk. Adequate room lighting, and the background remains constant. Real-time video capture is performed for approximately 2 minutes for each movement or class. The variation in video capture positions is due to certain movements being more effective for analysis from the front, side, and back, as suggested by Dr. ZAENUDIN. Ag. The data obtained for each class is approximately 656 rows, and the total data obtained overall is 7220 rows, comprising 11 The results of the data can be seen in Table 1. Table 1. Dataset Result Class Total Takbiratul Ihram Bersedekap Rukuk Rukuk (Hadap Depa. Itidal Sujud Duduk Iftirasy Duduk Iftirasy (Hadap Depa. Duduk Tawaruk Duduk Tawaruk(Hadap Depa. Salam Modeling In this stage, the data previously obtained is initially separated into training data and test data . Training data is used to train the model, allowing the model to adapt its rules based on patterns and relationships in the data. On the other hand, test data is not used during training and serves as the final evaluation to measure the model's performance. Data separation ensures that the model's performance evaluation is based on data that has never been used before, providing a realistic overview of how well the model will perform in real-world situations. In this study, several ratios of data separation between training and test data are used, namely 70:30, 80:20, and 90:10. The results of the separation for these three ratios can be seen in Table 2 below. Data Separation 70:30 80:20 90:10 Table 2. Splitting Training and Testing Data Training Data Quantity Testing Data Quantity Evaluation In this study, the performance of the classification model is evaluated using the Confusion Matrix, which is a fundamental evaluation tool in classification tasks. The Confusion Matrix enables indepth analysis of the model's prediction quality by presenting information about the number of correct and incorrect classification results, allowing researchers to identify accuracy, precision, and recall Thus, the evaluation results provide comprehensive insights into the ability and reliability of the classification model in handling the data used in this study. The accuracy, precision, and recall results for the Gradient Boosting model can be seen in Table 3, while the accuracy, precision, and recall results for the Random Forest model can be seen in Table 4. Table 3. Accuracy. Precision. Recall results for the Gradient Boosting Model. Data Accuracy Precision Recall Separation 70:30 80:20 90:10 Table 4. Accuracy. Precision. Recall results for the Random Forest Model Data Accuracy Precision Recall Separation 70:30 80:20 90:10 Data Separation 70:30 80:20 90:10 Table 5. Model Training Time Gradient Boosting Random Forest However, the use of accuracy, precision, and recall does not determine whether the model can work optimally. testing is necessary. In Figure 3, testing is shown using the Gradient Boosting model with a ratio of 70:30. During testing, it was found that some movements were misclassified. This could be due to the limited diversity of the dataset and the need for parameter tuning. Figure 4 shows testing with the Random Forest model with a ratio of 70:30. In the test, almost all movements could be classified Figure 3. Gradient Boosting Model Testing Figure 4. Random Forest Model Testing Conclusion Errors during prayer execution arise from a lack of profound understanding or misunderstandings regarding the correct prayer procedure. One common example of such errors is the miscalculation of prayer cycles. With 2770 data points collected using Mediapipe Pose Detection and classified using Random Forest and Gradient Boosting models, the Random Forest model with a 70:30 ratio achieved an accuracy, precision, and recall of 99. 9%, along with the fastest training time of 3. Overall, this indicates that both models achieved testing results close to 100% in the three separation ratio comparisons, but Random Forest demonstrated faster training times compared to Gradient Boosting . On the other hand, the more the number of training data, the longer the training time for the model based on Table 5. However, during the classification testing, the Gradient Boosting model could only correctly classify a few movements, thus unable to count prayer cycles. In the Random Forest model, only one movement. Salam, proved challenging to detect, while others could be accurately classified, enabling the counting of prayer units. This can occur due to various factors such as dataset limitations, conditions during data acquisition, and the need for tuning in both models used. These factors significantly impact the models' ability to recognize and classify prayer movements accurately. Understanding factors like dataset limitations and conditions during data acquisition, as well as the need for tuning in both models, future research efforts can focus on improving model performance through dataset expansion, enhancing data quality, and adjusting model parameters. References