Lesson 5.4: Weight of evidence for a continuous target
Extend binning, WoE and IV to continuous outcomes like loss given default: bin means, fractional WoE, exposure weights, skewed targets and noise.
By the end of this lesson you will be able to bin a predictor against a target that is a number, such as the share of a defaulted loan that was lost, and compute a weight of evidence and an information value for it. You will meet two ways of doing so: replacing each bin by its average target, and a fractional version of WoE that treats each loan as partly good and partly bad. You will see how to weight by exposure so that large loans count for more, how to handle targets that are skewed or unbounded, and how to judge the noise in a bin average. You should have read Lessons 5.1 to 5.3, and Lesson 3.1, which defined loss given default. The arithmetic is the same shares and logarithms as before, and all calculations here are worked out in full.
Lessons 5.1 to 5.3 assumed that every loan ends as either good or bad. That is the right frame for the probability of default, and it is the frame in which weight of evidence was born. But credit risk has more than one target. When a borrower defaults, the loss is not yes or no: the lender may lose 12 per cent of the balance on one loan and 80 per cent on another. The loss given default model needs predictors, and those predictors need bins just as the default model does. So do the models for exposure at default, the share of a credit line drawn at default, and the time to recover. All of these targets are continuous, and the good-or-bad version of WoE does not apply directly.
The problem
Suppose you have 2,000 defaulted secured loans and want to predict loss given default (LGD) from the loan-to-value ratio, or LTV: the loan amount divided by the value of the asset at the time the loan was made. A loan of ₹80 lakh against a flat valued at ₹1 crore has an LTV of 80 per cent. A higher LTV leaves less cushion, so recoveries should be lower and LGD higher.
You could turn the target into a yes or no by choosing a cut-off, saying a loan is "bad" if its LGD exceeds 50 per cent. This is simple and it throws away most of the information. A loan with an LGD of 49 per cent would be good and one with 51 per cent would be bad, though they are nearly identical, and a loan that lost 100 per cent would count the same as one that lost 51 per cent. The better route is to keep the target as it is.
Approach one: the average target in each bin
The simplest idea is to cut the predictor into bins as before and compute the average LGD in each bin. This is called bin-mean or target encoding. Here are the results for the LTV variable, with bins chosen by the rules of Lesson 5.1.
LTV bin · Loans · Average LGD · Lift on the overall averageUp to 60% · 400 · 12% · 0.42
60% to 80% · 800 · 22% · 0.76
80% to 100% · 600 · 38% · 1.32
Above 100% · 200 · 62% · 2.15
All loans · 2,000 · 28.8% · 1.00
The overall average is the loan-weighted mean of the bin averages: (400 × 12% + 800 × 22% + 600 × 38% + 200 × 62%) ÷ 2,000 = (48 + 176 + 228 + 124) ÷ 2,000 = 576 ÷ 2,000 = 28.8 per cent. The lift divides each bin's average by the overall average: 12 ÷ 28.8 = 0.42, and 62 ÷ 28.8 = 2.15. A loan with an LTV above 100 per cent loses, on average, more than twice as much as a typical defaulted loan, and one below 60 per cent loses well under half as much.
Bin averages are easy to compute and easy to explain, and they are a good first look. As a model input they have a drawback: they live on the scale of the target (a percentage from 0 to 100) and have no common scale with the other variables of a scorecard. For this reason, many practitioners prefer to convert them to a log-odds measure, as they did for the default model.
Approach two: fractional weight of evidence
The idea is to treat every loan as part bad and part good. A loan with an LGD of 62 per cent counts as 0.62 of a "bad" (the part of the balance that was lost) and 0.38 of a "good" (the part that was recovered). With this device, the machinery of Lesson 5.2 works unchanged, because the totals of "bad weight" and "good weight" can be computed just as the counts of bads and goods were.
For the 2,000 loans, assume for the moment that every loan has the same exposure, so each counts the same.
Total bad weight: the sum of LGDs = 576 loan-equivalents (from 48 + 176 + 228 + 124).
Total good weight: 2,000 − 576 = 1,424.
Now compute the weight of evidence for each bin.
LTV bin · Bad weight · Good weight · Share of all bad weight · Share of all good weight · WoEUp to 60% · 48 · 352 · 8.33% · 24.72% · +1.087
60% to 80% · 176 · 624 · 30.56% · 43.82% · +0.361
80% to 100% · 228 · 372 · 39.58% · 26.12% · −0.416
Above 100% · 124 · 76 · 21.53% · 5.34% · −1.395
Total · 576 · 1,424 · 100% · 100% ·
The working for the top bin: bad weight 200 × 0.62 = 124, good weight 200 × 0.38 = 76; share of bad weight 124 ÷ 576 = 0.2153; share of good weight 76 ÷ 1,424 = 0.0534; ratio 0.0534 ÷ 0.2153 = 0.248; ln(0.248) = −1.395.
The interpretation carries over from Lesson 5.2. A positive WoE means the bin has a smaller share of the losses than of the recoveries, so it is better than average for the lender. A negative WoE means the bin accounts for more of the losses than of the recoveries. Above 100 per cent LTV, the loans are 10 per cent of the sample and recover only 5.3 per cent of the good weight, but account for 21.5 per cent of the loss. The information value is computed in the same way:
> IV = sum of (share of good weight − share of bad weight) × WoE
> = 0.1639 × 1.087 + 0.1326 × 0.361 + (−0.1346) × (−0.416) + (−0.1619) × (−1.395)
> = 0.1782 + 0.0479 + 0.0560 + 0.2258 = 0.508
On the scale of Lesson 5.3, an IV above 0.5 is suspiciously strong for a default model, but for a loss given default model the same scale is less informative. Loan-to-value is known to be the most important driver of recoveries on secured loans, and IV values for the leading LGD predictors are typically higher than for default predictors. A reviewer would still ask the questions of Lesson 5.3: is the LTV measured at origination or at default, and is the asset value an independent appraisal?
Predict first: suppose the average LGD in a bin happened to equal the overall average of 28.8 per cent. What would its fractional WoE be? Decide before reading on.
It would be zero. A bin whose average LGD equals the overall average holds the same share of bad weight as of good weight, so the ratio is one and ln(1) = 0. That is the same dividing line as before: positive means better than the average defaulted loan, negative means worse.
Weighting by exposure
The calculation above treated every loan alike. In a loss model the amount at stake matters: a 60 per cent loss on ₹1 crore matters more than a 60 per cent loss on ₹5 lakh. The natural fix is to weight each loan by its exposure at default, so that a rupee of exposure counts equally wherever it sits.
Assume the loans in the four bins have the following average exposures.
LTV bin · Loans · Average exposure · Total exposure · Average LGDUp to 60% · 400 · ₹10 lakh · ₹40 crore · 12%
60% to 80% · 800 · ₹10 lakh · ₹80 crore · 22%
80% to 100% · 600 · ₹12 lakh · ₹72 crore · 38%
Above 100% · 200 · ₹20 lakh · ₹40 crore · 62%
All · 2,000 · · ₹232 crore ·
The exposure-weighted overall LGD is (40 × 12% + 80 × 22% + 72 × 38% + 40 × 62%) ÷ 232 = (4.80 + 17.60 + 27.36 + 24.80) ÷ 232 = 74.56 ÷ 232 = 32.1 per cent, higher than the 28.8 per cent from counting loans. The reason is that the loans with the highest LGD are also the largest. Money-weighted, the portfolio loses more than loan-weighted.
Now redo the weight of evidence with money as the weight: bad weight is exposure times LGD, good weight is exposure times (1 − LGD). The totals are 74.56 and 157.44 crore.
LTV bin · WoE by loan count · WoE by exposureUp to 60% · +1.087 · +1.245
60% to 80% · +0.361 · +0.518
80% to 100% · −0.416 · −0.258
Above 100% · −1.395 · −1.237
The information value on the exposure-weighted basis is 0.595, against 0.508 on the loan-count basis. Weighting by money raises the IV here because the worst bin, which is also the one with the largest loans, accounts for a larger share of the rupee loss. Which basis to use depends on the question. For a model that will set capital or provisions, which are rupee amounts, the exposure-weighted version is the right one. For the experience of a typical borrower or a collections team that works loan by loan, loan counts are more natural. Say which basis you used.
When the target is skewed or unbounded
LGD is convenient because it lies between 0 and 1 (though in practice some data show recoveries above the balance or costs that push LGD slightly past 100 per cent). Other continuous targets are not so tidy.
Loss amounts in rupees have no upper bound and are heavily skewed: many small losses and a few huge ones. A raw average is dominated by the extremes. Options include capping at a high percentile (winsorising), taking logarithms, using the median in each bin, or dividing by exposure to turn the target into a rate.
Exposure at default and credit conversion factors. For lines of credit that can still be drawn, the target is the share of the undrawn limit that is drawn by the time of default. It lies between 0 and 1 for most borrowers and the fractional approach applies directly.
Time to recovery or time to default. These are durations and are often incomplete, because many loans have not yet recovered or defaulted. Survival methods are the right tool. A rough binning can still use the average duration of completed cases, with the caveat that it understates the true time.
Zero-heavy and two-humped targets. LGD data often pile up at zero (full recovery) and at 100 per cent (nothing recovered), with a thin spread in between. The average hides this shape. Look at the distribution within each bin, and consider modelling in two stages: first the chance of any loss, then the size given a loss. Fractional WoE still works, but the interpretation needs care.
How much noise is in a bin average?
Every bin average is an estimate from a finite number of loans. For a target that varies a lot, the estimate is noisy. The standard error of a bin's average is the standard deviation of the target within the bin divided by the square root of the number of loans.
The top bin has 200 loans, an average LGD of 62 per cent, and suppose the standard deviation of LGD among them is 35 percentage points, which is typical of a spread-out target. The standard error is 35 ÷ √200 = 35 ÷ 14.14 = 2.5 points, so a 95 per cent range is 62 ± 4.9 points, or about 57 to 67 per cent. That is acceptable, and it separates this bin from the next one at 38 per cent. A bin of 40 loans would have a standard error of 35 ÷ √40 = 5.5 points and a range of ±10.9 points. The rules of Lesson 5.1 about bin size therefore carry over, but the quantity that matters is the number of loans, not the total weight: a bin that holds ₹40 crore in two very large loans is much less reliable than one with 200 small loans, even though the money is the same. Count loans when judging precision.
In Python
The weighted calculation is a short extension of the earlier code. The target lgd is a fraction between 0 and 1, and ead is the exposure.
python
import numpy as np
import pandas as pd
df = pd.readcsv("defaultedloans.csv") # columns: ltv, lgd (0 to 1), ead
edges = [-np.inf, 60, 80, 100, np.inf]
labels = ["<=60", "60-80", "80-100", ">100"]
df["bin"] = pd.cut(df["ltv"], edges, labels=labels, right=True)
df["badw"] = df["ead"] df["lgd"] # money lost
df["goodw"] = df["ead"] (1 - df["lgd"]) # money recovered
t = df.groupby("bin", observed=True).agg(
loans=("lgd", "count"), ead=("ead", "sum"),
badw=("badw", "sum"), goodw=("goodw", "sum"),
lgdsd=("lgd", "std"))
t["avglgd"] = t["badw"] / t["ead"] 100 # exposure-weighted
t["distbad"] = t["badw"] / t["badw"].sum()
t["distgood"] = t["goodw"] / t["goodw"].sum()
t["woe"] = np.log(t["distgood"] / t["distbad"])
t["iv"] = (t["distgood"] - t["distbad"]) t["woe"]
t["stderrpts"] = t["lgdsd"] / np.sqrt(t["loans"]) 100
print(t.round(3))
print("IV:", round(t["iv"].sum(), 3))
To get the loan-count version, set ead to 1 for every loan. The stderrpts column carries the precision of each bin, so you can see at a glance which bins are too thin. As with the default model, save the table, since the same mapping from bin to WoE must be applied to every future loan.
A worked example: picking a binning for LTV
An analyst is given the LTV data and told to propose bins. She starts with ten equal-frequency bins and finds that the average LGD runs 9, 11, 14, 17, 21, 26, 31, 40, 55 and 61 per cent from the lowest to the highest LTV decile. The sequence rises steadily, so she can merge neighbours confidently. She tests the gaps between bins against their standard errors, each about 2 to 3 points.
Bins 1 and 2 (9 and 11 per cent) are 2 points apart, within the noise. Merge.
Bins 3 and 4 (14 and 17) are 3 points apart. Borderline, and merging keeps a bin of 20 per cent of the sample. Merge.
Bins 5 and 6 (21 and 26) differ by 5 points, about twice the standard error. Keep apart, or merge if she wants fewer bins.
Bins 9 and 10 (55 and 61) are 6 points apart but the standard errors are larger because the bins hold fewer loans. Merge.
The result is five or six bins that rise steadily and match the business story: below about 60 per cent LTV, recoveries are comfortable; between 60 and 100 per cent they erode; above 100 per cent, the lender is under water. She then checks the bins on a holdout sample from a different year, finds them stable, and computes the exposure-weighted IV. At 0.595 it is well above the usual cut-offs. She notes in her documentation that the relationship depends on the way asset values are estimated, and that a fall in property prices would push loans into higher bins, which is itself a risk to monitor.
Common mistakes
Cutting the target into good and bad at an arbitrary LGD. It discards information and creates artificial edges.
Mixing loan weights and money weights. Say which basis the WoE and IV use.
Judging precision by money and not loans. Bin reliability depends on the number of loans.
Ignoring a skewed target. Cap, transform or use the median before averaging.
Forgetting the zero and 100 per cent spikes. Look at the distribution inside each bin.
Treating a high IV as comfort. For LGD the scale is different, but leakage and measurement dates still need checking.
Using the asset value at default instead of at origination. The predictor must be known at the time of the decision.
Not freezing the mapping. Production must apply the development bins and WoE.
Key takeaways
Default has a yes or no outcome, but loss, exposure and recovery are continuous. Their predictors can still be binned and scored.
Bin-mean encoding replaces each bin by its average target and gives a lift against the overall average. It is simple but not on the log-odds scale.
Fractional WoE treats each loan as part bad and part good by its LGD. In the example it ran from +1.087 to −1.395 across four LTV bins, with an IV of 0.508.
Weighting by exposure gives the rupee view. It lifted the overall LGD from 28.8 to 32.1 per cent and the IV to 0.595, because the largest loans sat in the worst bin.
Skewed targets need capping, a transformation or the median. Check the shape of the distribution inside each bin.
Bin precision depends on the number of loans and on how spread out the target is. A bin of 200 loans with a standard deviation of 35 points has a range of about plus or minus 5 points.
Check yourself
1. A bin has 500 defaulted loans with an average LGD of 18 per cent. The sample has 3,000 loans with an average LGD of 30 per cent. What are the bin's shares of bad and good weight, and its WoE?
Bad weight in the bin 90, total 900, share 10 per cent. Good weight in the bin 410, total 2,100, share 19.5 per cent. WoE = ln(0.195 ÷ 0.10) = +0.67.
2. What is the WoE of a bin whose average LGD equals the sample average?
Zero.
3. Why can the exposure-weighted overall LGD be higher than the loan-count average?
The loans with the highest LGDs may also be the largest, so they carry more of the money. Weighting by exposure gives them more weight.
4. A bin has 100 loans and the LGD in it has a standard deviation of 40 points. What is the 95 per cent range around its average?
The standard error is 40 ÷ √100 = 4 points, so the range is about plus or minus 7.8 points.
5. Why is it a poor idea to call a loan "bad" if its LGD is over 50 per cent and then use ordinary WoE?
Loans just either side of 50 per cent are almost the same but would be classed differently, and a 100 per cent loss counts the same as a 51 per cent one. Most of the information in the target is lost.
Try this
Bin a continuous target of your own. Set aside forty to forty-five minutes.
1. Invent a file of at least 1,000 defaulted loans with an LTV (or another predictor), an exposure and an LGD between 0 and 1. Make LGD rise with LTV and let a few loans have zero loss and a few have a total loss.
2. Make ten equal-frequency bins on LTV. Compute loans, average LGD and the standard error of the average for each bin.
3. Merge neighbours whose averages differ by less than about two standard errors, and write down your final four to six bins.
4. Compute the fractional WoE and IV on a loan-count basis, writing out the shares of bad and good weight.
5. Repeat with exposure weights. Compare the overall LGD and the WoE of each bin on the two bases, and write one sentence on why they differ.
6. Use the simulator to check one bin's WoE, then move its average LGD up by 10 points and see how the contribution to IV changes.
7. Write a five-sentence note to a model reviewer: the shape of the relationship, the bins you chose, the basis you used and why, the precision of the thinnest bin, and the check you would run on a second year of data.
A good result is a table of four to six bins with averages, standard errors and WoE on both bases, plus a note that explains the choice of basis. With binning, weight of evidence and variable selection in place for both default and loss, Module 6 builds the models themselves, starting with a logistic regression scorecard.
Tags: Credit Risk Analytics Weight of Evidence LGD Continuous Target Exposure Weighting