# XBeats: A Real-Time Electrocardiogram Monitoring and Analysis System
## 5 Experimental Results and Discussions
### Signal Detection and Classification  
The signal detection and classification represent one of the novel integrations of this work as it enables the dynamic configurations of operation modes in real-time. Moreover, it provides an additional safeguard to the ECG monitoring platform as we bring the classification closer to the patient. This feature is considered the first step of a two-phase ECG data classification of the ECG monitoring platform. The binary classification module provides a faster response by classifying the ECG data to normal heartbeat or irregular heartbeats. The second phase includes deep analytics functions deployed at the backend level, where we perform and build a correlation between real-time and historical data for better analysis and predictions. To that extent, we use the real-time ECG dataset acquired from the simulator using the proposed ECG patch to evaluate the performance of our classification algorithm. In contrast, we use the PTB-XL datasets for training the proposed classification module. The dataset is split into training and testing sets at an 80% to 20% ratio. To select the best classifier for our application, we compare six different algorithms, namely, random forest (RF), support vector machine (SVM), K-nearest neighbors (KNN), Decision tree (DT), logistic regression (LR), and Extra Trees Classifier, which is the ensemble learning method of the decision trees method as recommended by [39]. The main objective of our model is to achieve the best accuracy with the minimum processing time to fit the constraints of our hardware system. We calculate the F1-score (F1), Precision, Recall, overall accuracy, and the processing time to fit the trained model of each classification technique. The training set performance is calculated using a K-fold cross-validation splitting strategy with 10 folds. The results are collected using only 5 features from the top 5 to minimize our processing time, as shown in Table 5. We used  
Figure 6: A Sample of the streamed ECG data over BLE in real-time using the ECG patch: (**a**) Chest leads; (**b**) Limb leads; (**c**) Chest leads with noise and outliers; and (**d**) One ECG lead with outliers. Python and Scikit-learn for implementation. The results in Table 6 compare the 6 algorithms from the accuracy and time perspectives. We observe that the Extra Trees Classifier achieves the best combination of accuracy and time with the highest accuracy of 95.3% and only 5.78 s to classify the ECG signal. Logistic regression performs the best processing time with 0.857 s but with an accuracy of 93.6%, which is considered the lowest accuracy out of all classifiers. Worth noting, the processing time in Table 6 represents the overall processing time of the corresponding algorithm over the selected dataset. The following experiment evaluates the actual time when implementing the best algorithm in real-time on an edge device. Table 7 shows the performance details obtained from the test dataset for the normal signals (N) and abnormal signals (ABN). We observe that almost all the best values result from the Extra Trees classifier, which concludes that it's the best model to adopt in our system. Furthermore, we investigate the accuracy of the Extra Trees classifier with the number of features, as shown in Figure 7a. It can be observed that the highest performance is accomplished with only 5 features (accuracy = 95.30%), and after that, the accuracy decreases with the growth of the number of features.