A LightGBM gradient boosting model served as a REST API. Given a loan applicant's details, it returns a default probability, risk band, and approve/review/deny decision.
| File | Purpose |
|---|---|
loan_data.csv |
2,000 synthetic loan applicant records used to train the model |
train.py |
Script to train (or retrain) the model |
model_artifacts.pkl |
Trained model + encoders, loaded by the API at startup |
app.py |
Flask REST API that serves predictions |
requirements.txt |
Python dependencies |
Dockerfile |
Container definition |
test_api.sh |
Quick curl-based smoke tests |
# Install dependencies
pip3 install -r requirements.txt
# Start the API
python3 app.pyThe API will be available at http://localhost:5000.
For Docker and cloud deployment instructions, see DEPLOYMENT_GUIDE.md.
GET /health — Check the server is running.
POST /predict — Score a loan applicant. Returns:
{
"default_probability": 0.23,
"risk_band": "medium",
"decision": "REVIEW"
}You can also run bash test_api.sh to execute a suite of test requests and see the responses.
Full request/response field reference is in DEPLOYMENT_GUIDE.md.
To train a new model on updated data:
python3 train.pySee RETRAINING_GUIDE.md for data requirements, Docker-based training, and hyperparameter tuning.