# Decision Support System for Predicting Mortality in Cardiac Patients Based on Machine Learning
## 2 Materials and Methods
### Proposed Work  
In this study, we developed a diagnostic system for the early detection of mortality risk in heart disease. The proposed diagnostic system uses a dataset of 55 features based on daily lifestyle factors, medical history, and biochemical test results. The newly developed system consists of two main components. One of the main components is to select useful features from the dataset that can help predict the cause of cardiac mortality. The second component, on the other hand, is a classifier that predicts cardiac mortality. To select features from the given dataset, we used a static chi-square model (\(\chi^{2}\)), whereas, for the classification problem, we used a random forest classifier (RF), fine-tuning the hyperparameters of the RF using the grid search algorithm [23]. The working of the newly developed system is given in Figure 2.  
For this study, we used the (\(\chi^{2}\)) model to rank the features from the dataset to eliminate irrelevant features. In feature selection, (\(\chi^{2}\)) computes the statistics between the non-negative feature \(\kappa_{i}\) and the class. The model performs the (\(\chi^{2}\)) test, which analyzes the degree of dependence between the features and the class. As a result, the model can exclude features more likely to be class-independent, as these features could be considered unimportant for classification. The features are sorted in the first phase depending on the (\(\chi^{2}\)) test score. Then, we search for ideal features \(\omega\) from the scored features. For information on feature selection and discretization using (\(\chi^{2}\)) statistics, the reader is referred to [24]. Mathematical feature selection based on the (\(\chi^{2}\))-test is described as follows:  
Figure 1: Distribution of samples in the dataset. From Table 2, we can calculate the statistical score \(\chi^{2}\) for positive and negative classes for the \(\Omega\) instances of the binary classification problem of heart mortality. In Table 2, \(\gamma\) represents the number of instances that do not have feature \(\kappa\), \(\Omega-\gamma\) denotes the number of instances that do not contain feature \(\kappa\), \(\rho\) represents the positive instances, and the number of positive instances can be represented from \(\Omega-\rho\). The main purpose of the \(\chi^{2}\) test is to measure the expected count, i.e., \(C\), and the observed count, i.e., \(B\), which are derived from each other. Assuming that \(\alpha\), \(\beta\), \(\tau\), and \(v\) represent the observed values and \(C_{\kappa}\), \(C_{\beta}\), \(C_{\tau}\), and \(C_{v}\) denote the expected values, then the predicted values based on the null hypothesis of independent events can be calculated as follows:  
\[C_{\kappa}=(\alpha+\beta)\frac{\alpha+\beta}{\Omega} \tag{1}\]  
From Equation (1), \(C_{\beta}\), \(C_{\tau}\), and \(C_{v}\) can be computed. For the general formulation of the \(\chi^{2}\) score, we have  
\[\chi^{2}=\frac{1}{v}\sum_{i=1}^{n}\frac{(B_{i}-C_{i})^{2}}{B_{i}} \tag{2}\]  
\[\chi^{2}=\frac{(\alpha-C_{\kappa})^{2}}{C_{\alpha}}+\frac{(\beta-C_{\beta})^{ 2}}{C_{\beta}}+\frac{(\tau-C_{\tau})^{2}}{C_{\tau}}+\frac{(v-C_{v})^{2}}{C_{v}} \tag{3}\]  
From solving the equations, we obtain a simple form of Equation (3)  
\[\chi^{2}=\frac{\Omega(\alpha\tilde{\Omega}-\gamma\rho)^{2}}{\gamma\rho(\tilde{ \Omega}-\rho)(\tilde{\Omega}-\gamma)} \tag{4}\]  
After feature ranking from Equation (4), the highly ranked (selected) features (or a subset of the features) are input into RF for classification. However, before the classification phase, it was found that the number of class instances in the dataset was highly imbalanced. To overcome the problem of bias in machine learning, we employed the synthetic minority oversampling technique (SMOTE). SMOTE achieves balanced classes in the data by enriching the training data with synthetic minority class samples, resulting in balanced classes