Download the dataset from Kaggle
and place it in the /data folder as credit_card_data.csv.
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.
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)?
- 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.
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
Analyzed distributions of credit limits, payment history, and demographic variables. Identified that recent payment delinquency (September) is the strongest early signal of default.
Built three business-motivated features:
avg_payment_ratio— average of monthly payment / bill amount; low values indicate a customer paying only minimumsmonths_delinquent— count of months with late payments across the 6-month windowbill_growth— difference between most recent and oldest bill amount; positive values indicate accelerating debt
- Logistic Regression — industry baseline; legally defensible and interpretable under ECOA adverse action requirements
- XGBoost — gradient boosted tree model; higher performance with
scale_pos_weight=3to handle class imbalance
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
| 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.
- Payment delinquency in September (
pay_sep) is the single strongest predictor of default — customers already behind are far more likely to default next month months_delinquent, our engineered feature, ranked 2nd in SHAP importance — validating the feature engineering approachavg_payment_ratioconfirmed that customers paying only minimum balances are significantly higher risk- Credit limit is protective — higher limits at origination correlate with lower default rates, likely reflecting stronger underwriting at approval time
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).
- 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
Python 3.10
xgboost==1.7.6
shap
scikit-learn
pandas
numpy
matplotlib
seaborn
Bisola Adekola
Data & Information Science
GitHub




