FDE Times dataFDE jobs open 928▲21 Change in open roles over 7 days, like-for-like: roles from companies we started tracking this week are left outNew in 7 days 85Companies hiring 200Remote-friendly 24%Median US pay $200kTop hirer Databricks 107
中文VI

The newspaper of the Forward Deployed Engineer

Guides

A loan model with a great AUC still owes each borrower a reason

US regulators reject complexity as an excuse; SHAP assigns each feature its share of a single decision, and LIME tests that explanation on the same application.

The entrance to the Consumer Financial Protection Bureau headquarters in Washington, D.C., with the words "Consumer Financial Protection Bureau" above the glass doors.
Photo: G. Edward Johnson / CC BY 4.0
ShareLinkedInFacebookX

In brief

  • The CFPB requires credit denial reasons to be specific and accurate, and a complex or opaque model is no exemption.
  • For tree models, Tree SHAP is exact and fast, but how it handles correlated features changes the result.
  • LIME works well as a cross-check, but on tabular data it can be unstable, and both methods can be fooled.
Waterfall chart for loan application 4127. The default probability starts from a baseline of 0.12. Debt-to-income adds 0.14, three late payments add 0.11, four months in the job adds 0.06, income adds 0.03, while a nine-year credit history subtracts 0.05. The predicted result is 0.41, above the 0.30 approval cut-off. The table alongside shows LIME agreeing with SHAP on rank and sign for all four features; the result must still be verified by lowering debt-to-income and re-running the model.
For loan 4127, SHAP adds up contributions from a 0.12 baseline to 0.41, above the 0.30 approval cut-off. LIME gives the same ranking and the same signs. The reason for declining should go to the customer only after it has been verified on the model itself.

“Application 4127 was denied. The customer has complained. We need a specific reason by Friday.” Take that email, from the risk team at a lender where you are deploying a model, as a hypothetical. The model is an XGBoost with a few dozen features, a strong AUC and a clean backtest. Nobody in the meeting room can say why this particular application was rejected.

It is a textbook FDE assignment: a model that is statistically sound but cannot explain itself to one specific customer. In the United States, answering that question is a legal obligation for the lender, not a courtesy.

CFPB Circular 2022-03, issued on May 26, 2022, confirms that the requirement to give reasons for adverse action under ECOA and Regulation B applies to every credit decision, whatever technology was used to make it.

The CFPB goes further. Creditors may not use complex algorithms if doing so prevents them from giving specific and accurate reasons. Nor can they claim that the technology they use to evaluate applications is too complicated or too opaque to understand.

If you work for a fintech serving the US market, or for a bank that looks to this standard, the skill in this guide will be put to real use.

SHAP answers “how far did each feature push this application?”

SHAP, published by Lundberg and Lee in 2017, assigns each feature a contribution to each individual prediction. The common reading is that the model has a base value, roughly the average probability of default on a reference dataset.

Starting from that base value, you see how much each feature of the application pushes the prediction up or pulls it down. But do not assume that reading holds: check for yourself that the base value plus the contributions matches the probability the model returns for that application.

When the sum matches, you have an explanation the risk team can trace number by number, which is what a denial reason needs.

For tree models such as XGBoost or LightGBM, shap.TreeExplainer uses Tree SHAP, which the library’s documentation describes as a fast and exact method for trees and ensembles of trees.

There is no approximation and no waiting for hours.

LIME, from Ribeiro, Singh and Guestrin in 2016, takes a different route. It generates many variants of the application by perturbing its values, asks the original model to predict each variant, and then fits a simple model on this new dataset.

Samples closer to the original application get higher weight. LIME supports classifiers on tabular data with both numeric and categorical columns, which suits credit data.

Working through case 4127

The code below computes SHAP on the probability scale in interventional mode. According to the SHAP documentation, this mode needs a background dataset, so it samples 500 applications from the training set.

import shap
from lime.lime_tabular import LimeTabularExplainer

background = X_train.sample(500, random_state=0)
explainer = shap.TreeExplainer(
    model,
    data=background,
    feature_perturbation="interventional",
    model_output="probability",
)
x = X_test.loc[[4127]]
sv = explainer(x)
print(sv.base_values[0], sv.values[0].sum())

Suppose the output gives a base value of 0.12 and contributions summing to +0.29, and a comparison with predict_proba confirms the model’s probability of default is exactly 0.41, above the company’s approval threshold of 0.30.

By feature: a debt-to-income ratio of 52% contributes +0.14; three late payments in the past 12 months add +0.11; just 4 months in the current job adds +0.06; income adds +0.03; and a 9-year credit history pulls it down by −0.05.

The sum: 0.14 + 0.11 + 0.06 + 0.03 − 0.05 = 0.29.

That sum is the first thing to check. If base_values + values.sum() does not match model.predict_proba, find out which output you are explaining, log-odds instead of probability for instance, before you read any other number.

Next, run LIME on the same application for comparison:

lime_exp = LimeTabularExplainer(
    X_train.values,
    feature_names=list(X_train.columns),
    class_names=["repaid", "default"],
    mode="classification",
    random_state=0,
)
e = lime_exp.explain_instance(
    x.values[0], model.predict_proba, num_features=5
)
print(e.as_list())
# [('dti > 0.45', 0.21), ('late_payments_12m > 2', 0.17),
#  ('employment_months <= 6', 0.08), ('credit_age_years > 8', -0.06),
#  ('income <= 9000', 0.02)]

Compare rank and sign, not magnitude

The SHAP and LIME outputs just printed are measured on two different scales. In this example, the SHAP values have been checked to add up exactly to the distance from the base value of 0.12 to the prediction of 0.41.

LIME weights are coefficients of a local linear model fitted on conditions such as “dti > 0.45”, so adding them up produces no meaningful number.

When comparing the two, then, check only two things: which features rank highest, and in which direction each one pushes.

Feature SHAP (rank, value) LIME (rank, weight) Match?
Debt-to-income 1, +0.14 1, +0.21 Yes
Late payments, 12 months 2, +0.11 2, +0.17 Yes
Time in current job 3, +0.06 3, +0.08 Yes
Age of credit history pulls down, −0.05 pulls down, −0.06 Yes

For case 4127, the top three reasons agree on both rank and sign. You can now write to the customer: a high debt-to-income ratio, a recent history of late payments, and a short time in the current job. Three specific sentences, each tied to a number in the application.

Five steps to take at the client

First, ask the risk team which scale they want explanations on and what the approval threshold is, because a reason only means something next to the threshold. Then run SHAP and check that the sum matches the model’s actual output. Next, run LIME with several different random seeds and compare rank and sign with SHAP.

The fourth step is the one most often skipped: verify on the model itself. Lower the debt-to-income ratio of application 4127 to the median and call predict_proba again.

The probability should fall noticeably; if it does not, your top reason is not yet as accurate as the CFPB requires. Finally, map feature names to wording customers can understand, and have the legal team approve that mapping once rather than reviewing every letter.

Three traps that make a wrong reason look right

The first trap is correlated features. The SHAP documentation points out that SHAP values rest on conditional expectations, so you have to choose how to handle features that depend on each other, such as income and loan amount.

interventional mode needs a background dataset; tree_path_dependent mode does not, because it uses the number of training samples passing through each leaf as the background distribution. The two modes can split contributions differently, so pick one and record why.

The second trap is LIME’s instability. According to Christoph Molnar’s book Interpretable Machine Learning, choosing the neighborhood remains an unsolved problem when LIME is used on tabular data. Do not treat a single LIME run as evidence; if the top three shift with the seed, it is only a signal for reference.

The last trap is more serious. A 2019 study showed that perturbation-based explanation techniques such as LIME and SHAP can be fooled by an adversarially designed model, and the authors concluded they are not reliable.

That is why the verification step above, changing real data, is mandatory rather than optional.

How to show this skill on a CV

When reading job descriptions from fintechs or banks, watch for phrases such as “model explainability”, “reason codes” and “adverse action”. On your CV, do not just write “used SHAP”.

Write what you delivered: a pipeline that generates denial reasons for each application, with a sum check, a cross-check against LIME and counterfactual verification.

If you are applying for credit roles, be ready to walk through each of those steps on a specific application, with the numbers you checked.

The next time an email asks “why was this application rejected?”, there is no need to open a slide deck about model accuracy. Send the sum from 0.12 to 0.41, with evidence that every term in it has been verified.

Was this article useful?

Use with your AI assistantAsk Claude ↗Ask ChatGPT ↗
7 sources
Read next on the roadmap · Stage 4: CustomersThe ten seconds after an AI demo that shape the whole engagementA prototype that reads three hand-picked invoices is not a system for every invoice, and the finance chief watching cannot see the gap.