Myocardial infarction (MI), referred to as a heart attack, is a life-threatening condition that happens due to blood clots, typically, blood flow to a portion of the heart muscle is blocked. The cardiac muscle may become permanently damaged if there is insufficient oxygen and blood flow to the affected area. It’s crucial to treat MI as soon as possible because even a small delay might have serious effects. The primary diagnostic tool to track and identify the signs of MI is the electrocardiogram (ECG). The complexity of MI signals combined with noise makes it difficult for clinicians to make a precise and prompt diagnosis. It might be laborious and time-consuming to manually analyse an enormous quantity of ECG data. Therefore, techniques for autonomously diagnosing from the ECG data are required. There have been numerous research on the topic of MI espial, but the majority of the algorithms are cognitively intensive when working with empirical data. The current study suggests a unique method for the efficient and reliable identification of MI. We employed circulant singular spectrum analysis (CSSA) for baseline wander removal, a 4-stage Savitzky–Golay (SG) filter to expunge powerline interference from the ECG signal and segmented in the preprocessing stage. Thus segmented ECG has been decomposed using CSSA, entropy based features are extracted. The best features are selected by using binary Harris hawk optimization (BHHO) and to machine learning (ML) classifiers like Naive Bayes, Decision tree, K-nearest neighbor (KNN), Support vector machine (SVM), and Ensemble subspace KNN. Our suggested method has been examined from both class as well as subject oriented perspectives. While the subject-oriented technique uses data from one patient for testing while using data from the other subjects for training, the class-wise strategy divides data as test data as well as training data regardless of subjects. We succeeded in achieving accuracy ( A c % ) of 99.8, sensitivity ( S e % ) of 99, and 100 specificity (Sp %) under the class-oriented approach. Similarly, for the subject wise strategy we achieved a mean A c % , Se %, and Sp % of 85.2, 83.1, and 84.5, respectively.