Predict attrition using the credit card data, using the classification algorithm from the rpart package.
Created a new binary variable cheater by classifying observations with 0 affairs as 0, and with one or more affairs as 1. Split the data (601 observations), into training and validation data sets (70%/30% , 6,097/4,030)
Interesting how Age is perceived by many as a predictor for customers
leaving. However, the data shows that it is not a good predictor.
Using the validation data, it is observed that the model is able to:
##
##
## Cell Contents
## |-------------------------|
## | N |
## | Chi-square contribution |
## | N / Row Total |
## | N / Col Total |
## | N / Table Total |
## |-------------------------|
##
##
## Total Observations in Table: 1063
##
##
## | validation_tree$Attrition_predicted
## validation_tree$Attrition_Flag | Attrited Customer | Existing Customer | Row Total |
## -------------------------------|-------------------|-------------------|-------------------|
## Attrited Customer | 80 | 57 | 137 |
## | 385.947 | 37.003 | |
## | 0.584 | 0.416 | 0.129 |
## | 0.860 | 0.059 | |
## | 0.075 | 0.054 | |
## -------------------------------|-------------------|-------------------|-------------------|
## Existing Customer | 13 | 913 | 926 |
## | 57.100 | 5.475 | |
## | 0.014 | 0.986 | 0.871 |
## | 0.140 | 0.941 | |
## | 0.012 | 0.859 | |
## -------------------------------|-------------------|-------------------|-------------------|
## Column Total | 93 | 970 | 1063 |
## | 0.087 | 0.913 | |
## -------------------------------|-------------------|-------------------|-------------------|
##
##
## Statistics for All Table Factors
##
##
## Pearson's Chi-squared test
## ------------------------------------------------------------
## Chi^2 = 485.525 d.f. = 1 p = 1.341304e-107
##
## Pearson's Chi-squared test with Yates' continuity correction
## ------------------------------------------------------------
## Chi^2 = 478.4127 d.f. = 1 p = 4.733108e-106
##
##