Predict Heart Disease Application

Yolife Arvelo
June 2015

Motivation

This application is intended to help doctors in the diagnosis of Coronary Heart Disease (CHD).

Using a prediction algorithm, this application indicates whether a patient could be or not diagnosed with CHD based on several risk factors.

The prediction was based on the SAHeart dataset from the ElemStatLearn packages. A retrospective sample of males in a heart-disease high-risk region of the Western Cape, South Africa. There are roughly two controls per case of CHD.

The SAheart dataset

library(ElemStatLearn)
data(SAheart)
names(SAheart)
 [1] "sbp"       "tobacco"   "ldl"       "adiposity" "famhist"  
 [6] "typea"     "obesity"   "alcohol"   "age"       "chd"      

The algorithm

The algorithm used was prediction trees using 10-fold CV repeated 20 times. 60% of the data was used for training, 40% was used to test it.

fitControl <- trainControl(method = "repeatedcv",number = 10,repeats = 20)
rpart.grid <- expand.grid(.cp=0.005) 
train.rpart <- train(chd ~ ., data = SAheart, 
method="rpart",trControl=fitControl, tuneGrid=rpart.grid)

The algorithm

The algorithm was validated against the remaining test data obtaining 81% accuracy.

predSArp <- predict(train.rpart, testSA)
cmSArp <- confusionMatrix(testSA$chd, predSArp)
tab <- table(testSA$chd, predSArp)
rownames(tab)=c("Sample no CHD", "Sample CHD")
print(knitr::kable(tab, col.names=c("Predict no CHD", "Predict CHD")))
Predict no CHD Predict CHD
Sample no CHD 95 26
Sample CHD 11 52

The application

Very simple application, just enter the patient information and press the Predict button. alt text