Explainable ML

EquiLend AI

A loan model that has to explain itself, and an agent that checks the letter for bias before it goes out.

How it works

A home-equity loan decisioning app where every decision arrives with its reasons attached. An XGBoost classifier scores the application, SHAP turns that score into the specific factors that drove it, and Claude writes the applicant's decision letter from those factors. A second agent reads the letter back before it is sent, scores it for discriminatory language, and either passes it, rewrites it, or stops it for a human.

Engineering detail

  • Bias-checking agent with a rewrite loop: every generated letter is scored 0.0–1.0 for discriminatory language — under 0.3 it sends, 0.3–0.7 goes to a rewrite agent for up to 3 attempts, over 0.7 escalates to a human. The thresholds are code, not model judgment.
  • Explainability is stored, not just displayed: a SHAP TreeExplainer produces per-application reasons, and those reasons are written to the audit row alongside the decision.
  • Full audit trail: a SQLAlchemy loan_decisions table records the application inputs, the decision, default probability and confidence, the SHAP reasons, both the draft and final letter, and the bias score, action and rewrite count.
  • XGBoost classifier (200 trees, depth 5, learning rate 0.1) trained on the public HMEQ home-equity dataset across 12 features, with scale_pos_weight set from the class balance and median/mode imputation for missing values.
  • Fairness audit script reports disparate impact across categorical groups plus false-positive and false-negative rates — the rate of good loans denied and bad loans approved.
  • 38 automated tests across schema, preprocessing, model, email generation, bias detection and audit.

What it doesn't do

It runs on the public HMEQ dataset, not real applicants, and that dataset has no race, gender or age fields — so the fairness audit measures disparate impact across job category and loan reason, which are proxies rather than protected attributes.