top of page

PREDICTING
PROBABILITY OF ATTRITION
MODEL VALIDATION
CROSS-VALIDATION
We use 10-fold cross validation to validate our models.
R Code:
f#Cross Validation for full model
library(boot)
cost <- function(Attrition,pi=0)
{
mean(abs(Attrition-pi)>0.5)
}
HR.glm<-glm(Attrition~.,binomial,data=HR)
(cv.err<-cv.glm(HR,HR.glm,cost,K=10)$delta[1])
[1] 0.1340136
backwd.glm<-glm(Attrition~.,binomial,data=HR)
(cv.err<-cv.glm(HR,backwd.glm,cost,K=10)$delta[1])
[1] 0.129932
The result shows that the model obtained by backward selection is associated with the lowest cross validation error and hence we will be using the full model for our prediction.
bottom of page