Credit Scoring: Theory, Methods, and Practice

An Executable Handbook for Practitioners and Academics

End-to-end treatment of credit scoring. Math, derivations, runnable Python, publicly available data, and cloud-agnostic deployment patterns. Covers classical statistics, machine learning, deep learning, alternative data, explainability, fairness, causal inference, graph neural networks, LLMs, regulatory capital, and production deployment.

Author
Published

2026-05-17

Preface

This book is a working reference for people who build, audit, deploy, and regulate credit scoring models. Every method is derived, every line of code runs in the reader’s own environment, and every dataset is publicly downloadable under a permissive license.

Who this book is for

Practitioners: model developers, validators, MLOps engineers, credit analysts, and risk officers who need code that works and methods that pass audit.

Academics: researchers in finance, statistics, machine learning, and law who want a single coherent reference with verified derivations and top-tier citations.

Regulators and auditors will also find the regulatory chapters, the model risk workflow, and the fairness and explainability material directly useful.

How to use this book

The book is a Quarto project. Each chapter is a .qmd file with executable Python. Clone the repo, install the environment, render locally:

git clone https://github.com/mikenguyen13/credit_score.git
cd credit_score
uv sync --python 3.12
source .venv/bin/activate
cd book
quarto render

Details on environment setup and macOS OpenMP notes are in Why reproducibility matters for credit models.

Data

Four public datasets anchor most examples:

  • UCI Statlog German Credit Data (Hofmann 1994): 1,000 consumer loans, 20 features. Small enough for pedagogy, large enough for real benchmarks.
  • UCI Default of Credit Card Clients (Yeh and Lien 2009): 30,000 Taiwanese credit card customers. Class imbalance around 22%, rich behavioral history.
  • Home Credit Default Risk (Kaggle, CC0): large, real-world mixed tabular with application, bureau, and installment tables.
  • HMDA Loan-level Public Data (CFPB, public domain): millions of U.S. mortgage applications, the default source for fair-lending research.

These anchor examples, but several chapters also simulate data when a specific statistical property is pedagogically necessary. Why dataset choice is a first-class modeling decision provides download and caching code.

What is new in this treatment

Four things distinguish this book from the existing literature:

  1. Every algorithm ships with a from-scratch derivation, a reference NumPy implementation, and the standard production library call. Readers see the math, the code, and the package API side by side.
  2. Scalability is treated as a first-class concern. Each method is benchmarked on single-node pandas, Polars, Dask, and PySpark where relevant, and the throughput numbers are the ones the reader actually reproduces.
  3. Deployment patterns are cloud-agnostic. FastAPI plus Docker plus MLflow form the core stack. SageMaker, Vertex, Databricks, and Azure ML map onto this stack with small adapters.
  4. Regulatory, fairness, and explainability material is integrated chapter by chapter rather than confined to a single appendix. SR 11-7, GDPR Article 22, ECOA, and the EU AI Act are referenced in every chapter whose content they actually govern.

Reproducibility

All results in this book are rendered directly from executable code. Random seeds are fixed. Dataset versions are pinned. A continuous integration run renders the full book from scratch; any number or figure that does not match the text is treated as a build failure.

License

Text is licensed under Creative Commons Attribution 4.0 International (CC-BY-4.0). Code is licensed under the MIT License. Redistribute, adapt, and use in your own work with attribution.

A note on scope

The book does not cover quantitative credit pricing, CDS markets, or structured credit. It focuses on models whose output is the probability of default for an individual borrower or facility over a fixed horizon, plus the calibration, explanation, and capital consequences of that output. The structural and causal chapters (8  Structural Models: Merton and the KMV Framework and 32  Causal Inference in Credit Scoring) touch on pricing only insofar as the lenses they introduce inform retail and SME scoring.

Acknowledgments

This book builds on four decades of work by Baesens, Thomas, Hand, Lessmann, Bastos, Verbraken, Crook, Altman, Ohlson, Merton, and many others whose contributions we cite throughout. Any errors are ours.