{'fraction_non_alphanumeric': 0.02318604769410688, 'fraction_numerical': 0.009864239589159506, 'mean_word_length': 4.846611177170035, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
An Improved Coronary Heart Disease Predictive System Using Random Forest

Aims: This work aim is to develop an enhanced predictive system for Coronary Heart Disease (CHD). Study Design: Synthetic Minority Oversampling Technique and Random Forest. Methodology: The Framingham heart disease dataset was used, which was collected from a study in Framingham, Massachusetts, the data was cleaned, normalized, rebalanced. Classifiers such as random forest, artificial neural network, naïve bayes, logistic regression, k-nearest neighbor and support vector machine were used for classification. Results: Random Forest outperformed other classifiers with an accuracy of 98%, a sensitivity of 99% and a precision of 95.8%. Feature selection was employed for better classification, but no significant improvement was recorded on the performance of the classifier with feature selection. Train test split also performed better that cross validation. Conclusion: Random Forest is recommended for research in Coronary Heart Disease prediction


Fig. 1. Coronary-artery-disease
Cardiovascular is a compound-word in Latin, Cardio means heart while vascular means vessel. The heart is a muscular organ in the body; it is the muscular pumping machine that pumps and circulates blood throughout our body. Cardiovascular system also comprises a network of blood vessels, for example, veins, arteries, and capillaries. These blood vessels deliver blood all over the body [1]. All diseases involving this system are called Cardiovascular Diseases (CVDs). There are many diseases that can affect the cardiovascular system including stroke, heart failure, hypertensive heart disease, rheumatic heart disease, cardiomyopathy, abnormal heart rhythms, congenital heart disease, valvular heart disease, carditis, aortic neurysms, peripheral artery disease, thromboembolic disease, and venous thrombosis, [2] asserted CHD is the most prominent of the CVDs. Al-Numan ibn Bashir reported from Muhammad to have said "Verily, in the body is a piece of flesh which, if good the whole body is good and if spoilt the whole body is spoilt, truly the piece of flesh is the heart". (The Hadith, n.d) Furthermore, world health organization (WHO) in 2017 proclaimed CVDs are the number 1 cause of death globally: more people die annually from CVDs than from any other cause. An estimated 17.9 million people died from CVDs in 2016, representing 31% of all global deaths. Of these deaths, 85% are due to CHD. Over three quarters of CVDs deaths take place in low-and middle-income countries.CVD is the leading cause of death in South Africa after HIV/AIDS. The mortality that results from CVDs in South Africa is so much that it is more than the mortality that results from all the cancers combined [3]. WHO (2017), confirmed CHD Deaths in Nigeria reached 76,410 amounting to 3.76% of total deaths in that year. Heart disease is easier to treat when detected early so, if CVDs can be predicted before patients go down with this deadly disease, measures will be put in place to avert it. [1]. States of the heart equipment are needed for the diagnose CHD according to Nhongo, Hendricks, Bradshaw, & Bail, [4], another factor worsening the effect of the disease in Nigeria is the country is far behind in the doctor patient ratio. The novel COVID-19 is another reason for tackling CHD because worst hit victims are those with underlining illness, especially CVDs, but the good news about the disease is that you don't have to compulsorily undergo clinical diagnosis before identifying the disease, since it can be predicted from indicators [5], which is why Machine Learning is used in this field to forecast and diagnose the disease.
Machine Learning (ML) is vital in the formation of medical support systems. This is as a result of the vast amount of data collected in the hospital. These information house the medical history of patients. Machine learning can be used to mine this information to uncover traces of disease in individual [6].
A lot of works have been done with ML in the domain of CHD, this study divide the works as including novel algorithm development, algorithm enhancement, hybridization, implementation and system development, comparative analysis and interface development.
A novel algorithm was developed [7] which was tested with the Alizadehsani dataset against famous classifiers like support vector machine, C4.5 and Naive Bayes, the new algorithm outperformed the famous algorithms, recording a sensitivity value of 100% and accuracy rate of 96.40%. This study has no interface where users can test for their CHD status.
Convolutional neural network was enhanced by [8], the study was conducted using randomly subsampled dataset and iterates LASSO multiple times. Majority voting system was used to identify the variables that are nonzero in major number of iterations. The enhanced algorithm outperformed multilayer perceptron. No interface was designed for this model and the accuracy could also be improved.
Merger of more than one supervised machine learning algorithm was also experimented to diagnose CHD according to the work of [9] who conducted a study using the Cleveland Heart disease dataset, on a hybridization of Naïve Bayes and SVM which gives an accuracy of 89%.
A lot of design and implementation were done while intermarrying CHD and machine learning to improve diagnosis. Some of the works include that of [10], the study used ten thousand and thirty patients data with suspected CHD. Boosted ensemble algorithm was used. No user interface was designed [11] also designed and implemented using the Hungarian Institute of Cardiology, Budapest and the Cleveland Clinic Foundation datasets was employed and a fuzzy expert system was build to aid interpretation of result. Many authors did extensive comparative analysis on supervised machine learning methods used in the domain of CHD. The work of Ayatollahi et al., [12], shows that SVM outperformed ANN on a dataset of three selected hospitals affiliated to AJA University of Medical Sciences in Iran.
[13] also compared ensemble algorithms with other classification algorithms when difficulty was express in diagnosing CHD based on the risk factor, ensemble algorithms did better than the other algorithms.
[7], compared programming expression and genetic algorithm emotional neural when it is known that angiography is the known treatment of CHD, however, it is very expensive and have very high risk. The study used the Alizadehsani dataset genetic programming expression was reported to outperform genetic algorithm emotional neural. Some works in this domain have gone to the extent of designing interface for the implemented system to ease the use of the system for its intended end-user. Among this effort is the work of Chen et al., [14], designed a system using the Cleveland dataset from UCI was used, with ANN as the classifier and reported accuracy of classification as 80% as well as 85% sensitivity and 70% specificity. The dataset employed is small and the accuracy could improve.
Another interface was built by [6], who designed a system using the Cleveland Heart disease dataset, random forest to rank features and used fuzzy logic for modeling, 50% correct classification accuracy was reported wish is quiet low and the dataset is also small.
[15] deployed a system which gives a yes or a no for the presence or absence of CHD respectively in the patient, when it is observed that a rampant increase in the CHD rates at juvenile ages and that it is impractical for a common man to frequently undergo costly tests like the ECG, using the Cleveland Dataset a system was designed using neural network and it gives a yes or a no for the presence or absence of CHD respectively in the patient.

MATERIALS AND METHODS
This work is based on an adapted heart disease prediction model as shown in Fig. 2 below. The model developed by Tarawneh and Embarak, [9]. The model is made up of three phases and each phase has sub-phases. The first phase is the preprocessing stage and has two sub-phases, namely: cleansing and feature engineering. The phase that follow is the classification phase which also has within it evaluation of classifiers, elimination of weak classifiers and hybridization of the best two classifiers. After which diagnosis is made.

Data Preprocessing Phase
The data preparation phase has sub-phases which include data cleansing, normalization, rebalancing and feature selection.

Data cleansing
Data cleansing is prompted because the data contain missing values and its output are supplied to the normalization sub-phase. The missing values in the data are replaced using the average of the feature that has missing values.

Scaling phase
The data used was scaled or normalized because of the variation in their ranges to improve the performance of our classifier. The technique employed in this task is the Standard Scalar. The result is then passed to the rebalancing sub-phase.

Rebalancing data
Real world datasets are characterized with imbalance class distribution; this is why this study decided to rebalance the dataset. The technique used for class rebalancing is Synthetic Minority Over-sampling Technique (SMOTE). An instance of the rebalancing function will be created and data will be passed to the initiated instance in the form of x input and y output. After which feature engineering will be carried out.

Feature engineering
Feature engineering is also carried out in the preprocessing stage to improve the accuracy of the classifier. Visha,[16] describes correlation as a statistical term, which refers to how close two variables are to having a linear relationship with each other; when two features have high correlation, we can drop one of the two features. The result of the entire preprocessing stage will serve as input in the classification phase.

Classification Phase
In this phase, the result of the preprocessing phase is supplied to different classifiers which will be evaluated to determine the best as experimented in this research. The classifiers as earlier mentioned are artificial neural network (ANN), support vector machine (SVM), k-nearest neighbor (KNN), Random forest, Naïve bayes and logistic regression.

Data Acquisition
This work is based on a dataset from a cardiovascular study on residents of the town of Framingham, Massachusetts. The goal of the study is to envisage the possibility of a patient having coronary heart disease (CHD). Even though there are other dataset with different feature that suit this study like the Cleveland CVD dataset which this work will use as the smaller dataset, but the choice of this particular dataset is born out the features making-up the dataset. It includes 4,240 records with fifteen (15) attributes the sixteenth been the target or the outcome which is if the patient will eventually have CHD or not. The dataset is publicly available in http//:kaggle.com.
The dataset includes the demographic risk factors, listed in Table 1.

Model Implementation
It is found while describing the dataset that there is an imbalance class distribution on the data set, 3596 account for healthy people while 644 are stricken with the disease.
There are also 645 missing values in the dataset which was filled by the mean of the attribute with missing value. These problems are taken care of in the preprocessing stage as explained in the subsequent sections.

Data preprocessing phase using python programming language
Python programming language was used in the implementation of this work, using the Jupyter notebook in Anaconda Environment. The data was loaded using the pandas python library in a tabular format because the data originally is in a comma separated value (CSV).Exploratory data analysis was carried out on the data to provide a better understanding of the data and its characteristics. Such analysis include; a check on size of the data with the shape()command, displaying 4240 by 16 as output. The output displayed by the describe command indicates that the data has missing values, with much variations in the range of values and is highly imbalanced.
These findings prompt the study to do the following:

Data cleansing
As observed in the exploratory stage stated above, the missing values in the data are replaced with the average of the feature that has missing values

Data normalization
The first feature added was the data scalar which was as a result of attribute values appearing in different ranges, such as stroke, bearing Boolean value 0 and 1, Level of education, bearing value between 1 and 4, age range having values between 32 and 70, glucose range having values between 40 and 394. This variation calls for normalization which ameliorates the disparity that could sway the learning algorithm. In the light of this, there's a need to scale the data to set all our values within the range of -1 and 1. Scaling of values of features will also reduce the computational complexity of the proposed system. The techniques employed in this task are the MinMax Scalar and the Standard Scalar. The data is passed to the MinMax Scalar function in the python library, which essentially shrinks the range such that the range is now between 0 and 1. The Standard Scalar on the other hand assumes your data is normally distributed within each feature and will scale the data such that the distribution is now centered on a standard deviation of 1.

Data rebalancing
Another feature added to the model is data rebalancing which became necessary due to class imbalance observed during the exploratory data analysis. The total number of sample is 4240and the class with CHD denoted by 1 is 644 while the class without CHD denoted by 0 is 3596. The techniques used for class rebalancing include NearMiss, SMOTE and Random Oversampling. These work by creating an instance of the rebalancing function and data will be passed on to the initiated instance in the form of x input and y output.

Classification Phase
The preprocessed data will serve as input into the classification phase. The Sickitlearn (sklearn) is a library in python designed ML tasks and it provides a uniform interface to ML models and there is a common pattern that can be reused across different models. The data that is coming will be divided into the training and testing data using the sklearn model_selection mudule method tain_test_split. This method takes as argument the x features, the y label and the percentage of the split. The python statement for this is shown in the following lines of code: From sklearn.model_selection import train_test_split x_train, x_test, y_train, y_test = train_test_split (x,y,test_size=0.2) The first step in classification is to import the relevant class, in this case random forest classifier is imported from sklearn.ensembles, sklearn carefully organized into modules which will make it easy to find the class needed.

From skleran. ensemble import Random Forest Classifier
The second step in the sklearn patter is to instantiate the classifier

Clf = Random Forest Classifier
At this stage the classifier was trained, here the classifier learns the relationship between the feature and the response value. The fit method is used to train the classifier and the fit method takes two arguments.

System Evaluation
The new models performance is tested using accuracy, sensitivity and precession, these metrics are further explained below.

Accuracy
In addition to the fit method, there is a score method which is used to measure the accuracy of a classifier, the score method also receive two arguments the testing input features X and the testing response value Y

Clf.score (x_test, y_test).
Sklearn's model have uniform interface which means the same steps pattern can be used on a different model with ease. To use another model simply import the mlpclassifier from the nueral network module of sklearn, instantiate the classifier, fit the model with training data and score it with testing data.

Sensitivity
Sensitivity is the ratio of correctly positive label to the entire positive class. How sensitive is the classifier to detecting positive instances. This tells when the actual value is positive how often the prediction is correct.

Precision
Precision tells when a positive value is predicted, how often is the prediction correct, it is derived by metrics. precision_score(y_test, y_pred)

RESULTS AND DISCUSSION
The adapted model was tested on the raw data Framingham dataset and the result obtained using the six earlier mentioned classifiers are shown in Table 2.
It can be observed that all the algorithms performed very well on the raw data after filling in missing values so that our classifier will be able to work. The best performance is produced by logistic regression with an accuracy of 85.8% while naïve bayes gave us the least performance of 83.3%, which is still good. The sensitivity of the classifiers is very poor with naïve bayes having the highest sensitivity of 17% and SVM gave a sensitivity of 16%. The precision is better with logistic regression producing a score as high as 71% and the least performance in term of precision as recorded by KNN with a score of 33.3%.
In all cases train test split performed better than cross validation, but after rebalancing the data cross validation produced better result with random forest, ANN and KNN.
The Cleveland dataset on the other hand, produce very good result too with the lowest performance recorded by SVM with an accuracy score 66.6% while random forest gave us a score as high as 98.1%. The sensitivity and precision are also very good, logistic regression and ANN paired with a score of 90.6% while the lowest recorded is from naïve bayes and random forest with a score of 84.3. The precision on the other hand is high as well with naïve bayes producing the best result with a score of 90.0% and the least score is 66.6% from SVM.
In comparing the Framingham dataset against Cleveland dataset, the accuracy are both high but the precision and recall of the Framingham dataset are very low. This result from the nature of class distribution of both dataset, the Framingham Dataset is an unbalance dataset while the Cleveland dataset is fair.
After rebalancing the dataset, both the sensitivity and precision of the Framingham dataset also increased. Random forest now scoring 99% and 95% respectively.  Both dataset were scaled to test the effect of scaling on the dataset, scaling in this sense is shown not to have a significant effect on the performance of the classifiers.
The Framingham dataset is characterized with imbalance class distribution which affects classifier performance negatively. Here is a result of the performance of classifiers after rebalancing the dataset. Random forest returned the best performance with an accuracy of 97.2% and a sensitivity of 99% and a precision of 95.8%.
After dropping the correlated features, sensitivity and precision increased why accuracy remain fairly the same.

CONCLUSION
Coronary heart disease which is one of the number killers of man is diagnosed in this work. Many studies that have tried to contain the disease are also reviewed. In this work, the CHD predictive system has been enhanced. The model was designed using random forest classifier which gave an accuracy of 98%, 99% recall and 95.8% precision.
This system is recommended for the poor masses who cannot afford the cost of CHD diagnosis and for those who also want to test their vulnerability to CHD. In future study, a dataset of Nigerians will be collected and used to train the classifier. The random forest can also be used to diagnose other deadly diseases as well.