Python Tutorial : Understanding credit risk

Michael Crabtree, a data scientist at Ford, explains credit risk modeling in Python. Expected loss from default equals Probability of Default times Exposure at Default times Loss Given Default. The tutorial uses a 32,000-row dataset with features like income and loan amount, then walks through exploratory analysis with pandas crosstabs and scatter plots.
Chapters
Hi, my name is Michael Crabtree and I'm a data scientist at Ford Motor Company. I will show you some concepts and techniques for credit risk modeling using Python. What exactly is credit risk? Credit risk is the risk that someone who has borrowed money will not repay it all. Think of this risk as the difference between lending money to a person and purchasing a government bond. With government bonds, it's almost guaranteed to be paid back, but not when lending money to people. A loan is in default when the lending agency is reasonably certain the loan will not be repaid. We will use machine learning models to determine this. Consider this example. We've loaned $300 to someone who has made two payments, but not the final payment. It is at this point that we consider the loan to be in default. Predicting this beforehand is useful for us to estimate expected loss. The expected loss is is the amount that the firm loses as a result of a default on a loan. Expected loss is a simple calculation of the following three the probability of default, which is the likelihood that someone will default on a loan the exposure of default, which is the amount outstanding at the time of default and the loss given default, which is the ratio of the exposure against any recovery from the loss. From our example, the $100 we were owed as our exposure and if we sell that debt for $20, our loss given default would be 80%. The formula for expected loss is probability of default times exposure at default and loss given default. This course will focus on probability of default. For modeling probability of default, we generally have two primary types of data available. The first is application data, which is data that is directly tied to the loan application like loan grade. The second is behavioral data which describes the recipient of the loan such as employment length. The data we will use for our predictions of probability of default includes a mix. This is important because application data alone is not as good as application and behavioral data. Together included are two columns which emulate data that can be purchased from credit bureaus. Acquiring external data is a common practice in most organizations. These are the columns available in the data set. Some examples are personal income, loan amounts, percentage of the person's income, and credit history length. Consider the percentage of income. This could affect loan status if the loan amount is more than their income because they may not be able to afford payments. Our data has 32,000 rows which can be difficult to see all at once. Here is where we use cross tables using the crosstab function available within pandas. We can use this function to help get a high level view of the data. Similar to PIVOT tables in Excel. Here we see that the data has been grouped by loan status and homeownership, and then the average interest rate has been calculated. In addition to using cross tables, we can explore the data set visually. Here we use matplotlib to create a scatter plot of the loan's interest rate and the recipient's income. Just like the cross table plots help us get a high level view of our data, so.
More from Richie

#359 My Best Friend is AI with Valerie Tiberius, Professor of Philosophy at University of Minnesota

How AI Agents Will Work While You Sleep | Ruslan Salakhutdinov, Professor at Carnegie Mellon

#358 How AI Agents Will Work While You Sleep | Ruslan Salakhutdinov, Professor at Carnegie Mellon







