Objective - Predict Credit Card Attrition using the CreditCardData, using the randomforest algorithm from the randomForest package.
Data Prep - Split the data (10127 observations), into training and validation datasets (70%/30% , 7056/3071) ## Variable Importance
## Attrition_Flag Customer_Age Gender Dependent_count
## Attrited Customer:1627 Min. :26.00 Length:10127 Min. :0.000
## Existing Customer:8500 1st Qu.:41.00 Class :character 1st Qu.:1.000
## Median :46.00 Mode :character Median :2.000
## Mean :46.33 Mean :2.346
## 3rd Qu.:52.00 3rd Qu.:3.000
## Max. :73.00 Max. :5.000
## Education_Level Marital_Status Income_Category Card_Category
## Length:10127 Length:10127 Length:10127 Length:10127
## Class :character Class :character Class :character Class :character
## Mode :character Mode :character Mode :character Mode :character
##
##
##
## Months_on_book Total_Relationship_Count Months_Inactive_12_mon
## Min. :13.00 Min. :1.000 Min. :0.000
## 1st Qu.:31.00 1st Qu.:3.000 1st Qu.:2.000
## Median :36.00 Median :4.000 Median :2.000
## Mean :35.93 Mean :3.813 Mean :2.341
## 3rd Qu.:40.00 3rd Qu.:5.000 3rd Qu.:3.000
## Max. :56.00 Max. :6.000 Max. :6.000
## Contacts_Count_12_mon Credit_Limit Total_Revolving_Bal Avg_Open_To_Buy
## Min. :0.000 Min. : 1438 Min. : 0 Min. : 3
## 1st Qu.:2.000 1st Qu.: 2555 1st Qu.: 359 1st Qu.: 1324
## Median :2.000 Median : 4549 Median :1276 Median : 3474
## Mean :2.455 Mean : 8632 Mean :1163 Mean : 7469
## 3rd Qu.:3.000 3rd Qu.:11068 3rd Qu.:1784 3rd Qu.: 9859
## Max. :6.000 Max. :34516 Max. :2517 Max. :34516
## Total_Amt_Chng_Q4_Q1 Total_Trans_Amt Total_Trans_Ct Total_Ct_Chng_Q4_Q1
## Min. :0.0000 Min. : 510 Min. : 10.00 Min. :0.0000
## 1st Qu.:0.6310 1st Qu.: 2156 1st Qu.: 45.00 1st Qu.:0.5820
## Median :0.7360 Median : 3899 Median : 67.00 Median :0.7020
## Mean :0.7599 Mean : 4404 Mean : 64.86 Mean :0.7122
## 3rd Qu.:0.8590 3rd Qu.: 4741 3rd Qu.: 81.00 3rd Qu.:0.8180
## Max. :3.3970 Max. :18484 Max. :139.00 Max. :3.7140
## Avg_Utilization_Ratio random
## Min. :0.0000 Min. :0.0000653
## 1st Qu.:0.0230 1st Qu.:0.2531897
## Median :0.1760 Median :0.4945483
## Mean :0.2749 Mean :0.4976151
## 3rd Qu.:0.5030 3rd Qu.:0.7433762
## Max. :0.9990 Max. :0.9999414
## Length Class Mode
## call 5 -none- call
## type 1 -none- character
## predicted 7137 factor numeric
## err.rate 1500 -none- numeric
## confusion 6 -none- numeric
## votes 14274 matrix numeric
## oob.times 7137 -none- numeric
## classes 2 -none- character
## importance 76 -none- numeric
## importanceSD 57 -none- numeric
## localImportance 0 -none- NULL
## proximity 0 -none- NULL
## ntree 1 -none- numeric
## mtry 1 -none- numeric
## forest 14 -none- list
## y 7137 factor numeric
## test 0 -none- NULL
## inbag 0 -none- NULL
## terms 3 terms call
## Attrited Customer Existing Customer
## Customer_Age 5.209985e-03 6.094077e-03
## Gender 7.313003e-03 1.050486e-03
## Dependent_count 8.890636e-04 8.196618e-04
## Education_Level -3.731033e-04 7.107129e-05
## Marital_Status -4.743139e-05 9.398317e-04
## Income_Category 1.472442e-03 5.298416e-04
## Card_Category 1.613177e-04 2.556012e-04
## Months_on_book 3.570180e-03 2.290269e-03
## Total_Relationship_Count 2.606469e-02 2.888278e-02
## Months_Inactive_12_mon 2.732083e-02 7.274292e-04
## Contacts_Count_12_mon 1.387470e-02 2.967741e-03
## Credit_Limit 1.612998e-02 1.624175e-02
## Total_Revolving_Bal 6.787425e-02 4.908643e-02
## Avg_Open_To_Buy 1.733587e-02 1.511753e-02
## Total_Amt_Chng_Q4_Q1 2.983933e-02 6.599926e-03
## Total_Trans_Amt 1.383110e-01 9.154042e-02
## Total_Trans_Ct 2.341558e-01 9.172821e-02
## Total_Ct_Chng_Q4_Q1 7.547071e-02 1.301618e-02
## Avg_Utilization_Ratio 3.346788e-03 4.282685e-02
## MeanDecreaseAccuracy MeanDecreaseGini
## Customer_Age 5.952204e-03 67.721214
## Gender 2.053355e-03 18.069709
## Dependent_count 8.330205e-04 24.588289
## Education_Level 1.388215e-06 21.780988
## Marital_Status 7.823934e-04 17.076899
## Income_Category 6.797281e-04 21.518866
## Card_Category 2.401003e-04 4.815106
## Months_on_book 2.494116e-03 49.250601
## Total_Relationship_Count 2.842153e-02 133.535542
## Months_Inactive_12_mon 4.986729e-03 43.963740
## Contacts_Count_12_mon 4.711278e-03 51.677818
## Credit_Limit 1.623010e-02 64.893698
## Total_Revolving_Bal 5.206934e-02 209.671243
## Avg_Open_To_Buy 1.548509e-02 62.401374
## Total_Amt_Chng_Q4_Q1 1.031662e-02 113.757505
## Total_Trans_Amt 9.902120e-02 373.709407
## Total_Trans_Ct 1.145100e-01 325.790686
## Total_Ct_Chng_Q4_Q1 2.300351e-02 198.494462
## Avg_Utilization_Ratio 3.650621e-02 122.768449
## Attrited Customer Existing Customer class.error
## Attrited Customer 939 206 0.17991266
## Existing Customer 78 5914 0.01301736
##
##
## Cell Contents
## |-------------------------|
## | N |
## | Chi-square contribution |
## | N / Row Total |
## | N / Col Total |
## | N / Table Total |
## |-------------------------|
##
##
## Total Observations in Table: 2990
##
##
## | val$predicted_Attrition_Flag
## val$Attrition_Flag | Attrited Customer | Existing Customer | Row Total |
## -------------------|-------------------|-------------------|-------------------|
## Attrited Customer | 392 | 90 | 482 |
## | 1558.549 | 253.999 | |
## | 0.813 | 0.187 | 0.161 |
## | 0.936 | 0.035 | |
## | 0.131 | 0.030 | |
## -------------------|-------------------|-------------------|-------------------|
## Existing Customer | 27 | 2481 | 2508 |
## | 299.530 | 48.815 | |
## | 0.011 | 0.989 | 0.839 |
## | 0.064 | 0.965 | |
## | 0.009 | 0.830 | |
## -------------------|-------------------|-------------------|-------------------|
## Column Total | 419 | 2571 | 2990 |
## | 0.140 | 0.860 | |
## -------------------|-------------------|-------------------|-------------------|
##
##
Model Accuracy - Using the validation data, it is observed that the model can:
Financial Impact - We offered to forgive 419 annual fees at $100 each (419 x $100 = $41900) - 27 customers of the 419 were going to stay anyway. However, using our customer retention program we can keep 30% of the 392 customers that will actually leave - This means that we will convince 118 customers to stay (30% x 392) - The company makes $2300 per customer so through the retention program we keep $271400 (118 x $2300 = $271400) - We net $229500 ($271400 - $41900) - So for every 2990 customers we generate $229500 - We save approximately $77 per customer