## Table 4.1: 
cv_mod1 <- caret::train(
  default ~ balance,
  data = churn_train,
  method = "glm",
  family = "binomial",
  trControl = trainControl(method = "cv", number = 10)
)

pred_class <- predict(cv_mod1, churn_train)
confusionMatrix(
  data = relevel(pred_class, ref = "Yes"),
  reference = relevel(churn_train$default, ref = "Yes")
)
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction  Yes   No
##        Yes   71   30
##        No   159 6740
##                                           
##                Accuracy : 0.973           
##                  95% CI : (0.9689, 0.9767)
##     No Information Rate : 0.9671          
##     P-Value [Acc > NIR] : 0.002652        
##                                           
##                   Kappa : 0.4173          
##                                           
##  Mcnemar's Test P-Value : < 2.2e-16       
##                                           
##             Sensitivity : 0.30870         
##             Specificity : 0.99557         
##          Pos Pred Value : 0.70297         
##          Neg Pred Value : 0.97695         
##              Prevalence : 0.03286         
##          Detection Rate : 0.01014         
##    Detection Prevalence : 0.01443         
##       Balanced Accuracy : 0.65213         
##                                           
##        'Positive' Class : Yes             
## 
## Table 4.2: 
cv_mod2 <- caret::train(
  default ~ balance + student,
  data = churn_train,
  method = "glm",
  family = "binomial",
  trControl = trainControl(method = "cv", number = 10)
)

pred_class <- predict(cv_mod2, churn_train)
confusionMatrix(
  data = relevel(pred_class, ref = "Yes"),
  reference = relevel(churn_train$default, ref = "Yes")
)
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction  Yes   No
##        Yes   76   30
##        No   154 6740
##                                           
##                Accuracy : 0.9737          
##                  95% CI : (0.9697, 0.9773)
##     No Information Rate : 0.9671          
##     P-Value [Acc > NIR] : 0.0008272       
##                                           
##                   Kappa : 0.4408          
##                                           
##  Mcnemar's Test P-Value : < 2.2e-16       
##                                           
##             Sensitivity : 0.33043         
##             Specificity : 0.99557         
##          Pos Pred Value : 0.71698         
##          Neg Pred Value : 0.97766         
##              Prevalence : 0.03286         
##          Detection Rate : 0.01086         
##    Detection Prevalence : 0.01514         
##       Balanced Accuracy : 0.66300         
##                                           
##        'Positive' Class : Yes             
## 
## Table 4.3: 
cv_mod3 <- caret::train(
  default ~ balance + income + student,
  data = churn_train,
  method = "glm",
  family = "binomial",
  trControl = trainControl(method = "cv", number = 10)
)

pred_class <- predict(cv_mod3, churn_train)
confusionMatrix(
  data = relevel(pred_class, ref = "Yes"),
  reference = relevel(churn_train$default, ref = "Yes")
)
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction  Yes   No
##        Yes   76   30
##        No   154 6740
##                                           
##                Accuracy : 0.9737          
##                  95% CI : (0.9697, 0.9773)
##     No Information Rate : 0.9671          
##     P-Value [Acc > NIR] : 0.0008272       
##                                           
##                   Kappa : 0.4408          
##                                           
##  Mcnemar's Test P-Value : < 2.2e-16       
##                                           
##             Sensitivity : 0.33043         
##             Specificity : 0.99557         
##          Pos Pred Value : 0.71698         
##          Neg Pred Value : 0.97766         
##              Prevalence : 0.03286         
##          Detection Rate : 0.01086         
##    Detection Prevalence : 0.01514         
##       Balanced Accuracy : 0.66300         
##                                           
##        'Positive' Class : Yes             
## 
## Accuracy
summary(
  resamples(
    list(
      Table1model = cv_mod1,
      Table2model = cv_mod2,
      Table3model = cv_mod3
    )
  )
)
## 
## Call:
## summary.resamples(object = resamples(list(Table1model = cv_mod1, Table2model
##  = cv_mod2, Table3model = cv_mod3)))
## 
## Models: Table1model, Table2model, Table3model 
## Number of resamples: 10 
## 
## Accuracy 
##                  Min.   1st Qu.    Median      Mean   3rd Qu.      Max. NA's
## Table1model 0.9642857 0.9717857 0.9735714 0.9731429 0.9753571 0.9800000    0
## Table2model 0.9671429 0.9714286 0.9735714 0.9737143 0.9757143 0.9800000    0
## Table3model 0.9685714 0.9717857 0.9728571 0.9735714 0.9764286 0.9785714    0
## 
## Kappa 
##                  Min.   1st Qu.    Median      Mean   3rd Qu.      Max. NA's
## Table1model 0.1796362 0.3665542 0.4385241 0.4177551 0.4844803 0.5542618    0
## Table2model 0.2452653 0.4023762 0.4305530 0.4367752 0.5071568 0.6016584    0
## Table3model 0.3108944 0.3482950 0.4176434 0.4326191 0.5323200 0.5677345    0

A likely conclusion is we get a slight increase in accuracy, although I’m not sure my code is right since I wasn’t able to implement the dummy splitting for the student feature. I also wasn’t able to implement the ROC curve in R for some reason.