MulaiMulai sekarang secara gratis

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.

Latihan ini adalah bagian dari kursus

Credit Risk Modeling in Python

Lihat Kursus

Petunjuk latihan

  • Print the summary statistics of the loan_amnt column using .describe().
  • Calculate the average value of loan_amnt and store it as avg_loan.
  • Set the formatting for pandas to '${:,.2f}'
  • Print the cross table of the true loan status and predicted loan status multiplying each by avg_loan.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# 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))
Edit dan Jalankan Kode