Our study presents a novel approach for myocardial infarction (MI) detection using an autoencoder and machine learning method. We propose a deep learning model that can automatically extract relevant features from electrocardiogram (ECG) signals to accurately diagnose MI. The proposed approach achieves state-of-the-art performance with an accuracy of 99.6% on a large-scale ECG dataset. Furthermore, we conducted extensive experiments to evaluate the robustness and generalizability of our model, which shows promising results. Our work has the potential to improve the diagnosis of MI and reduce medical errors, leading to better patient outcomes.