Kirtan001/R_Bank_Marketing_UCI_Classification
0
End-to-End MLOps: UCI Bank Marketing Analysis
This project is a complete MLOps implementation for predicting term deposit subscriptions using the UCI Bank Marketing dataset. It includes data processing, model training (XGBoost), experiment tracking (MLflow), and deployment (Shiny App & Plumber API).
๐ Project Structure
โโโ analysis
โ โโโ (EDA and research files)
โโโ data
โ โโโ (Dataset files downloaded automatically)
โโโ src
โ โโโ app.R # Interactive Shiny App for Hugging Face
โ โโโ plumber.R # REST API for model serving
โ โโโ model.rds # Trained model artifact (generated by report)
โโโ tests
โ โโโ (Unit tests for model validation)
โโโ .github/workflows
โ โโโ main.yaml # CI/CD: Builds & Pushes Docker Image to GHCR
โโโ Dockerfile # Configuration for containerization
โโโ final_report.Rmd # Main report: Data -> Training -> Evaluation
โโโ README.md # Project documentation๐ How to Run
1. Generate the Model
Before running the app or API, you must train the model. Open final_report.Rmd in RStudio and click Knit.
- This will run the entire pipeline.
- It protects against data leakage.
- It saves the best model to
src/model.rds.
2. Run Locally (Shiny App)
Open src/app.R in RStudio and click Run App.
3. Run Locally (Plumber API)
Run the following R code:
library(plumber)
pr <- plumb("src/plumber.R")
pr$run(port = 8000)โ๏ธ Deployment (Hugging Face Spaces)
This project is configured for Docker deployment on Hugging Face.
Option A: Direct GitHub Connection (Recommended)
- Push to GitHub: Commit all files (including
src/model.rds) and push to your repository. - Create Space: Go to Hugging Face Spaces -> "Create new Space".
- Select SDK: Choose Docker.
- Connect Repo: Select your GitHub repository.
- Build: Hugging Face will automatically build the Docker image and launch the app.
Option B: Use Pre-Built Image from GitHub Packages (GHCR)
The CI/CD pipeline automatically builds and pushes the Docker image to GitHub Container Registry.
- Go to your GitHub Repository -> Packages.
- Copy the full image URL (e.g.,
ghcr.io/username/repo:main). - In Hugging Face Space settings, you can configure it to pull this image (requires Access Token if private).
Option C: Automated CI/CD (GitHub Actions) [Recommended]
We have configured main.yaml to automatically push code improvements to Hugging Face.
- Get Token: Go to Hugging Face -> Settings -> Access Tokens -> Create "Write" Token.
- Add Secret: Go to GitHub Repo -> Settings -> Secrets and variables -> Actions -> New Repository Secret.
- Name:
HF_TOKEN - Value: (Paste your token)
- Deploy: Any push to
mainwill now auto-update your Space!
๐ค CI/CD Pipeline
The main.yaml workflow performs the following:
- Lints Code: Checks R syntax for errors.
- Builds Docker Image: Creates the production container.
- Pushes to GHCR: Stores the image in GitHub Packages for easy deployment.
๐ ๏ธ Technologies
- Modeling:
tidymodels,xgboost,ranger,themis(SMOTE). - Deployment:
shiny,plumber,docker. - Validation:
testthat,yardstick.
