Detecting Myocardial Infarction by Electrocardiogram Machine Learning Models With Greater Accuracy; A Technical Advance Article

Abstract


Abstract Background
Electrocardiogram (ECG) is a key diagnostic test in cardiac investigation.Interpretation of ECG is based on the understanding of normal electrical patterns produced by the heart and alterations of those patterns in speci c disease conditions.With machine learning techniques, it is possible to interpret ECGs with increased accuracy.However, there is a lacuna in machine learning models to detect myocardial infarction (MI) coupled with the affected territories of the heart.

Methods
The dataset was obtained from the University of California, Irvine, Machine Learning Repository.It was ltered to obtain observations categorized as Normal, Ischemic changes, Old Anterior MI and Old Inferior MI.The dataset was randomly split into a training set (70%) and a test set (30%).73 out of the 270 ECG features were selected based on the changes observed following MI, after excluding predictors that had near zero variance across the observations.Three machine learning classi cation models (Bootstrap Aggregation Decision Trees, Random Forest, Multi-layer Perceptron) were trained using the training dataset, optimizing for the Kappa statistic and the parameter tuning was achieved with repeated 10-fold cross validation.Accuracy and Kappa of the samples were used to evaluate performance between the models.

Results
The Random Forest model identi ed old anterior and old inferior MIs with 100% sensitivity and speci city and all 4 categorized observations with an overall accuracy of 0.9167 (95% CI 0.8424 -0.9633).Both the Bootstrap Aggregation Decision Trees and the Multi-layer Perceptron models identi ed old anterior MIs with 100% sensitivity and speci city and their overall accuracies for all 4 observations were 0.8958 (95% CI 0.8168 -0.9489) and 0.8542 (95% CI 0.7674 -0.9179) respectively.

Conclusion
With a medically informed feature selection we were able to identify old anterior MI with 100% sensitivity and speci city by all three models in this study, and old inferior MI with 100% sensitivity and speci city by Random Forest Model.If the data set can be improved it is possible to utilize these machine learning models in hospital setting to identify cardiac emergencies by incorporating them into cardiac monitors, until trained personnel become available.

Background
Since its development in 1902, Electrocardiogram (ECG) has evolved steadily to the cost effective, simple and non-invasive 12 lead ECG used in the modern age, which is one of the most widely used investigations worldwide (1).It remains a cornerstone investigation in the medical eld, utilized for the diagnosis of countless medical conditions including cardiac conditions such as acute coronary syndromes and arrhythmias and non-cardiac conditions such as electrolyte imbalances.A standard 12 lead ECG records information from 6 limb leads namely lead I, II, III, aVR, aVL and aVF and 6 chest leads from V1-V6.These leads look at the heart from different directions and record the electrical signals accordingly and the standard ECG has a p wave, QRS complex and T wave (1).
The interpretation of ECG is based on the understanding of normal electrical patterns produced by the electrical activity of the heart and the variations in speci c conditions.This pattern recognition process requires targeted knowledge and depends on the ability and training of the interpreter.With the development of machine learning techniques, it is possible to train a model to recognize these patterns and interpret the ECG tracing.
There have been models reported which aimed to detect arrhythmias by classifying ECGs as normal and abnormal and to narrow down the speci c arrhythmia by classifying them into multiple classes (2,3).However, as a review done in 2017 reveals, studies regarding myocardial infarction (MI) and the affected territory are few (4).A vast amount of information can be gathered using the ECG, from the presence of an MI up to the affected area, timing and complications.The ECG changes of an MI depend on the lead and the timing and may include tall T waves in the initial stage, ST segment elevation, left bundle branch block, prolonged QRS complex, increased heart rate (reduced R-R interval) and q waves in an old MI.According to the affected territory, these changes may be seen in different leads.For example, in leads II, III and aVF in an inferior MI and in the chest leads in an anterior MI (5).
Therefore, with these changes in mind we aimed to create a machine learning model utilizing existing ECG data to detect an MI along with the information regarding the affected territory and timing.

Materials And Methods
The dataset used was obtained from University of California, Irvine (UCI) Machine Learning Repository, which contained 279 predictor variables of 452 observations (6).The variables included age, sex, height, weight and attributes derived from standard 12 lead ECG tracings.Each observation had been assigned one of sixteen possible outcomes.
The original dataset was ltered to obtain observations categorized as Normal (class 1), Ischemic changes (class 2), Old Anterior MI (class 3) and Old Inferior MI (class 4).
The dataset was randomly split into a training set (70%) and a test set (30%).Ninety nine features were selected based on the ECG changes that are observed following a MI.They are heart rate, the amplitudes of q, R and T waves and the durations of the QRS complexes along with the age and the sex of the subject (Table 1).Total 99 26 predictors (R' and S' waves of all the 12 leads and Q wave amplitudes of V2 and V3 leads) that had near-zero variance across the observations were excluded.The selected 73 features were scaled to have a mean of 0 and standard deviation of 1.
Three machine learning classi cation models (Bootstrap Aggregation Decision Trees, Random Forest, Arti cial Neural Network) were trained using the training dataset, following data up-sampling to overcome class imbalances, optimizing for the Kappa statistic, which is a measure of inter-rater reliability which takes the possibility of percentage agreement occurring by chance, into account.
Parameter tuning of the models was done with 10 fold repeated cross validation.Cross validation folds were sampled identically to make inter-model performance evaluation possible using accuracy and Kappa statistics.
Performance of the nal model was evaluated using sensitivity, speci city, positive predictive value, negative predictive value and balanced accuracy for each class for the test dataset.
The evaluation metrices are summarized below.

Results
The Bootstrap Aggregation classi er had a mean accuracy of 0.9788 and a mean Kappa value of 0.9718 for the 100 cross validation resamples.
The Random Forests model yielded the highest cross validation accuracy (0.9927) and Kappa metric (0.9902) out of the three models, with 3 randomly selected variables for splitting each tree node (Figure 1).
The Feed forward Arti cial Neural Network was a Multi-layer Perceptron with one hidden layer (Figure 2).This model yielded the highest cross validation accuracy (0.9772) with 10 hidden units (Figure 3).
The distributions of the evaluation matrices of the cross validation samples and the scatter plot matrix for Kappa statistic of the three models are depicted in following gures (Figure 4, 5, 6).
All the three models had excellent cross validation accuracies.
The previously unseen test data split was used to evaluate the nal model performances.
The Random Forests model predicted the classes of the test dataset with an overall accuracy of 0.9167 (95% CI 0.8424 -0.9633) with 100% sensitivity and speci city for identifying old anterior and old inferior myocardial infarctions.
The overall accuracies of the Bootstrap Aggregation Decision Trees and the Multi-layer Perceptron models were 0.8958 (95% CI 0.8168 -0.9489) and 0.8542 (95% CI 0.7674 -0.9179).Both these models could identify old anterior myocardial infarctions with 100% sensitivity and speci city.
The confusion matrices and evaluation matrices of the three models are summarized below (Tables 2-7).(7).

Random Forests model
The feature extraction and reduction was carried out by correlation-based feature subset selection.A notable characteristic in the above models is that the feature selection was not performed based on medical knowledge regarding the diseases but rather by mathematical feature reduction techniques.It is possible that this may be responsible for the relatively similar accuracies which do not exceed 90%.Furthermore, this data set has not been utilized speci cally for the detection of myocardial infarctions and its subsets.
It is evident by this study that the detection and classi cation of myocardial infarction with regard to timing and territory can be achieved with a relatively higher accuracy.The better model performances demonstrated in our study may be attributed to the feature selection technique utilized, which was predominantly based on the known electrophysiological changes occurring during a myocardial Infarction.All three models were able to identify old anterior MI with 100% sensitivity and 100 % speci city, with the random forest model being able to identify old inferior MI with similar matrices as well.Therefore, this study highlights the potential real world applications of this technology in the healthcare sector.The availability of an interpretation along with the tracing would be of paramount importance in conditions like myocardial infarctions where time is of the essence.The need to wait for trained personnel for the interpretation of ECG can be avoided and hence delays minimized.Patients requiring emergent care can be identi ed in settings with a large patient load.In addition, implanted cardioverter de brillators (ICDs) and pacemakers of patients can also be equipped with this technique, enabling the detection of MI as well.Hence, it is evident that further studies to explore the boundaries of these new upcoming leaps in technology should be performed for the improvement of medical diagnostics.

Conclusion
We used three machine learning models to detect MI along with timing and territory, using data derived from ECG tracings.The overall accuracies obtained by Random Forests, Bootstrap Aggregation Decision Trees and Multi-layer Perceptron were 0.9167, 0.8958 and 0.8542 respectively.Furthermore, all the models could identify old anterior MIs with a speci city and sensitivity of 100%.
This study can be expanded by using a more extensive data set, to include more detail regarding timing and territories, as well as the detection and classi cation of arrhythmias.Hence, it can be concluded that these models can be utilized in hospital settings to minimize the delays until trained personnel are available for ECG interpretation and to alert the staff of a potential emergency.Cross validation Kappa statistics for different numbers hidden units of the neural network.

List Of Abbreviations
Box-and-whisker plots of the resampling distributions of the accuracy and the Kappa between the models.
Resampling distributions of the accuracy and the Kappa between the models.
Accuracy = Number of correct predictions / The total number of predictions Sensitivity= True positive / (True positive + False negative) Speci city= True negative / (True negative + False positive) Positive predictive value = True positive / (True Positive + False positive) Negative predictive value = True negative / (True negative + False negative) =+ =+

Figure 2 The
Figure 2

Table 1
Selection of ECG features based on medical knowledge

Table 2
Confusion matrix of Random Forest Model Original label of the class Radom forest Model identi ed as

Table 3
Performance of the Random Forest model on the test data

Table 4
Confusion Matrix of Bootstrap Aggregation Decision Trees Model

Table 5
Performance of the Bootstrap Aggregation Decision Trees Model on the test data

Table 6
Confusion Matrix of Multi-layer Perceptron Model

Table 7
(3)formance of Multi-layer Perceptron Model on the test data learning dataset has been utilized by previous studies for the detection of heart disease, mainly arrhythmias.A modular neural network model proposed by Jadhav et al., aimed to detect arrhythmias by classifying the ECG tracings as 'normal'and 'abnormal'.It was found that the model classi ed the tracings into the two classes with 82.22% accuracy (2).Batra et al., also utilized multiple machine learning algorithms for the classi cation of arrhythmias into multiple classes.The maximum accuracy achieved was 84.82% using Support Vector Machine (SVM) algorithm and gradient boosting, in conjunction(3).A model proposed by Mitra et al., utilized neural networks for the classi cation of arrhythmias into 'normal' and 'arrhythmia'.It was found that an accuracy of 87.71% was achievable using this method