MACHINE LEARNING · CREDIT RISK
ROLE
Data Science & Analytics
TOOLS
R · K-means · DBSCAN
TIMEFRAME
Jul 2026
IMPACT
6 risk segments + a 3.3% high-risk watchlist
Credit risk is usually summarised in a single score, but one number hides the different ways a customer becomes risky. The question behind this project: can retail banking customers be grouped into distinct, actionable risk profiles based on their income, savings, debt and repayment behaviour, in a way that supports differentiated credit risk management and collections strategy?
The dataset was a synthetic set of 100,000 customer records generated for the project, with realistic data-quality problems deliberately embedded: duplicate rows, impossible values, and missing income and credit score data that the pipeline had to detect and fix before any clustering could be trusted.
Nine variables were selected across three complementary dimensions of risk: repayment capacity, leverage and repayment behaviour. Demographic fields were deliberately excluded; they are not direct risk indicators, and their use in risk scoring raises fairness concerns.
After cleaning and per-variable preprocessing in R (log transforms for skewed monetary variables, robust scaling for credit score, min-max normalisation for zero-inflated counts), K-means was tuned with the elbow method and silhouette analysis. The two diagnostics disagreed, so the final k of 6 was chosen where a strong silhouette peak, the flattening of the elbow curve and genuine business interpretability all met. DBSCAN was then run as a complementary density-based pass to surface the customers who do not truly fit any cluster.
K-means produced six interpretable segments, from high-income savers with zero debt down to a small financially distressed group: 4.1% of customers with an extreme debt-to-income ratio of 11.57 and the highest missed-payment rate. DBSCAN flagged a further 3.3% of customers (3,303 people) as density-based outliers, with a debt-to-income ratio 32 times higher than everyone else.
The practical takeaway: K-means gives a bank six broad segments to build relationship and collections strategy around, while DBSCAN produces a much smaller, sharper list of customers who need manual underwriting attention right now. The full code, figures and report are on GitHub.
BY THE NUMBERS
6
distinct risk segments across 100,000 customers
3.3%
of customers isolated as high-risk, density-based outliers
32x
higher debt-to-income ratio in the outlier group than the rest
4G Migration: converting 2.1M subscribers