For a logistic regression the SHAP value has a closed form, adds exactly to the logit, and gives reason codes a decline letter can defend.
For a logistic regression the SHAP value of each feature has a closed form in log-odds: coefficient × (applicant's value − portfolio mean), assuming the features are independent. On an illustrative four-variable PD model, an applicant with a PD of 29.4 per cent against a base of 3.97 per cent owes 0.990 of the 2.310 log-odds gap to revolving utilisation and 0.625 to recent enquiries, so those are the two reasons to give for the decline, not the debt-to-income ratio that the raw coefficient-times-value reading would put second.
Worked in full in Machine Learning for Finance by Julian R. Sterling, with every figure reproduced in a free workbook.See the book on Amazon →
Lenders need per-applicant explanations for adverse action notices, model validation and challenge from the business. For a tree ensemble SHAP needs an algorithm. For the logistic regression that still runs most credit decisions it needs one line of arithmetic, and getting that line wrong produces the wrong reason codes.
| Feature | Coefficient | Portfolio mean | Applicant |
|---|---|---|---|
| Debt-to-income, % | 0.035 | 32 | 45 |
| Revolving utilisation, % | 0.022 | 40 | 85 |
| Years at address | −0.06 | 6 | 2 |
| Credit enquiries, last 6 months | 0.25 | 1.5 | 4 |
How the PD itself comes out of the logistic function is worked in calculating PD from a logistic regression. Here the question is how to split that PD between the four inputs.
SHAP explains the difference between the applicant's output and the expected output. For a linear model in log-odds the expected output is the model evaluated at the portfolio means.
Base = −5.2 + 0.035 × 32 + 0.022 × 40 − 0.06 × 6 + 0.25 × 1.5
= −5.2 + 1.120 + 0.880 − 0.360 + 0.375 = −3.185 log-odds, a PD of 3.97 per cent.
SHAPi = βi × (xi − meani)
Debt-to-income: 0.035 × (45 − 32) = 0.035 × 13.0 = 0.455
Utilisation: 0.022 × (85 − 40) = 0.022 × 45.0 = 0.990
Years at address: −0.06 × (2 − 6) = 0.240
Enquiries: 0.25 × (4 − 1.5) = 0.25 × 2.5 = 0.625
Excel, coefficients in B2:B5, means in C2:C5, applicant in D2:D5: =B2*(D2-C2), filled down.
Sum of SHAP values = 0.455 + 0.990 + 0.240 + 0.625 = 2.310
Base + sum = −3.185 + 2.310 = −0.875 = the applicant's logit. PD = 1 ÷ (1 + e0.875) = 29.4 per cent.
The four values add exactly to the gap between the applicant and the average, which is the property that makes SHAP usable for reason codes. In shares of the gap, utilisation explains 43 per cent, enquiries 27, debt-to-income 20 and years at address 10.
| Feature | SHAP, log-odds | Points lost | Naive β × x |
|---|---|---|---|
| Revolving utilisation | 0.990 | 28.6 | 1.870 |
| Credit enquiries | 0.625 | 18.0 | 1.000 |
| Debt-to-income | 0.455 | 13.1 | 1.575 |
| Years at address | 0.240 | 6.9 | −0.120 |
| Total | 2.310 | 66.7 |
The points column multiplies each SHAP value by PDO ÷ ln 2 = 20 ÷ 0.693 = 28.85, the same factor used to turn a model into scorecard points. Credit teams usually find “28.6 points lost on utilisation” easier to act on than a log-odds figure.
| Applicant | DTI | Utilisation | Address | Enquiries | PD | Main reason |
|---|---|---|---|---|---|---|
| A: 45, 85, 2, 4 | +0.455 | +0.990 | +0.240 | +0.625 | 29.4% | Utilisation |
| B: 24, 15, 11, 0 | −0.280 | −0.550 | −0.300 | −0.375 | 0.9% | None needed |
| C: 50, 30, 8, 1 | +0.630 | −0.220 | −0.120 | −0.125 | 4.7% | Debt-to-income |
Applicant C is the useful case. Three of four features pull the PD below average, and one, a 50 per cent debt-to-income ratio, pushes it above. If C is declined at a cut-off below 4.7 per cent, debt-to-income is the only honest reason, and a model monitor can see that from the signs alone.
The independence caveat. The closed form is the interventional SHAP value, which treats the features as independent. Utilisation and enquiries are often correlated, and a conditional SHAP implementation will share credit between them differently. State which one the reason codes use, and keep it fixed between validations.
For a logistic PD model, SHAP needs no library: coefficient times distance from the mean, in log-odds, adding exactly to the applicant's logit. Applicant A's 29.4 per cent PD is 43 per cent utilisation and 27 per cent enquiries, and those are the reason codes. The book builds its scorecard from counts and carries every coefficient into points in the free workbook for this case.
No. A coefficient is the effect of one unit; the SHAP value is the coefficient times the applicant's distance from the portfolio mean. A utilisation coefficient of 0.022 gives a SHAP value of 0.990 for an applicant at 85 per cent against a mean of 40, and a negative value for one below the mean.
Log-odds, or scorecard points derived from them. In log-odds the values add exactly to the applicant's logit. In probability the split depends on order: in the illustrative case utilisation is worth 6.0 PD points if added first and 16.0 if added last, so the ranking of reasons can change.
Multiply each log-odds SHAP value by the scorecard factor, PDO divided by ln 2. With a PDO of 20 the factor is 28.85, so a SHAP value of 0.990 is 28.6 points lost and the applicant's four features cost 66.7 points in total against the average applicant.
This article is one calculation from Machine Learning for Finance. The book takes the same case from first principles to the decision, chapter by chapter, and every figure it prints is a live formula in the free companion workbooks.
Get the book on Amazon →Free companion files
Also on Amazon UK · Amazon Germany · Amazon France · Amazon Canada
Reading guide: corporate finance, valuation and markets → · All 1501 articles →
If this book helped, or didn’t, a few lines on Amazon are worth more than they look: they are what the next reader goes on. Write a review. The workbook stays free either way.