This repository contains a Flask-based API for serving an MLflow model to predict customer churn in a banking dataset. The API loads the latest version of the registered model from MLflow and exposes a REST endpoint for making predictions.
- Fetches the latest version of a registered model from MLflow.
- Exposes a
/predictendpoint to make predictions using a trained model. - Dockerized for easy deployment.
- CI/CD pipeline using Jenkins.
├── app.py # Flask application
├── Dockerfile # Docker container setup
├── requirements.txt # Python dependencies
├── Jenkinsfile # CI/CD pipeline setup
└── README.md # Project documentation
- Python 3.8+
- Docker
- MLflow server with a registered model
pip install -r requirements.txtpython app.py --mlflow_tracking_uri http://mlflow.example.com:8080 --model_name my_model- Method:
POST - Content-Type:
application/json - Request Body:
{
"Gender": 1,
"Balance": 12000.5,
"NumOfProducts": 2,
"IsActiveMember": 1,
"Geography_France": 1,
"Geography_Germany": 0,
"Geography_Spain": 0,
"Age_bin": 3
}- Response:
{
"predictions": [0.8]
}docker build -t bank-churn-api .docker run -d -p 5000:5000 --name bank-churn-container bank-churn-apiThis project includes a Jenkins pipeline (Jenkinsfile) to automate building, tagging, and deploying the Docker container. The pipeline consists of the following stages:
- Clone Repository
- Build Docker Image
- Tag Image
- Push Image to Registry
- Run Container
| Variable | Description | Default Value |
|---|---|---|
MLFLOW_TRACKING_URI |
MLflow tracking server URL | http://mlflow.example.com:8080 |
MODEL_NAME |
Name of the registered ML model | my_model |
- Flask
- MLflow
- pandas
- scikit-learn
- cloudpickle
- numpy
- psutil
- scipy
This project is licensed under the MIT License.