Installs and Load Data

Our data has 10127 observations

It contains information on customers credit account such as demographics, account activity, and account status.

Choose Features

We will use all variables besides CLIENTNUM as this is random and has no correlation to the Attrition_Flag

We will convert the Attrition_Flag to numerical, ‘Existing Customer’ == 0, ‘Attrited Customer’ == 1

Then we will also make Education_Level, Marital_Status, Income_Category, Card_Category, and Gender factors

We are also adding a random variable inorder to use for our split

So we are using 19 predictors to predict the attrition flag (whether the account is open or closed)

#Splitting Data #### For our Training Data we will use all the observations with a random variable < .7 #### Our Validation Data we will all the observations with a random variable >= .7 #### So we will have a 70-30 train-val split #### We will be dropping the random variable from both our train and val data after doing the split

Train the Random Forest model

##                 Length Class  Mode     
## call                5  -none- call     
## type                1  -none- character
## predicted        7160  factor numeric  
## err.rate         1500  -none- numeric  
## confusion           6  -none- numeric  
## votes           14320  matrix numeric  
## oob.times        7160  -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                7160  factor numeric  
## test                0  -none- NULL     
## inbag               0  -none- NULL     
## terms               3  terms  call

Checking Attribute Importance:

We will check both %IncMSE and IncNodePurity, the higher value for both the more important that Attribute is

It seems the two most important variables, with both the highest %IncMSE and IncNodePurity, are Total_Trans_Amt and Total_Trans_Ct

Other Important variables are Total_Revolving_Bal, Total_Ct_Chng_Q4_Q1, and Total_Relationship_Count
##                          Attrited Customer Existing Customer
## Customer_Age                  0.0052572297      5.162767e-03
## Gender                        0.0067405782      8.525907e-04
## Dependent_count               0.0003784856      8.136274e-04
## Education_Level               0.0003362005      2.335779e-05
## Marital_Status                0.0002779797      1.699260e-03
## Income_Category               0.0020127583      8.372586e-04
## Card_Category                -0.0001141457      3.636128e-04
## Months_on_book                0.0043540722      1.934433e-03
## Total_Relationship_Count      0.0240353718      2.952263e-02
## Months_Inactive_12_mon        0.0218888568      4.548783e-04
## Contacts_Count_12_mon         0.0122434964      3.570336e-03
## Credit_Limit                  0.0157503456      1.599528e-02
## Total_Revolving_Bal           0.0637354185      4.847240e-02
## Avg_Open_To_Buy               0.0174417500      1.505175e-02
## Total_Amt_Chng_Q4_Q1          0.0318722859      7.980563e-03
## Total_Trans_Amt               0.1451527313      8.864380e-02
## Total_Trans_Ct                0.2349672912      9.397573e-02
## Total_Ct_Chng_Q4_Q1           0.0735490814      9.932354e-03
## Avg_Utilization_Ratio        -0.0016715800      4.041444e-02
##                          MeanDecreaseAccuracy MeanDecreaseGini
## Customer_Age                     5.179575e-03         67.77274
## Gender                           1.811743e-03         14.52756
## Dependent_count                  7.427413e-04         26.13595
## Education_Level                  7.649371e-05         39.81309
## Marital_Status                   1.464783e-03         20.10895
## Income_Category                  1.033261e-03         31.74989
## Card_Category                    2.860157e-04          5.29176
## Months_on_book                   2.330496e-03         48.09845
## Total_Relationship_Count         2.863369e-02        134.96181
## Months_Inactive_12_mon           3.944274e-03         40.66250
## Contacts_Count_12_mon            4.984285e-03         52.10328
## Credit_Limit                     1.596650e-02         65.81235
## Total_Revolving_Bal              5.095579e-02        214.11341
## Avg_Open_To_Buy                  1.543851e-02         60.88202
## Total_Amt_Chng_Q4_Q1             1.187533e-02        119.17014
## Total_Trans_Amt                  9.784650e-02        367.06223
## Total_Trans_Ct                   1.169766e-01        321.24015
## Total_Ct_Chng_Q4_Q1              2.028319e-02        209.15984
## Avg_Utilization_Ratio            3.357006e-02        120.11233

Validation Accuracy

## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  2967 
## 
##  
##                    | val$predicted_Attrition_Flag 
## val$Attrition_Flag | Attrited Customer | Existing Customer |         Row Total | 
## -------------------|-------------------|-------------------|-------------------|
##  Attrited Customer |               382 |                76 |               458 | 
##                    |          1562.055 |           256.155 |                   | 
##                    |             0.834 |             0.166 |             0.154 | 
##                    |             0.914 |             0.030 |                   | 
##                    |             0.129 |             0.026 |                   | 
## -------------------|-------------------|-------------------|-------------------|
##  Existing Customer |                36 |              2473 |              2509 | 
##                    |           285.142 |            46.759 |                   | 
##                    |             0.014 |             0.986 |             0.846 | 
##                    |             0.086 |             0.970 |                   | 
##                    |             0.012 |             0.834 |                   | 
## -------------------|-------------------|-------------------|-------------------|
##       Column Total |               418 |              2549 |              2967 | 
##                    |             0.141 |             0.859 |                   | 
## -------------------|-------------------|-------------------|-------------------|
## 
## 

Our Models accuracy on our validation data was 96%

458 I predicted are going to leave: 458 * $100 = $45,800 how much my program costs

We will save 30% of 427 = 128.1, which has a value of 2300 * 128.1 = $294,630

The net of this program is $294,630-$45,800 = $248,830 from 3089 people

Per customer is $248,830 / 3089 = $80.55