Batch ML pipeline for predicting household rent arrears risk across Lewisham council's housing and benefits caseload. Outputs a ranked priority list for caseworker outreach — every score is reviewed by a human before any contact or resource allocation decision is made.
Two models are trained in parallel:
| Model | Role |
|---|---|
| Logistic regression | Interpretable baseline; useful for explaining individual scores |
| XGBoost | Primary scoring model; better ranking performance on held-out data |
See docs/model_card.md for intended use, training data, evaluation metrics, equity overlay, fairness approach, and monitoring guidance.
flowchart LR
A[household_data.xlsx] --> D[prepare_dataset]
B[IMD25.xlsx] --> D
D --> E[train / test split]
E --> F[cross-validate]
F --> G[fit LR pipeline]
F --> H[fit XGB pipeline]
G --> I[evaluate + fairness slices]
H --> I
I --> J["models/{timestamp}/"]
J --> K[arrears-predict]
D --> K
K --> L["outputs/{timestamp}_predictions.csv"]
.
├── src/arrears_risk_model/ # config, schemas, data, features, models, evaluate, train, predict
├── tests/ # pytest suite (synthetic fixtures — no real data required)
├── notebooks/ # EDA, clustering, and modelling notebooks
├── config/default.yaml # all tunable settings
├── data/ # input files (gitignored — see data/README.md)
├── docs/model_card.md # model card
├── models/ # trained pipeline artefacts (gitignored)
└── outputs/ # ranked priority lists (gitignored)
Requires Python ≥ 3.12 and uv.
uv sync # production dependencies
uv sync --dev # + pytest and ruffarrears-train # default config; writes to models/{timestamp}/
arrears-train --config path/to/my.yaml # custom config file
arrears-train --model-dir /tmp/models # override output directoryEquivalent: uv run python -m arrears_risk_model.train.
arrears-predict # score the default input
arrears-predict --model lr # use logistic regression
arrears-predict --input data/2026-05-01.xlsx # score a fresh export
arrears-predict --output-dir /tmp # override output directoryLoads the most recently trained pipeline from models/, scores every row in the input, applies the equity overlay, and writes a ranked CSV to outputs/. The --input flag accepts a fresh monthly export with or without arrears_flag/arrears_amount columns (production data typically has neither).
Before scoring, predict compares the input columns against the feature list recorded in the model's metadata.json and refuses to run if anything required is missing — so a stale model can't silently score data with a drifted schema.
Equivalent: uv run python -m arrears_risk_model.predict.
All settings are in config/default.yaml. Any field can be overridden at runtime with an ARM_-prefixed environment variable using __ as the nested delimiter:
ARM_TRAINING__RANDOM_STATE=7 arrears-train
ARM_EQUITY__CHILDREN=0.1 arrears-predict
ARM_PATHS__MODEL_DIR=/tmp/runs arrears-trainuv run pytestThe suite runs entirely on synthetic 50-row fixtures. No real data files are needed.
uv run ruff check src/ tests/