October 09, 2026
Application of machine learning algorithms in the classification of cardiac arrhythmias
Application of Machine Learning Algorithms in the Classification of Cardiac Arrhythmias
Lisnane Vitória de Oliveira; Lauro Marques Vicari
DOI: 10.22167/2675-6528-202603158
Article derived from a Course Conclusion Work (TCC), with content based on the student’s original work and adapted to the editorial format of the E&S Magazine with the support of the ResumeAI tool, an artificial intelligence solution developed by Instituto Pecege for textual synthesis and organization.
Summary
Cardiovascular diseases have emerged as a leading cause of global mortality, with cardiac arrhythmias presenting significant clinical impact due to alterations in the heart’s rhythm and electrical conduction. Although electrocardiography (ECG) is widely used for diagnosis, its manual interpretation has limitations of subjectivity and risk of error. In this context, the application of machine learning algorithms for the classification of cardiac arrhythmias using tabular ECG data was investigated. The Arrhythmia dataset from the UCI Machine Learning Repository, containing demographic and electrocardiographic information, was employed. The original multiclass problem was reformulated into a binary classification, distinguishing individuals with and without arrhythmia. The methodology involved preprocessing, robust scaling, feature selection based on Random Forest, and evaluation of the Logistic Regression, Random Forest, XGBoost, and Support Vector Machine (SVM) models. The models were evaluated by accuracy, precision, recall, and F1-Score. On the test set, Random Forest achieved an accuracy of 84.52%, precision of 83.33%, recall of 81.08%, F1-Score of 82.19%, and ROC-AUC of 0.8902. The results demonstrated potential for supporting the automated detection of arrhythmias, considering the limitations of using a single database and binary classification.
Keywords: Machine Learning; Cardiac arrhythmia; Binary classification; Electrocardiogram; Digital health.
1. Introduction
Cardiovascular diseases are among the leading causes of global mortality. The World Health Organization (2025) estimated that in 2022, nineteen million nine hundred thousand people lost their lives due to these conditions, representing approximately 32% of all global deaths. Of these cases, 85% were caused by heart attack and stroke.
Among the cardiovascular diseases that cause the most deaths, cardiac arrhythmia stands out, characterized by alterations in the heart’s rhythm. These manifestations can include tachycardia, bradycardia, or irregular heart rhythm, which compromise the coordination between the atria and ventricles, impacting the efficiency of cardiac pumping (Antzelevitch et al., 2011). Consequently, the body may receive insufficient blood supply, leading to symptoms such as palpitations, dizziness, shortness of breath, fainting, and, in severe situations, cardiac arrest (Kumar et al., 2024).
The diagnosis of arrhythmias is commonly performed using the electrocardiogram (ECG), an exam that records the electrical activity of the heart through electrodes placed on the patient’s chest area. Changes in the signals captured by the electrocardiogram can indicate specific cardiac conditions and the presence of cardiovascular diseases, making the processing of these signals crucial for the diagnosis of cardiac arrhythmias (Marques, 2024). However, manual interpretation of the electrocardiogram presents significant limitations, such as subjectivity and the risk of human error, which can hinder the detection of subtle cases of arrhythmia.
In this context, the advancement of computer sciences, especially in the biomedical domain, has enabled the application of machine learning algorithms in the analysis of electrocardiogram signals. These computational models are capable of identifying complex patterns and revealing information that would often not be perceived in an exclusively human analysis (Chicco et al., 2024). Machine learning, according to Ravani (2024), has transformed various fields of knowledge, allowing computers to learn and improve their performance without the need for explicit programming, by processing large volumes of data. These algorithms can recognize complex relationships and make high-quality predictions, being able to identify subtle and multifaceted patterns in long historical data series that are difficult for experts to detect.
In medicine, machine learning has expanded its applications in the diagnosis, prognosis, and treatment of pathologies. The automated analysis of medical exams and the identification of patterns assist healthcare professionals in making faster and more assertive decisions, integrating technology and clinical practice for significant gains in diagnostic accuracy and efficiency (Braga et al., 2019). Despite the relevance of databases such as Arrhythmia for arrhythmia classification studies, their characteristics, such as the reduced number of observations and the limited diversity of the population, impose limitations on the generalization of results. Furthermore, the reformulation of the original multiclass problem into a binary classification, although it simplifies the detection of the presence or absence of arrhythmia, does not allow for the specific identification of different types of cardiac alterations. These limitations reinforce the need for future validations in independent databases and with multiclass approaches.
Given this scenario, the present research is justified by the need to develop and evaluate more effective and objective methods for the detection of cardiac arrhythmias, overcoming the limitations of manual interpretation and contributing to the improvement of clinical practices. The objective of this work is to investigate the application of Machine Learning techniques in the detection of cardiac arrhythmias, using tabular electrocardiogram data as the main source of information, seeking to understand and compare the performance of four models: Logistic Regression, Random Forest, XGBoost, and Support Vector Machine in the identification of cardiac arrhythmia, with the expectation that the results can contribute to the improvement of clinical practices and assist in the development of more efficient decision support systems, promoting early detection and timely treatment of cardiac arrhythmias.
2. Material and Methods
The methodology of this study focused on the application of machine learning algorithms for the classification of cardiac arrhythmias, aiming to identify patterns in electrocardiographic data. The process involved the acquisition, preprocessing, training, and evaluation of supervised classification models. The electrocardiogram (ECG) served as the basis for the data, being a non-invasive examination that records the electrical activity of the heart, allowing the analysis of cardiac electrical conduction and assisting in the diagnosis of heart diseases (Ramos and Sousa, 2007). The interpretation of the ECG is based on the analysis of components such as the P waves, the QRS complex, and the T wave, which represent specific electrical events of the cardiac cycle (Guyton and Hall, 2021).
The Arrhythmia dataset, obtained from the UCI Machine Learning Repository (Guvenir et al., 1997), was used, comprising 452 instances and 280 attributes. These included demographic information (age, sex, height, weight) and clinical characteristics from electrocardiograms, such as temporal measurements of intervals, wave amplitudes, vector angles, and statistical metrics derived from the signals.
The original target variable, of a categorical nature, presented 16 distinct classes, representing different types of arrhythmias or normality conditions. For the objectives of this work, the problem was reformulated into a binary classification task, where the absence of arrhythmia was labeled as class 0 and the presence of any type of arrhythmia (classes 2 to 16) was grouped as class 1.
The data preprocessing began with loading the Arrhythmia database. Missing values (“?”) were replaced by NaN, and variables converted to numeric. Column 14 (>50% missing) was removed, and the remaining 32 instances with missing values were excluded. The cleaned dataset was divided into predictor variables and a binary target, and partitioned into training (80%) and testing (20%) sets in a stratified manner.
For the scaling of variables, the “RobustScaler” method was applied, which standardizes data using the median and interquartile range, being less sensitive to outliers (Khoirunnisa and Ramadhan, 2023). The scaler was fitted exclusively on the training set and applied to the training and test sets to avoid information leakage.
Attribute selection was conducted based on variable importance, estimated by a “Random Forest” classifier on the training set (Lee, 2005). This procedure aimed to reduce dimensionality and improve model interpretability. The ten most relevant variables were selected to form the final dataset.
In the modeling and evaluation stage, four supervised classification algorithms were selected: Logistic Regression (Hosmer et al., 2013; Mitchell, 1997), Random Forest (Breiman, 2001; Bühlmann and Yu, 2002), XGBoost (Chen and Guestrin, 2016), and Support Vector Machine (SVM) (Vapnik et al., 1996; Cortes and Vapnik, 1995). The objective was to compare the performance of these approaches in predicting cardiac arrhythmias.
For each model, the hyperparameters were optimized using the “GridSearchCV” method (Pedregosa et al., 2011) with five-fold cross-validation. For Logistic Regression, regularization parameters and optimizers were evaluated. The Random Forest had parameters such as the number of trees and depth adjusted. In XGBoost, the number of trees, depth, learning rate, and sampling were tested. For SVM, with a radial kernel (“rbf”) (Hastie et al., 2009), regularization and “gamma” parameters were evaluated.
The optimization criterion adopted was the F1-Score, considered adequate for binary classification problems with imbalanced classes (Powers, 2011). The final evaluation of the models occurred on the test set, using performance metrics such as accuracy, precision, recall, F1-Score, and AUC-ROC (Hastie et al., 2009).
3. Results and Discussion
This section details the results obtained in the investigation of the application of machine learning algorithms for the classification of cardiac arrhythmias, based on tabular electrocardiogram data. The findings are presented and discussed in accordance with the methodology employed, addressing from the exploratory analysis of the selected variables to the performance of the predictive models. The central objective was to compare the effectiveness of different techniques in identifying arrhythmias, aiming to contribute to the development of clinical decision support systems.
Initially, the exploratory analysis of the selected variables, performed after the preprocessing and feature selection stage, provided an in-depth understanding of the data’s behavior. The ten most relevant variables, identified by the Random Forest model, were subjected to a descriptive statistical analysis, which included measures of position and dispersion. It was observed that all variables presented a median equal to zero, a result consistent with the application of the RobustScaler scaling method, which uses the median as a centrality measure, making the process less sensitive to outliers.
The data variability revealed that the variable att_91 stood out with a high standard deviation and a wide range of values, indicating significant dispersion and the presence of extreme values. This behavior suggests that att_91 may be associated with complex physiological patterns or abnormal events in the electrocardiographic signal, reinforcing its importance for arrhythmia detection. Furthermore, the presence of positive and negative values in several variables indicates centered distributions, but with notable dispersion, a common characteristic in biomedical data.
The analysis of the variable distributions through histograms indicated that most attributes presented a distribution approximately centered at zero, with varying levels of asymmetry. Variables such as att_15, att_5, att_169, and att_207 exhibited behavior closer to a symmetric distribution. In contrast, other variables, such as att_228 and att_167, showed asymmetry and long tails, suggesting the presence of rare events or atypical patterns in the cardiac signal, potentially associated with the presence of arrhythmias.
The presence of extreme values was confirmed and deepened by the boxplot analysis, which showed outliers in practically all variables. The highlight for att_91, with significantly high extreme values, reinforces the idea that certain variables capture rare events or intense changes in the electrocardiographic signal. This finding is crucial, as these patterns can significantly contribute to the model’s ability to identify anomalies associated with arrhythmia, as discussed by Chicco et al. (2024) on the importance of complex patterns in biomedical data.
The multivariate analysis, performed using pairplot graphs, revealed considerable overlap between the classes of individuals without arrhythmia (blue) and with arrhythmia (orange) in several combinations of variables. This behavior indicates the absence of a clear linear separation in the original data space, which makes it difficult to distinguish between the groups using simple linear boundaries. However, the marginal distributions (density plots on the diagonal) showed that, despite the overlap, there are specific regions of the sample space where one of the classes predominates.
In some variables, the arrhythmia class showed higher concentration in extreme values, while the normal class tended to concentrate in more central ranges. This pattern suggests the existence of implicit thresholds that can aid in discriminating between the groups. Additionally, the arrhythmia class demonstrated greater dispersion and longer tails in the distributions, occupying wider regions of the attribute space, whereas the normal class appeared more concentrated and homogeneous. This behavior indicates that the distinction between the classes does not depend on a single isolated variable, but rather on the joint interaction between multiple attributes, characterizing a problem of a nonlinear nature.
The simultaneous presence of overlap and partially separable regions evidences that, although separation is not trivial, there is a discriminative structure in the data. This context justifies the use of more robust models capable of capturing complex relationships, such as Random Forest and XGBoost, which proved more effective in the predictive modeling stage by exploring these non-linear interactions and patterns. The ability to identify these complex patterns is a differential of machine learning, as pointed out by Ravani (2024).
Predictive Modeling Results
In the predictive modeling stage, four machine learning models were evaluated: Logistic Regression, Random Forest, XGBoost, and Support Vector Machine (SVM). Initially, the base models were trained using scaled data and the reduced set of attributes. Preliminary results indicated that the Random Forest model showed superior performance compared to the others, especially in the F1-Score for the positive class (Arrhythmia), with a value of 0.8056. This performance demonstrated a greater ability to balance precision and sensitivity in a slightly imbalanced data scenario.
In comparison, the XGBoost model presented an intermediate performance, while Logistic Regression and SVM exhibited inferior results, particularly in identifying the arrhythmia class. Accurate arrhythmia identification is a critical aspect in the clinical context, where the detection of false negatives can have serious implications. The superiority of Random Forest at this initial stage already pointed to its robustness in handling the complexity of electrocardiographic data.
Hyperparameter optimization was performed using the GridSearchCV method, employing stratified five-fold cross-validation and F1-Score as the optimization criterion, applied exclusively to the training set. For Logistic Regression, the best hyperparameters were C = 0.01, penalty = l2, and solver = liblinear. For Random Forest, n_estimators = 200, max_depth = 10, min_samples_split = 2, and min_samples_leaf = 2 were the optimized values. XGBoost achieved n_estimators = 300, max_depth = 6, learning_rate = 0.01, subsample = 0.8, and colsample_bytree = 0.8. SVM, on the other hand, used kernel = rbf, C = 10, and gamma = 1.
The optimization results showed that the models were adjusted with complexity control mechanisms, such as regularization, limiting tree depth, and using sampling. These adjustments are fundamental to mitigate overfitting and improve the generalization capability of the models, ensuring that the observed performance is not just a memorization of the training data, but a real prediction capability on unseen data (Khoirunnisa and Ramadhan, 2023).
The cross-validation results, after hyperparameter optimization, confirmed the trend observed in the preliminary results. The XGBoost model presented the highest average F1 (0.774±0.065), while Random Forest demonstrated similar performance (F1 of 0.769±0.075), but with lower variability between folds, indicating greater stability. The SVM, despite high precision (0.864±0.049), presented reduced recall (0.616±0.077), implying a higher occurrence of false negatives, a relevant clinical risk.
Logistic Regression, in turn, presented the lowest performance among the evaluated models, with an F1-Score of 0.716±0.050, suggesting limitations in modeling the non-linear relationships present in the data. The choice of Random Forest as the final model was justified not only by its high average performance but mainly by its greater stability and better balance between metrics, fundamental characteristics in healthcare applications, where the consistency of results is crucial.
After selection, the Random Forest model was evaluated on the test set, composed of data not used during training and validation. The results confirmed the model’s good performance, achieving an accuracy of 84.52%, precision of 83.33%, recall of 81.08%, F1-Score of 82.19%, and ROC-AUC of 0.8902. These values demonstrate the model’s generalization capability and its robustness in identifying cardiac arrhythmias from ECG data.
The analysis of the confusion matrix of the Random Forest model revealed good overall performance, with a high hit rate. However, the presence of false negatives, although in smaller numbers, indicates a limitation in detecting some cases of arrhythmia. From a clinical point of view, this type of error is particularly relevant, as it represents patients with cardiac alterations who would not be identified by the model, which reinforces the importance of using these systems as a decision support tool, and not as a substitute for medical evaluation.
The ROC curve showed a high area under the curve (AUC) of 0.8902, indicating an excellent discriminatory capacity of the model. This result is aligned with the literature, which points out that tree-based and ensemble models, such as Random Forest, perform well in binary classification tasks on biomedical data (Dhanka and Maini, 2021). The high AUC demonstrates that the model is capable of correctly distinguishing between classes, even in situations of data imbalance (Hastie et al., 2009).
The results obtained in this study indicate that tree-based models, such as Random Forest and XGBoost, show superior performance in classifying cardiac arrhythmias from tabular electrocardiogram data. This finding reinforces the suitability of these algorithms for problems characterized by high dimensionality, presence of noise, and nonlinear relationships between variables, as is the case with the analyzed electrocardiographic data. Random Forest stood out not only for its high average performance but also for its lower variability among cross-validation folds, demonstrating greater stability and generalization capability, fundamental characteristics in healthcare applications.
These results are in line with the study by Dhanka and Maini (2021), who also identified Random Forest as the most effective model in predicting heart disease. However, other studies, such as those by Kumar et al. (2024) and Shimpi et al. (2017), point to Support Vector Machine (SVM) as the best-performing model in similar contexts. These divergences highlight that there is no universally superior model, with performance being strongly dependent on factors such as data preprocessing, feature selection, class balancing, and the nature of the available variables.
In the present study, the use of attribute selection and robust scaling may have favored tree-based algorithms, which are naturally more adaptable to different data distributions and less sensitive to variable scale. From an applied point of view, the results obtained suggest that machine learning models can act as clinical decision support tools, especially in screening scenarios. The observed performance, with a high F1-Score for the arrhythmia class and an AUC-ROC close to 0.9, indicates a good model capacity in identifying individuals with cardiac alterations, reducing both false positives and false negatives.
In this context, it is possible to conceive the practical application of the model in hybrid protocols, in which artificial intelligence acts as an initial filtering step, while the final decision remains the responsibility of the physician. This approach allows for increased efficiency of the healthcare system, reduced diagnosis time, and optimized resource allocation, without compromising patient safety. In terms of implementation, the model could be integrated into electronic health record systems, automatically analyzing ECG data and classifying patients according to arrhythmia risk.
Alternatively, the solution could be applied on digital platforms or portable devices, expanding access to screening tools in primary care and telemedicine contexts. Despite the promising results, it is important to highlight that the model should not be interpreted as a substitute for medical evaluation, but as a support system, especially due to the presence of false negatives, which represent a relevant clinical risk. The use of a single public database, with a limited number of observations, restricts the evaluation of the model’s generalization capacity to different populations and clinical contexts.
Furthermore, reformulating the original multiclass problem into a binary classification allows for the identification of the presence or absence of arrhythmia, but it does not enable the distinction between different types of cardiac alterations. Thus, the results should be interpreted within the scope of the dataset and the approach adopted in this study. In summary, the results of this study highlight not only the performance of the models but also the potential for their practical application, contributing to the advancement of digital health solutions aimed at faster, more accurate, and accessible diagnostics.
4. Conclusion
This research investigated the application of machine learning techniques in the detection of cardiac arrhythmias, using tabular electrocardiogram data. It was found that, after conservative preprocessing, robust scaling, and feature selection based on Random Forest, the machine learning models demonstrated promising capability. Among the evaluated algorithms, Random Forest stood out with robust performance on the test set, achieving an accuracy of 84.52%, precision of 83.33%, recall of 81.08%, F1-Score of 82.19%, and ROC-AUC of 0.8902. This model exhibited a superior balance between precision and sensitivity, as well as greater stability, essential characteristics for healthcare applications. The results obtained indicate that the proposed approach can act as an effective clinical decision support tool, contributing to faster and more accurate diagnoses in screening scenarios and optimizing resource allocation in healthcare systems.
However, the generalization of the results is limited by the use of a single public database with a restricted number of observations and by the reformulation of the original multiclass problem into a binary classification, which prevents the distinction between different types of arrhythmias. The presence of false negatives, although in smaller numbers, reinforces that the model should be used to support medical evaluation, not as a substitute. For future studies, it is suggested to explore more advanced feature engineering techniques, incorporate temporal ECG signal data, and apply deep neural network-based models. Model validation on external databases and in real clinical contexts is crucial to assess its robustness and implementation feasibility, as well as the analysis of model interpretability to increase the confidence of healthcare professionals.
Bibliographic References
Antzelevitch, C.; & Burashnikov, A. 2011. Overview of Basic Mechanisms of Cardiac Arrhythmia. Cardiac electrophysiology clinics 3(1): 23–45
Chicco, D.; Karaiskou, A. I.; De Vos, M. 2024. Ten quick tips for electrocardiogram [ECG] signal processing. PeerJ Computer Science 10: e2295.
Kumar, A.; Singh, J.; & Khan, A. A. 2024. Arrhythmia Detection Using Machine Learning: A Study with UCI Arrhythmia Dataset. In: International Conference on Frontiers of Intelligent Computing: Theory and Applications, 2024, Singapore. Anais… p. 217-226.
Marques, B. T. 2024. Interpretabilidade de modelos de aprendizado de máquina para classificação de arritmias cardíacas. Dissertação de Mestrado em Computação. Programa de Pós Graduação em Computação, Campus Quixadá, Universidade Federal do Ceará, Quixadá, CE, Brasil.
Organização Mundial da Saúde [OMS]. 2025. Doenças cardiovasculares [DCV]. Disponível em: <https://www.who.int/news-room/fact-sheets/detail/cardiovascular-diseases-(cvds)>. Acesso em: 29 ago. 2025.
Ravani, D. C. 20
Article originating from the Final Course Project of the Specialization in Data Science and Analytics of the MBA USP/Esalq
To learn more about the course, click here and access the MBX Academy platform