Predicting Reinfarction after Myocardial Infarction using a Random Forest Model: A Machine Learning Approach on an Open-Source Clinical Dataset
Reinfarction following acute myocardial infarction is a major complication associated with morbidity and mortality, and early identification of patients at elevated risk remains a key clinical challenge. This study aims to demonstrate the applicability of machine learning approaches in the classification of reinfarction risk. We developed a random forest classifier to predict in-hospital reinfarction using the publicly available Myocardial Infarction Complications dataset. Feature selection combined Information Gain, Chi-Square, Gini Index, Relief, and clinical judgment, yielding four admission-time predictors: age, diabetes mellitus, exertional angina pectoris in anamnesis, and time from symptom onset to hospital admission. Missing data were imputed using mean and most-frequent values, and class imbalance was corrected with the Synthetic Minority Oversampling Technique, resulting in a balanced dataset. Performance was evaluated using area under the receiver operating characteristic curve, Matthews correlation coefficient, and confusion matrix analysis. The random forest model achieved an area under the receiver operating characteristic curve of 0.960, a classification accuracy of 91.2%, an F1 score of 0.912, and an Matthews correlation coefficient of 0.824. The model correctly identified 89.2% of reinfarction cases and 93.1% of non-reinfarction cases. A random forest classifier trained on admission-time clinical variables shows strong predictive performance for in-hospital reinfarction after acute myocardial infarction. These findings support the potential of machine learning for early, personalized risk stratification in post myocardial infarction care.