LoslegenKostenlos loslegen

Acceptance rates

Setting an acceptance rate and calculating the threshold for that rate can be used to set the percentage of new loans you want to accept. For this exercise, assume the test data is a fresh batch of new loans. You will need to use the quantile() function from numpy to calculate the threshold.

The threshold should be used to assign new loan_status values. Does the number of defaults and non-defaults in the data change?

The trained model clf_gbt and the data frame of it's predictions, test_pred_df, are available.

Diese Übung ist Teil des Kurses

Credit Risk Modeling in Python

Kurs anzeigen

Anleitung zur Übung

  • Print the summary statistics of prob_default within the data frame of predictions using .describe().
  • Calculate the threshold for a 85% acceptance rate using quantile() and store it as threshold_85.
  • Create a new column called pred_loan_status based on threshold_85.
  • Print the value counts of the new values in pred_loan_status.

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

# Check the statistics of the probabilities of default
print(____[____].describe())

# Calculate the threshold for a 85% acceptance rate
____ = np.____(____['prob_default'], ____)

# Apply acceptance rate threshold
____[____] = ____[____].apply(lambda x: 1 if x > ____ else 0)

# Print the counts of loan status after the threshold
print(____[____].____())
Code bearbeiten und ausführen