Acceptance rate impact
Now, look at the loan_amnt of each loan to understand the impact on the portfolio for the acceptance rates. You can use cross tables with calculated values, like the average loan amount, of the new set of loans X_test. For this, you will multiply the number of each with an average loan_amnt value.
When printing these values, try formatting them as currency so that the numbers look more realistic. After all, credit risk is all about money. This is accomplished with the following code:
pd.options.display.float_format = '${:,.2f}'.format
The predictions data frame test_pred_df, which now includes the loan_amnt column from X_test, has been loaded in the workspace.
Diese Übung ist Teil des Kurses
Credit Risk Modeling in Python
Anleitung zur Übung
- Print the summary statistics of the
loan_amntcolumn using.describe(). - Calculate the average value of
loan_amntand store it asavg_loan. - Set the formatting for
pandasto'${:,.2f}' - Print the cross table of the true loan status and predicted loan status multiplying each by
avg_loan.
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
# Print the statistics of the loan amount column
print(____[____].____())
# Store the average loan amount
____ = np.____(____[____])
# Set the formatting for currency, and print the cross tab
pd.options.display.float_format = ____.format
print(pd.____(____[____],
____[____]).apply(lambda x: x * ____, axis = 0))