Predicting Credit Default
A k-NN classifier that catches 6 out of 10 defaulters before the money leaves the bank — paired with a Power BI dashboard that shows loan officers exactly where the risk is concentrated.
Lending money is inherently risky — lending blindly is what destroys margins. The portfolio I analyzed had a default rate of 21.5%: for every five loans approved, more than one resulted in a loss. The goal was to build both a predictive gatekeeper and a visual risk map loan officers could actually use day to day.
Explore the Power BI dashboard
Having trouble viewing it? Open the dashboard directly.
From raw applications to a risk-ready model
Data profiling & business framing
Loaded 30,000+ loan applicant records — age, income, home ownership, loan intent, loan grade. Before touching any algorithm, I isolated high-risk renters with a history of default and found that medical expenses and debt consolidation were the biggest drivers of losses in that segment.
Cleaning & exploratory analysis
Filled missing interest-rate values (about 10% of rows) with the median, stripped out impossible outliers like ages over 100 and employment lengths over 60 years, then ran a correlation matrix to scout early relationships with default status.
Feature engineering
One-hot encoded the categorical fields, split the data 70/30 for training and testing, and scaled the numeric features — without that step, an income in the hundreds of thousands would have completely drowned out a variable like interest rate.
Choosing the right metric — and the right model
Accuracy is a trap here: a model that approves everyone still looks roughly 80% accurate while the bank quietly bleeds money on the 20% who default. Recall on defaulters was the metric that actually mattered. A scatterplot of income against interest rate showed no clean line between good and bad loans, which ruled out a simple linear approach — so I tested a linear SVM against a distance-based k-NN model.
Translating the model into decisions
A model living in a notebook doesn't change anyone's behavior. I moved the results into Power BI so loan officers could see risk visually — by grade, by home-ownership status, by loan purpose — instead of trusting a single score.
What the dashboard exposed
- k-NN beat the linear model. The distance-based k-NN classifier caught 61% of actual defaulters at 89% overall accuracy, comfortably outperforming the linear SVM.
- "G-grade" loans are a black hole. This grade carried an almost 98% default rate — not a calculated risk, essentially a guaranteed loss that should be restricted outright.
- Renters are the highest-risk segment. A 31% default rate, concentrated in debt-consolidation and medical loans.
- Homeowners are the safest bet. Just a 7% default rate, making them prime candidates for premium credit products.
Combining the k-NN model's ability to catch 6 in 10 defaulters with a dashboard that makes risk visible by grade and profile gave the bank a path from reactive debt collection to proactive lending policy — the fix wasn't to stop lending, it was to stop lending blindly.