No history yet

Data Engineering for Risk

The Bedrock of Modelling

Before any credit risk model can be built, we must first construct its foundation: the development sample. This isn't just a raw data dump. It's a carefully curated, historical snapshot of borrower behaviour, structured specifically for training and validating models that predict Probability of Default (PD), Loss Given Default (LGD), and Exposure at Default (EAD).

The primary challenge is creating a clean, reliable dataset from high-dimensional, often messy, banking data. Two critical hurdles stand out. The first is avoiding , where information from the future accidentally contaminates the training data, leading to a model that looks brilliant in testing but fails miserably in the real world. For example, using a borrower's final loan status (which is only known at the end of the observation period) to predict their likelihood of default at the beginning of that period.

The second is ensuring the definition of 'Default' is consistent. A default event must be defined precisely and applied uniformly across all data sources. Does it mean 90 days past due? A bankruptcy filing? A loan write-off? This definition, often dictated by regulations like Basel III, must be locked down before any data is assembled. Without this alignment, the model's target is a moving one, rendering its predictions meaningless.

The goal of creating a development sample is to build a time machine: a dataset that lets your model 'see' the past exactly as it was, without any hints about the future.

Shaping the Variables

Raw variables, like a customer's exact income or age, often have complex, non-linear relationships with default risk. A 25-year-old and a 65-year-old might both be low-risk, while a 40-year-old is higher risk. A simple linear model can't capture this U-shaped pattern. Furthermore, extreme outliers, like a CEO with an eight-figure salary, can disproportionately skew the model. To handle this, we transform continuous variables into categorical bins through a process called classing.

Fine Classing is the first step. We slice a continuous variable into many narrow bins, often 20 to 50 of them. For an 'age' variable, this might mean bins for 18-20, 21-23, and so on. This detailed breakdown helps us spot trends and non-linear patterns in the data without losing too much information.

Next comes Coarse Classing. We examine the finely classed bins and group them into a smaller number of broader, more meaningful categories. We might combine the age groups of 18-25 into a 'Young Adult' category and 60-75 into a 'Pre-Retirement' category. The goal is to create bins where the default rate within each bin is distinct from the others. This process simultaneously manages outliers (by grouping them into a top-level bin) and simplifies the variable for the model.

Customer AgeFine Class BinsCoarse Class BinsDefault Rate
2221-2318-29 (Young Pro)3.1%
2827-2918-29 (Young Pro)3.1%
4545-4730-55 (Mid-Career)5.8%
5251-5330-55 (Mid-Career)5.8%
6866-6856+ (Established)2.5%

This binning process also provides a structured way to handle missing data. We can simply create a dedicated 'Missing' bin for records where the value is unknown. This allows the model to learn the specific risk profile associated with having missing information, which is often predictive in itself.

Measuring Predictive Power

After coarse classing, we have a set of categorical variables. But logistic regression models require numerical inputs. This is where Weight of Evidence (WoE) comes in. WoE replaces each category bin with a single numerical value that represents the strength of that category in predicting default.

Specifically, the WoE value for a category is the natural logarithm of the ratio of non-defaulters to defaulters in that category. A positive WoE value means the category has more 'good' outcomes (non-defaults) than the overall average, suggesting lower risk. A negative value means it has more 'bad' outcomes, suggesting higher risk. This transformation elegantly linearises the relationship between the binned variable and the of default, making it perfect for a logistic regression model.

WoEi=ln(% of non-events in bin i% of events in bin i)WoE_i = \ln \left( \frac{\% \text{ of non-events in bin } i}{\% \text{ of events in bin } i} \right)

With our variables transformed by WoE, we can now assess their predictive strength using Information Value (IV). The IV for a single variable is a sum of the WoE values for each of its bins, weighted by the difference in the proportion of non-defaulters and defaulters in each bin. The result is a single number that summarises the variable's power to separate good customers from bad.

IV provides a simple, powerful heuristic for variable screening:

Information Value (IV)Predictive Power
< 0.02Useless
0.02 to 0.1Weak
0.1 to 0.3Medium
0.3 to 0.5Strong
> 0.5Suspicious

An IV greater than 0.5 is often a red flag. It can indicate a variable that is too good to be true, possibly due to data leakage or a definitional issue. By calculating the IV for every potential variable, we can quickly filter out the useless ones, identify the most promising candidates, and check for multicollinearity before ever starting to build the model itself. This rigorous preparation is what separates a fragile, unreliable model from a robust, regulatory-compliant one.

Quiz Questions 1/6

In the context of building a credit risk model, what is the primary danger of "data leakage"?

Quiz Questions 2/6

Before building a development sample, it is acceptable for the definition of a 'default event' to vary across different data sources as long as the model can identify the pattern.