## 2 Design and Experimental Setup
### Optimized, Subject-Wise Cross-Validated CNN Model  
In this study, a prediction model is developed based on the SCA data from PhysioNet to identify and classify heartbeats as normal and abnormal and be applied to any new individual ECG recording. Researchers have proposed different methods for identifying the risk of SCD using different markers in the literature. To predict SCA one hour before the VF onset, a kNN, SVM models were built [19; 20; 21]. Although these methods can be employed to predict SCA, the time required to extract features and the additional circuitry make them incompatible with real-time applications. The CNN model extracts features that are specific to the setting. [PERSON] et al. built a CNN model only to extract features and, based on the output features, an SVM classifier was built to classify ECG segments. Five-fold cross-validation was performed to obtain an accuracy of 99.02% [22]. The accuracy is high because the same subject ECG data are present in the training and test sets. However, there is a low degree of sensitivity and specificity or negative predictive value. CNNs can learn non-linear features flexibly and have inherent feature-extraction capabilities. Moreover, CNN is effective at extracting spatial features from time series data. Hence, this work is focused on building an optimized, subject-wise cross-validated CNN model to classify SCA heartbeats. Building the CNN model involves the following steps: First, the SCA data are preprocessed. For each subject, Physionet's 'ATR' file contains ECG values, annotations, and frequency, and more information is sampled and scaled. We sampled the data at 500 ms and normalized the data. The next step is to split the dataset subject-wise. Then we optimize the model with subject-wise cross-validation. The next step is to deploy the model and evaluate its performance on test data. Implementing the model on a hardware platform is the final step. In Figure 5, the complete process of building the CNN model is represented. A half-hour recording of the patients in the SCA data shows a significant imbalance between the number of normal and abnormal heartbeats (the various abnormal beats listed in the table are grouped into one category and labeled as abnormal), with 96% beats as normal and only 4% as abnormal beats per subject. All abnormalities are combined to develop a binary CNN classifier. The weights are initialized based on abnormal beats rather than normal beats to address the class imbalance. Subject-wise cross-validation (CV) is a feature of a machine learning tool where the trained model learns from each piece of subject data, set by the learning rate parameter. For different databases, CNN architecture requires hyperparameter tuning. The hyperparameters, such as the number of layers, number of neurons, activation function, etc., offer a range of options. To obtain an optimized model, we tune the hyperparameters. The lower \begin{table}
\begin{tabular}{c c c} \hline \hline \multirow{2}{*}{**SI. No**} & **Beat and Non-Beat** & **Description** \\  & **Annotations** & **Description** \\ \hline
1. & B & Bundle branch block beat \\
2. & E & Ventricular escape beat \\
3. & F & Fusion of ventricular and \\  & & normal beat \\
4. & J & Nodal (lunctional) premature \\
5. & N & Neural beat \\
6. & S & Supraventricular escape beat \\
7. & V & Premature ventricular \\  & & contraction \\
8. & \(|\) & Isolated QRS like artifact \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Annotations of heartbeats for SCA data. learning rate indicates slow but thorough training with a lower error rate. A slower-trained model is best suited for predictions on new subjects' data that is raw and has not been previously trained. Hence, such a CV-based model is suitable for real-time applications [23]. This work was cross-validated subject-by-subject. The first step is to separate some subjects from the entire dataset for testing and evaluation. The remaining subjects' data are divided into a training set and a validation set using the re-sampling method.