Aan de slagGa gratis aan de slag

Total expected loss

It's time to estimate the total expected loss given all your decisions. The data frame test_pred_df has the probability of default for each loan and that loan's value. Use these two values to calculate the expected loss for each loan. Then, you can sum those values and get the total expected loss.

For this exercise, you will assume that the exposure is the full value of the loan, and the loss given default is 100%. This means that a default on each the loan is a loss of the entire amount.

The data frame test_pred_df has been loaded into the workspace.

Deze oefening maakt deel uit van de cursus

Credit Risk Modeling in Python

Cursus bekijken

Oefeninstructies

  • Print the top five rows of test_pred_df.
  • Create a new column expected_loss for each loan by using the formula above.
  • Calculate the total expected loss of the entire portfolio, rounded to two decimal places, and store it as tot_exp_loss.
  • Print the total expected loss.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Print the first five rows of the data frame
print(____.head())

# Calculate the bank's expected loss and assign it to a new column
____[____] = ____[____] * ____[____] * ____[____]

# Calculate the total expected loss to two decimal places
____ = round(np.____(____[____]),2)

# Print the total expected loss
print('Total expected loss: ', '${:,.2f}'.format(____))
Code bewerken en uitvoeren