Skip to content

Latest commit

Β 

History

History
91 lines (65 loc) Β· 4.03 KB

File metadata and controls

91 lines (65 loc) Β· 4.03 KB

Loan Risk Analyzer 🚦

An interactive web application for Credit Risk Bias & Fairness Detection, allowing users to analyze, predict, and mitigate bias in credit risk modeling with powerful visualizations and explainability.

πŸ”— Live App: https://loan-risk-analyzer.streamlit.app/


✨ Features

  • Upload Dataset: Instantly visualize predictions, group risk rates, and fairness metrics from your CSV.
  • Manual Entry & Scoring: Enter applicant details in a form and receive an instant risk score using a real ML model.
  • Bias & Fairness Analysis: See group-wise bias before and after mitigation using Demographic Parity and Equalized Odds.
  • Interactive Visualizations: Enjoy dynamic Plotly charts, ROC curves, and classified performance tables.
  • Explainability Ready: (Optional) Integrate SHAP for model transparency (local/global impact explanations).
  • Clean Portfolio Design: Responsive, intuitive UI, perfect for demonstrations or practical decision science.

πŸ› οΈ Technology Stack

  • Streamlit: Modern Python app framework for data apps.
  • scikit-learn: Model development; includes logistic regression, scaling, and metrics.
  • Fairlearn: Open-source library for measuring and mitigating bias in ML.
  • Plotly: Interactive and publication-ready charts.
  • Pandas & NumPy: Data manipulation and computation.
  • Pickle: For saving and loading trained pipelines and scalers.
  • SHAP and/or LIME: For explainable AI if desired.

πŸ“¦ Recommended Folder Structure

loan-risk-analyzer/
β”œβ”€β”€ app.py                      # Main Streamlit app
β”œβ”€β”€ README.md                   # Project documentation
β”œβ”€β”€ requirements.txt            # List of all dependencies
β”œβ”€β”€ scaler.pkl                  # Trained scaler (used for live/manual prediction)
β”œβ”€β”€ best_logistic_model.pkl     # Trained model (loan default risk classifier)
β”œβ”€β”€ data/
β”‚   β”œβ”€β”€ demo_data.csv           # Demo/test or example input data
β”œβ”€β”€ notebooks/
β”‚   β”œβ”€β”€ credit_risk_training.ipynb  # Model training and bias analysis notebook
β”œβ”€β”€ utils/
β”‚   β”œβ”€β”€ model_utils.py              # (Optional) Helper functions for loading/preprocessing/prediction
β”œβ”€β”€ assets/
β”‚   β”œβ”€β”€ logo.png                # (Optional) Project or sponsor logo
β”‚   └── custom.css              # (Optional) Streamlit theme overrides
└── .streamlit/
    └── config.toml             # (Optional) Streamlit UI/settings config

πŸ† Project Workflow

Data Preparation: Load, clean, explore CSVs (Data/)

Feature Engineering: Transform, scale, encode data (see notebook/)

Model Training: Train fair and baseline models, export best to model/

Bias Detection: Audit group fairness using Fairlearn

Mitigation: Apply and compare bias mitigation strategies

Deployment: Streamlit app loads model/scaler, visualizes everything

Manual & Bulk Scoring: Score new applicants and full datasets interactively

πŸš€ How to Use

1. Open the App

Visit Project Link in your browser.

1 2 3 4 5 6 7 8

πŸ“« Contact