## 2 Design and Experimental Setup
### Optimized, Subject-Wise Cross-Validated CNN Model
We create a three-groups or three-fold (k = 3) dataset with different training and validation subjects. This is explained with an example; consider 12 subjects: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12. The ECG samples of subjects two, five, and eleven were randomly selected for testing. The remaining subjects' data were divided into three folds. In the first fold, 4 and 12 data are in the validation set, and 1, 3, 6, 7, 8, 9, and 10 are in the training set. On the second fold, 3 and 10 subjects are in validation, and 1, 4, 5, 6, 7, 8, and 9 of the 12 subjects are for training. On the third fold, there are 1 and 8 for validation and 3, 4, 5, 6, 7, 9, 10, 11, and 12 subjects in the training set. The fold (combination) that gives the model the highest performance is selected. Finally, an evaluation is performed to build an effective and efficient model on the test set. Training the ML model with subject-wise cross-validation in clinical settings is essential to simulate real-world medical diagnostics processes. This is because we train our model in such a way that the training set and test set (holdout set) have data from the same patients. At that time, the model will learn to classify the abnormal beats and pick up on identifying the characteristics of the patients. This will cause misjudgent in the classification error. Also, the data sample variability is significantly higher across patients than within patient data variability [24]. TensorFlow was used to implement the classification in a Python environment. As illustrated in Figure 6, our CNN includes three convolution layers and three pooling layers, and we added two fully connected layers and an output layer for classifying the heartbeats. The heartbeat is classified as either normal (1) or abnormal (0) heartbeat. As a precaution against overfitting, batch normalization and drop-out layers were added. The CNN model uses a rectified linear activation function (ReLU) to transform the summed weighted input from the node into the node's activation or output for that input. A low learning rate model of 0.00001 is used for better training and validation. The batch size, which defines the number of samples propagated through the network, is set to a good default size of 32. A higher batch size (e.g., 64) reduces the error rate but increases the training time of the model. The values for these and other optimized CNN hyperparameter settings are listed in Table 3. Weights are initialized so that abnormal beats can be detected accurately. The effectiveness of the CNN model on SCA classification is evaluated using the following performance measures: precision, recall, confusion matrix, accuracy, and F1-score. The confusion matrix for the binary classification model is 2 \(\times\) 2. The column of the matrix shows the true class, and the rows show the predicted class. The segment of the confusion matrix determines as _TP_ (true positive) when the true class and predicted class values are normal (1), as _TN_ (true negative) when the true class and predicted class values are abnormal (0). Thus, _TP_, and _TN_ are diagonal elements. _FP_ (false positive) is when the true value is normal (1), and the predicted value is abnormal (0), and _FN_ (false negative) is the value for a model when the true value is abnormal and predicted value is normal. The diagonal cells show where the true class and the predicted class match. For a particular machine learning model, accuracy is a key performance parameter that indicates the rate at which anomalies are detected. Among the other performance, parameters are the true positive rate (Recall) and the true negative rate (Precision). F1 score, which is the geometric mean of recall and precision, is well-suited and used to compare the performance of ML models using different datasets.