Dashboard

Decision tree Model

loans_model_HK = ctree(default ~ ., loans_train)
plot(loans_model_HK )

Loan DataTable

Decision tree Model : Output Summary

loans_model_HK
## 
## Model formula:
## default ~ fixed_assets + months_loan + credit_record + purpose + 
##     amount + savings_balance + employment + age + other_credit + 
##     housing + loans_count + job + dependents
## 
## Fitted party:
## [1] root
## |   [2] months_loan <= 33
## |   |   [3] housing in other, rent
## |   |   |   [4] credit_record in critical, poor: no (n = 122, err = 23.8%)
## |   |   |   [5] credit_record in good, perfect
## |   |   |   |   [6] credit_record in good: no (n = 229, err = 45.9%)
## |   |   |   |   [7] credit_record in perfect
## |   |   |   |   |   [8] age <= 26: yes (n = 9, err = 0.0%)
## |   |   |   |   |   [9] age > 26: yes (n = 11, err = 27.3%)
## |   |   [10] housing in own
## |   |   |   [11] employment < 1 year, unemployed
## |   |   |   |   [12] savings_balance < 0.1M HKD, 0.1 - 0.5M HKD: no (n = 165, err = 46.7%)
## |   |   |   |   [13] savings_balance > 1000 HKD, 0.5 - 1M HKD, unknown
## |   |   |   |   |   [14] amount <= 4716: no (n = 33, err = 6.1%)
## |   |   |   |   |   [15] amount > 4716: no (n = 10, err = 40.0%)
## |   |   |   [16] employment > 10 years, 1 - 3 years, 3 - 10 years: no (n = 638, err = 21.9%)
## |   [17] months_loan > 33
## |   |   [18] housing in other, rent
## |   |   |   [19] loans_count <= 1: yes (n = 62, err = 40.3%)
## |   |   |   [20] loans_count > 1: yes (n = 34, err = 8.8%)
## |   |   [21] housing in own: no (n = 187, err = 43.3%)
## 
## Number of inner nodes:    10
## Number of terminal nodes: 11

Decision tree Model : Confusion Matrix

loans_pred_HK = predict(loans_model_HK, loans_test)
HK_conft = table("prediction" = loans_pred_HK, "actual" = loans_test$default)
confusionMatrix(loans_pred_HK, loans_test$default, positive = "yes")
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction  no yes
##        no  323  95
##        yes   7  75
##                                          
##                Accuracy : 0.796          
##                  95% CI : (0.758, 0.8305)
##     No Information Rate : 0.66           
##     P-Value [Acc > NIR] : 1.522e-11      
##                                          
##                   Kappa : 0.4802         
##                                          
##  Mcnemar's Test P-Value : < 2.2e-16      
##                                          
##             Sensitivity : 0.4412         
##             Specificity : 0.9788         
##          Pos Pred Value : 0.9146         
##          Neg Pred Value : 0.7727         
##              Prevalence : 0.3400         
##          Detection Rate : 0.1500         
##    Detection Prevalence : 0.1640         
##       Balanced Accuracy : 0.7100         
##                                          
##        'Positive' Class : yes            
## 
Confusion Matrix: Test Data: Credit Default
Predicted
Actual Class
no yes
no 323 95
yes 7 75