Skip to content

About

Credit risk modeling portfolio project — PD estimation, feature engineering, temporal validation, and fair lending screening

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

RiskOptima

Credit Risk Modeling Portfolio Project

This is a portfolio project using synthetic data. It demonstrates concepts and techniques commonly used in credit risk modeling but is not production-ready software.

Overview

RiskOptima demonstrates:

  • Probability of Default (PD) estimation using multiple model architectures
  • Feature engineering with temporal awareness and interaction terms
  • Temporal validation (train 2021-2023, test 2024-2025) to prevent data leakage
  • Model validation including PSI/CSI drift monitoring
  • Fair lending screening across protected class groups
  • Survival analysis concepts relevant to lifetime ECL estimation
  • API deployment with FastAPI for scoring demonstrations

Architecture

Model Role Description
Logistic Regression Primary Baseline Interpretable, regulatory-friendly baseline
Decision Tree Benchmark Simple tree for comparison
XGBoost Challenger Gradient boosting for accuracy benchmarking
Ensemble (LR + XGB) Combined Weighted combination balancing interpretability and performance
Cox Proportional Hazards Survival Lifetime PD concepts for ECL modeling

Data

  • 25,000 synthetic loans originated between 2021-2025
  • Train: ~15,000 loans (2021-2023)
  • Test: ~10,000 loans (2024-2025)
  • Features: FICO, DTI, LTV, income, loan amount, interest rate, employment length
  • Protected classes included for fair lending analysis
  • Missing values (~3%) and outliers (~0.5%) simulated for realism

Important: High AUC scores reflect clean signal in synthetic data. Real-world credit models typically achieve 0.75-0.85 AUC.

Project Structure

RiskOptima/
├── README.md                    # This file
├── RESUME_GUIDE.md              # Interview prep & resume bullets
├── LICENSE                      # MIT License
├── requirements.txt             # Python dependencies
├── .gitignore
├── Dockerfile                   # Containerization
├── docker-compose.yml
├── src/                         # 11 Python modules
│   ├── data_generation.py       # Synthetic data (2021-2025)
│   ├── feature_engineering.py   # Feature pipeline & temporal split
│   ├── models.py                # LR & DT training
│   ├── challenger_xgboost.py    # XGBoost challenger
│   ├── survival_cox.py          # Cox PH survival model
│   ├── ensemble.py              # Weighted ensemble
│   ├── evaluation.py            # Gini, KS, Brier, H-L, binomial tests
│   ├── visualization.py         # ROC, calibration, distribution plots
│   ├── model_validation.py      # Temporal split, PSI, CSI, stress testing
│   ├── monitoring.py            # Performance decay & drift alerts
│   └── fair_lending.py          # Disparate impact & parity screening
├── api/
│   └── main.py                  # FastAPI scoring service
├── notebooks/
│   └── 01_credit_risk_analysis.ipynb
├── tests/
│   └── test_models.py
├── tableau/
│   └── dashboard_guide.md
├── models/                      # Trained model artifacts
├── data/processed/
│   └── synthetic_loans_2021_2025.csv
└── reports/figures/             # 12 visualizations

Quick Start

pip install -r requirements.txt
python tests/test_models.py
uvicorn api.main:app --reload
jupyter notebook notebooks/01_credit_risk_analysis.ipynb

Model Results (Test Set: 2024-2025)

Model AUC-ROC Notes
Decision Tree ~0.98 Simple benchmark
Logistic Regression ~0.99 Interpretable baseline
Gradient Boosting (XGB) ~0.996 Challenger model
Ensemble (LR + XGB) ~0.996 Weighted combination

Note: These high AUC values reflect the clean signal in synthetic data and should not be compared directly to real-world model performance.

Validation Framework

  • Temporal Split: Train on 2021-2023, test on 2024-2025
  • Hosmer-Lemeshow Test: Probability calibration assessment
  • Binomial Test: Default rate vs predicted PD comparison
  • PSI/CSI: Population and characteristic stability monitoring
  • Stress Testing: Hypothetical adverse scenario simulation

Fair Lending Screening

  • Disparate impact ratio analysis across protected classes
  • Statistical parity testing
  • Equal opportunity (TPR) analysis by group

Disclaimer: This tool screens for potential indicators only. It does not constitute legal compliance analysis.

Limitations & Disclaimers

  1. Synthetic Data: All data is artificially generated.
  2. Not Production-Ready: Missing MLOps infrastructure, feature stores, automated retraining.
  3. No Regulatory Compliance: Demonstrates concepts commonly used in industry but does not certify compliance.
  4. Portfolio Project: Built for learning and demonstration purposes.

Skills Demonstrated

  • Python (pandas, scikit-learn, XGBoost, lifelines)
  • Feature engineering and temporal data handling
  • Multiple model architectures and ensemble methods
  • Model validation and monitoring concepts
  • Fair lending analysis techniques
  • API development with FastAPI
  • Containerization with Docker
  • Data visualization and reporting

About

Credit risk modeling portfolio project — PD estimation, feature engineering, temporal validation, and fair lending screening

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages