Shresth Bhargava
Back to Projects
AI & Machine Learning

Loan Eligibility Predictor

End-to-End ML System

An end-to-end ML system for loan approval prediction with explainable AI, a production FastAPI backend, and an interactive Streamlit dashboard.

PythonScikit-learnFastAPIStreamlitSHAPDocker
Best Model
Random Forest

0.8548 Val AUC, 0.8837 F1

Cost Optimization
70% Loss Reduction

Threshold tuned to 0.77

API Speed
<150ms

FastAPI + Pydantic

Model Selection & Training

I evaluated 5 different models (Random Forest, XGBoost, Decision Tree, Gradient Boosting, Logistic Regression) using cross-validation. Despite the popularity of XGBoost, Random Forest outperformed it with the limited training data (614 rows). Its variance reduction through bagging provided better generalization, achieving a Validation AUC of 0.8548 and an F1 score of 0.8837.

Cost-Optimized Business Threshold

Instead of defaulting to a 0.5 probability threshold, I performed a business cost analysis. A False Positive (bad loan approved) costs ₹50k, while a False Negative (good loan rejected) costs ₹10k. By tuning the decision threshold to 0.77, I minimized the expected validation loss from ₹19.1L to ₹5.7L—a massive 70% reduction, demonstrating how ML directly impacts business value.

SHAP Explainability & Production Architecture

To comply with regulatory standards (like GDPR Article 22), I implemented SHAP to provide signed, per-prediction explanations, moving beyond basic feature importance. The system is containerized with Docker, featuring a FastAPI backend for sub-150ms inference, and an interactive Streamlit dashboard hosted on Hugging Face Spaces for real-time risk assessment.