Skip to content

jamesonsaunders/Loan-Risk-Model

Repository files navigation

Loan Risk Model

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.

Files

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

Quickstart

# Install dependencies
pip3 install -r requirements.txt

# Start the API
python3 app.py

The API will be available at http://localhost:5000.

For Docker and cloud deployment instructions, see DEPLOYMENT_GUIDE.md.

API

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.

Retraining

To train a new model on updated data:

python3 train.py

See RETRAINING_GUIDE.md for data requirements, Docker-based training, and hyperparameter tuning.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors