Anoop Swarup
June 15, 2018
Project for Coursera “Developing Data Products” Course
Enter some data on the risk factors:
Then you are given an estimate of a Coronary Heart Disease (CHD) risk. In subsequent slides we describe the model for this web-based Shiny App.
fit <- glm(factor(chd) ~ ., data=SAheart, family = binomial)
Results from this model gave us the significant predictor variables to be used in our model for Shiny App. Those are: tobacco, ldl, famhist, typea, and age.
We partitioned the 'SAheart' data into training (70%) and test (30%) datasets. The model was then built on the training dataset, and tested on the test dataset.
Model built using the caret package:
modFit <- train(chd ~ age + tobacco + typea + ldl + famhist, method = "glm", family="binomial", data = trainSA)
testing_prediction <- predict(modFit, testSA)
confMat <- confusionMatrix(testSA$chd, testing_prediction)
paste("Prediction accuracy - test:", round(confMat$overall["Accuracy"], 2))
[1] "Prediction accuracy - test: 0.7"
The model achieved accuracy of 77% on the training dataset, and 70% on the test dataset.
https://alphasig.shinyapps.io/HeartPredict/