Loan Status Prediction

PythonStreamlit

Loan Status Prediction is a machine-learning project that predicts whether a loan will be fully paid or charged off, giving financial institutions a fast, data-driven signal for credit-risk assessment — trained on a real Kaggle dataset and deployed as a real-time Streamlit app anyone can try.

Architecture and Tech Stack

Core Architecture

  • Language: Python (pandas, numpy)
  • Machine learning: scikit-learn + XGBoost (XGBRFClassifier), joblib for model persistence
  • Data: Kaggle credit dataset (Credit_train.csv), cleaned into train_data_processed.csv
  • App & deployment: Streamlit + Streamlit Cloud for a real-time prediction UI
  • Environment: Google Colab / Jupyter notebook for exploration and training, .devcontainer for reproducibility

ML Pipeline

A single, reproducible flow from raw Kaggle data to a live prediction: exploration and cleaning, feature encoding and scaling, training and comparing several classifiers, selecting the best by metrics, and persisting it for the Streamlit app to serve.

Key Features

Dataset

  • Source: Kaggle — Credit_train.csv
  • Key features: Credit Score, Annual Income, Monthly Debt, Years of Credit History, number of open accounts, current credit balance, maximum open credit, loan purpose, and home-ownership status
  • Target: whether the loan is fully paid or charged off

Models & Results

Six classifiers were trained on the same processed data and compared on accuracy, F1, AUC-ROC and inference time. XGBRFClassifier won on the balance of predictive quality and speed.

ModelRole
XGBRFClassifierBest — combines gradient boosting + random forest
Random ForestCompared
Logistic RegressionCompared
Gradient BoostingCompared
AdaBoostCompared
SGDClassifierCompared

Best model — XGBRFClassifier:

  • Accuracy: 82.7%
  • F1 Score: 0.89
  • AUC-ROC: 0.64
  • Inference time: 32.3 ms

Most influential features: Credit Score, Annual Income, and Years of Credit History.

Image

Technical Highlights

Model choice driven by metrics, not a single number

The winner wasn't picked on accuracy alone — six models were compared across accuracy, F1, AUC-ROC and inference time, and XGBRFClassifier was selected for giving the best balance rather than topping any one metric in isolation.

Inference speed treated as a first-class metric

At 32.3 ms per prediction, the model is fast enough for interactive, real-time credit decisions — a property that matters as much as accuracy when the result feeds a live approval flow.

Reproducible preprocessing and model persistence

Missing-value handling, de-duplication, label encoding, StandardScaler and the train/validation split are captured once and saved as a processed dataset plus a persisted model (joblib), so the Streamlit app loads exactly the model that was evaluated.

Project Structure

loan-status-prediction/
├── loan-status-prediction.ipynb   # EDA, preprocessing, training, model comparison
├── app.py                         # Streamlit real-time prediction UI
├── XGBRFClassifier.pkl            # Persisted best model (joblib)
├── train_data_processed.csv       # Cleaned / encoded training data
├── requirements.txt               # Python dependencies
└── .devcontainer/                 # Reproducible dev environment

Impact and Scalability

  • Real-time credit-risk signal: instant fully-paid vs. charged-off prediction from an applicant's features
  • Interpretable drivers: surfaces the features that most influence the decision (Credit Score, Income, credit history), not just a black-box score
  • Speed-aware: 32 ms inference supports interactive decision-making at approval time
  • Reproducible & deployable: a persisted model + processed data + Streamlit Cloud means anyone can run the exact demo

Notes

Built in Python with scikit-learn and XGBoost, deployed on Streamlit Cloud. Code is public on GitHub. Try the live app at loan-status-prediction-unal.streamlit.app.

🖼️ IMAGE PLACEHOLDER — Streamlit app UI: the loan-application form and the prediction result


© 2026 Felipe Giraldo