credit-risk prediction (neural network) and customer segmentation (K-Means + Hierarchical Clustering) for a South African retail bank. full pipeline debugging, SHAP interpretability, and a regulatory-aware executive recommendation.
# Thuso Bank Analytics: Credit Risk & Customer Segmentation
A multi-phase data science case study for a fictional retail bank, "Thuso Bank," covering
supervised default-risk prediction, unsupervised customer segmentation, and the integration
of the two into a single business recommendation, including where they honestly *don't*
combine the way you'd expect.
Built by **Gopolang Mmutlwane**.
## The business problem
Thuso Bank needs two things: (1) a way to predict which loan applicants are likely to
default, and (2) a way to segment its existing customer base for targeted marketing. Both
have to hold up to scrutiny, South Africa's National Credit Act (NCA) requires lenders to
justify credit decisions, and POPIA restricts fully-automated decisions with legal or
significant effects on a person.
This repo works through both problems end to end, starting from **broken, deliberately
buggy production code** (the realistic starting point for this kind of project) and rebuilding
each pipeline into something defensible.
## What's inside
| Notebook | What it does |
|---|---|
| `01_neural_net_debug_and_fix.ipynb` | Diagnoses and fixes a broken default-prediction network: identifier leakage, ordinal encoding of nominal categories, wrong loss/output activation, no regularisation, no class-imbalance handling, test-set leakage. Full defect log included. |
| `02_model_evaluation_shap.ipynb` | Evaluates the corrected model with confusion matrix, ROC/PR curves, and SHAP for per-applicant explainability (needed for NCA-compliant adverse-decision explanations). |
| `03_kmeans_debug_and_fix.ipynb` | Diagnoses and fixes an unstable K-Means segmentation script: identifier used as a feature, missing values dropped instead of imputed, a categorical field silently discarded, single-run random initialisation. |
| `04_kmeans_segmentation_pipeline.ipynb` | Builds a defensible K-Means segmentation: K chosen by elbow + silhouette evidence, stability-checked across seeds, segments profiled an …