End-to-end machine learning project that predicts loan default risk and serves predictions through both a web UI and a REST API.
Financial institutions must assess loan risk accurately. This project focuses on production-ready ML engineering: reproducible training, modular pipelines, and deployable inference services.
- Predicts default risk (0 = unlikely, 1 = likely)
- Returns probability of default
- Exposes inference via FastAPI and Streamlit
- Python, Pandas, NumPy, scikit-learn, Joblib
- FastAPI (REST API), Streamlit (interactive UI)
- Docker, GitHub Actions
- Data ingestion: load and split raw loan data
- Data transformation: preprocessing and feature encoding
- Model training: train and persist best classifier pipeline
- Prediction pipeline: load persisted pipeline for inference
- API + UI: FastAPI endpoints and Streamlit app
python -m venv venv
venv\Scripts\activatepip install -r requirements.txtpython -m src.pipelines.train_pipelineuvicorn app:app --reload --host 0.0.0.0 --port 5000Open:
http://127.0.0.1:5000Docs:
http://127.0.0.1:5000/docsstreamlit run app_streamlit.pycurl -X POST http://127.0.0.1:5000/predict ^
-H "Content-Type: application/json" ^
-d "{\"Age\":35,\"Income\":500000,\"LoanAmount\":200000,\"CreditScore\":600,\"MonthsEmployed\":60,\"NumCreditLines\":3,\"InterestRate\":12.5,\"LoanTerm\":36,\"DTIRatio\":0.9,\"Education\":\"Bachelor\",\"EmploymentType\":\"Salaried\",\"MaritalStatus\":\"Single\",\"HasMortgage\":\"No\",\"HasDependents\":\"Yes\",\"LoanPurpose\":\"Car\",\"HasCoSigner\":\"No\"}"docker build -t loan-default-app .
docker run -p 5000:5000 loan-default-appCI validates imports and application startup while skipping pipeline load if model artifacts are missing.
src/
components/ # ingestion, transformation, training, prediction
pipelines/ # training entrypoint
templates/ # HTML UI
static/ # CSS assets
app.py # FastAPI app
app_streamlit.py
Ellias Sithole