Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

10 Commits

Folders and files

Repository files navigation

credit-risk-model

Data

Download the dataset from Kaggle and place it in the /data folder as credit_card_data.csv.

Credit Card Default Risk Model

A machine learning project that predicts credit card default risk using the UCI Credit Card Default dataset. Built to mirror real-world credit risk workflows at consumer lending institutions like Capital One.


Business Problem

Credit card defaults cost lenders billions annually. The goal of this project is to build a model that identifies high-risk customers before they default, while minimizing the cost of wrongly rejecting good customers.

Key business question: Which model minimizes total expected losses when the cost of a missed default ($5,000) is 10x higher than the cost of a wrongly rejected customer ($500)?


Dataset

  • Source: UCI Credit Card Default Dataset
  • Size: 30,000 customers, 25 features
  • Target: Whether a customer defaulted on their next payment (binary)
  • Class imbalance: 22% default rate — accuracy is not a valid metric

To run this project, download the dataset from the link above and place it in the /data folder as credit_card_data.csv.


Project Structure

credit-risk-model/
├── data/                          # Data folder (CSV files not tracked by git)
├── images/                        # Saved visualizations
├── notebooks/
│   ├── 01_eda.ipynb               # Exploratory data analysis
│   └── 02_modeling.ipynb          # Modeling, evaluation & SHAP
└── README.md

Approach

1. Exploratory Data Analysis

Analyzed distributions of credit limits, payment history, and demographic variables. Identified that recent payment delinquency (September) is the strongest early signal of default.

2. Feature Engineering

Built three business-motivated features:

  • avg_payment_ratio — average of monthly payment / bill amount; low values indicate a customer paying only minimums
  • months_delinquent — count of months with late payments across the 6-month window
  • bill_growth — difference between most recent and oldest bill amount; positive values indicate accelerating debt

3. Models Trained

  • Logistic Regression — industry baseline; legally defensible and interpretable under ECOA adverse action requirements
  • XGBoost — gradient boosted tree model; higher performance with scale_pos_weight=3 to handle class imbalance

4. Evaluation

Models evaluated on AUC-ROC and a custom business cost matrix:

  • Missed default (false negative) = $5,000 loss
  • Wrong rejection (false positive) = $500 lost revenue

Results

Metric Logistic Regression XGBoost
AUC-ROC 0.740 0.772
Missed Defaults 941 537
Wrong Rejections 197 803
Total Business Cost $4,803,500 $3,086,500

XGBoost reduces expected losses by $1,717,000 (35.7%) on the 6,000 customer test set compared to logistic regression. Scaled to a portfolio of 500,000 customers, this represents approximately $143 million in avoided annual losses.

XGBoost achieves this by aggressively catching defaults — missing 404 fewer defaulters at the cost of 606 additional wrong rejections. This tradeoff is worthwhile because a missed default costs 10x more than a wrong rejection.


Visualizations

Exploratory Data Analysis

EDA Overview

ROC Curve Comparison

ROC Curve

Confusion Matrices

Confusion Matrices

SHAP Feature Importance

SHAP Importance

SHAP Summary Plot

SHAP Summary


Key Findings

  1. Payment delinquency in September (pay_sep) is the single strongest predictor of default — customers already behind are far more likely to default next month
  2. months_delinquent, our engineered feature, ranked 2nd in SHAP importance — validating the feature engineering approach
  3. avg_payment_ratio confirmed that customers paying only minimum balances are significantly higher risk
  4. Credit limit is protective — higher limits at origination correlate with lower default rates, likely reflecting stronger underwriting at approval time

Recommendation

Deploy XGBoost as the primary risk scoring model, with logistic regression retained to generate customer-facing explanations for adverse action notices as required under the Equal Credit Opportunity Act (ECOA).


Future Work

  • Fairness audit across demographic groups (SEX, EDUCATION, MARRIAGE) to ensure compliance with fair lending regulations
  • Hyperparameter tuning to further optimize the default/rejection tradeoff
  • Threshold optimization based on the business's specific risk tolerance
  • Deploy as a REST API scoring endpoint

Environment

Python 3.10
xgboost==1.7.6
shap
scikit-learn
pandas
numpy
matplotlib
seaborn

Author

Bisola Adekola
Data & Information Science
GitHub

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages