top of page
NNhead.png

Neural Network for Heart Attack Survival

Neural Network with PCA: Welcome

This analysis will use a neural network to predict the survival of heart attack patients admitted to the hospital. Rather than focusing on the attributes (previously done with Naïve Bayes Classification), the emphasis of this analysis will be on the accuracy of predictions of the outcome (living or deceased). The ability to correctly predict the survivability of patients can provide valuable information regarding how critical the patient may be at admission and aid in identifying which courses of action are most appropriate for individual patients.

​

The same data set used for the Naive Bayes Classification study was used in the neural network. Exploratory analysis and data descriptions can be seen by using the link below.

Neural Network with PCA: Text

Principal Component Analysis (PCA)

A new data set was created using PCA (DS1).  Principal component 1 (PC1) accounts for 43.6 of the data variance.

​

Together PC1 and PC2 explain just over 60% of the variance. The ellipses enclose the largest proportion of each outcome, alive and dead. The arrows representing an increase show that higher cpk and year are associated with survival. Increased length of stay, miord, and age are associated with not surviving.


96.4% of variance is explained by PC1 through PC7. 99.1% of variance is explained by PC1 through PC8. For this analysis PC1 through PC7 were used to create DS2.


Principal components are referred to by their number, PC1 through PC9.


MIORD is a binary variable where 1 indicates the patient was admitted for a heart attack that was not their first.

​

​

Neural Network with PCA: Image
Neural Network with PCA: Pro Gallery

Method

The activation function used in this analysis was a binary sigmoid function with values from 0 to 1.  Logistic regression was used by specifying linear.output = FALSE during network creation. The error function used to calculate error was the sum of squared errors. For each data set, the method was run multiple times with varying numbers of hidden layers and neurons. First, each network was created with one hidden layer, employing 2, 6, or 10 neurons. Next, two hidden layers were created with the first hidden layer having 10 neurons and the second hidden layer having 2, 6, or 10 neurons.

NNhead.png
Neural Network with PCA: Image

Comparison of Model Accuracy

The results were slightly higher for some networks including the single hidden layer 2 neuron network (80.5%) and the two hidden layer networks with 6 and 10 neurons (98%). Accuracy for all networks created is shown in Figure 8. Increasing the number of neurons improved accuracy as did increase the number of hidden layers. Performing principal component analysis did result in slightly higher accuracy, but all DS1 and DS2 networks improved similarly when hidden layers and neurons were increased.


Based on each network’s accuracy, the network which used DS2 (PC1 through PC8) having two hidden layers with ten neurons in each hidden layer was selected as the most accurate network.

NN8.png
Neural Network with PCA: Image
nn10.png

Layers and neurons

The neural network was modeled using DS2 and has two hidden layers with ten neurons each.

​

Each principal component was added to the network through an input neuron (I1 through I8)[1] before moving through each hidden layer (H1 through H10, in each layer) to the output neuron (O1). Positive weights added between neurons are shown in blue and negative weights are shown in red. The strength of the weights is represented by line thickness. The largest positive weight (181.4) was added to the output of neuron 6 in hidden layer two before being input to hidden layer 2, neuron 10. The greatest negative weight (-129.1) was added to hidden layer 1, neuron 2 before being input to hidden layer 2, neuron 8.

Neural Network with PCA: Image

Results

The accuracy when the network was used to predict patient survival using the test data was 97.2%. The confusion matrix shows four false negatives, 63 true positives, and 77 true negatives. The network had 100% sensitivity (true positive rate) and 94.0 % specificity (true negative rate). The misclassification rate is 2.8%. The high accuracy is reflected in the kappa score of .944. 

           

PC6 and PC8 had the strongest negative and positive relationships with the dependent variable. PC5 had the least importance for predicting patient survival. The influence of these variables was unexpected because of the high percentage of variance explained by PC1.

Neural Network with PCA: Text

617-751-2800

©2021 by Laura Ellis. Proudly created with Wix.com

bottom of page