Session Ready
Exercise

Computing a bad rate given a fixed acceptance rate

In the video, you learned how to compute the bad rate (or, the percentage of defaults) in the loan portfolio of a bank when given:

  1. a specific model
  2. the acceptance rate

In this exercise, you will compute the bad rate that a bank can expect when using the pruned tree ptree_prior that you fitted before, and an acceptance rate of 80%. As a reminder, the tree is plotted on your right hand side.

Instructions
100 XP
  • In the script, you are provided the code to make predictions for the probability of default using the pruned tree and test_set. Remember that if you use the predict() function for a tree, the probability of default can be found in the second column. Therefore [,2] was pasted to the predict() function.
  • Obtain the cut-off that leads to an acceptance rate of 80%, using prob_default_prior. You can use the quantile()- function to do this, setting the second argument to 0.8. Assign the name cutoff_prior.
  • The code to obtain the actual binary default predictions (0 or 1) is provided. ifelse() here. Name the object bin_pred_prior_80.
  • The code to select the default indicators of test_set for the accepted loans acording to a 80% acceptance rate is provided.
  • Compute the percentage of defaults (or the "bad rate") for the accepted loans. This is the number of occurences of 1 in accepted_status_prior_80, divided by the total number of instances in this vector. Print the solution to your R-console.