Skip to content
Sangam Gupta
All work

Credit Risk Predictor

Estimates how likely a loan applicant is to default, tuned to catch more risky applicants rather than to look accurate.

Status
Open source
Stack
Python, scikit-learn, HistGradientBoosting, pandas, Streamlit
Links
Code
ROC-AUC
0.76
of defaulters caught (recall) at a 15% threshold
41.8%
accuracy, which hides how rare defaults are
85.2%

Try the model

Change the applicant and watch the default probability move.

Loading the model (200 trees)…

How it fits together

  1. Applicant data
  2. Preprocessing pipeline
  3. HistGradientBoosting
  4. Probability of default
  5. 15% threshold
  6. Streamlit app

Model card

Intended use
Flag loan applicants for a closer human review. It ranks risk; it is not meant to approve or reject anyone on its own.
Data
Applicant financial, demographic and credit-history records (application_train.csv), with a binary label for whether the loan defaulted.
Model
scikit-learn pipeline: preprocessing followed by a HistGradientBoostingClassifier with 200 boosting iterations, saved with joblib.
How it was evaluated
  • ROC-AUC 75.99%
  • At a 0.15 threshold: recall 41.79%, precision 24.98%, F1 31.27%, accuracy 85.17%
  • Strongest features: the three external credit scores, then goods price and credit amount
Limitations
  • Low precision by design: about three in four flagged applicants would have repaid, so flags need human review.
  • Inputs include gender and family status. A real lender would need to review these for fairness and regulatory compliance before use.
  • Features not entered in the app or demo are fixed at dataset defaults, so individual scores are approximate.
  • Learned from one historical dataset; patterns may not hold for other markets or time periods.
Read the full analysis notebook

Gradient-boosted model on applicant financial, demographic and credit data, with a Streamlit app that returns default probability, risk class and the features driving the model.

The problem

Approving an applicant who later defaults costs a lender far more than reviewing one who would have repaid. A model that optimises plain accuracy on imbalanced data mostly predicts that nobody defaults.

How I built it

  1. Explore and preprocess applicant data inside a single scikit-learn pipeline, so training and the app use identical steps.
  2. Train a HistGradientBoostingClassifier and serialise the pipeline with joblib.
  3. Lower the decision threshold from 0.50 to 0.15, trading precision (25%) for recall (42%), because missed defaulters are the expensive error.
  4. Rank the top 20 features; external credit scores carry the most signal.
  5. Ship a Streamlit app that shows the probability, the risk class and how the threshold changes the decision.

Where it is now

Open source with the full notebook, trained pipeline and app.

Ask about Credit Risk Predictor

Answers come from this case study and its code on GitHub.