8000 GitHub - kyyril/Workflow-CI: MLflow Project CI Pipeline - Heart Disease Classifier - Submission SMSML Dicoding · GitHub
[go: up one dir, main page]

Skip to content

About

MLflow Project CI Pipeline - Heart Disease Classifier - Submission SMSML Dicoding

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Workflow-CI - Automated MLflow & Docker CI Pipeline

CI - MLflow Training Pipeline Python 3.12 MLflow 2.19.0 scikit-learn 1.5.0 Docker Hub

Automated end-to-end MLOps CI/CD pipeline built with GitHub Actions, MLflow Projects, and Docker (MLServer) for reproducible training, experiment tracking, artifact retention, and containerized model delivery of a Heart Disease Classifier (RandomForestClassifier).


CI/CD Pipeline Architecture

flowchart LR
    A["Trigger<br/>(push to main / manual)"] --> B["Setup Python 3.12<br/>& Dependencies"]
    B --> C["MLflow Project Run<br/>(modelling.py)"]
    C --> D["Log Params, Metrics,<br/>Plots & Model Signature"]
    D --> E["Upload GitHub Artifact<br/>(mlruns/, 30-day retention)"]
    D --> F["Resolve Latest RUN_ID<br/>from Heart-Disease-CI"]
    F --> G["Build Serving Image<br/>(mlflow + MLServer)"]
    G --> H["Push to Docker Hub<br/>kyyril/heart-disease-classifier:latest"]
Loading

Workflow Stages (.github/workflows/ci.yml)

Stage Description
1. Checkout & Setup Checks out repository and provisions Python 3.12 on ubuntu-latest with mlflow==2.19.0, scikit-learn, pandas, numpy, matplotlib, and seaborn.
2. Reproducible Training Executes mlflow run MLProject --env-manager=local --experiment-name Heart-Disease-CI to train and evaluate the RandomForestClassifier.
3. Artifact Retention Uploads mlruns/ directories as mlflow-artifacts-<run_number> with a 30-day retention policy.
4. Container Build Extracts the latest RUN_ID from Heart-Disease-CI and packages the logged model into a serving container via mlflow models build-docker --enable-mlserver.
5. Registry Push Authenticates via docker/login-action@v3 and pushes <DOCKER_USERNAME>/heart-disease-classifier:latest to Docker Hub.

Experiment Tracking & Logged Artifacts

Each CI run logs full reproducibility metadata under the Heart-Disease-CI experiment and registers the model as HeartDiseaseClassifier with an inferred input_example and schema signature:

  • Hyperparameters: n_estimators (default: 150), max_depth (default: None), min_samples_split (default: 5), random_state (42)
  • Evaluation Metrics: accuracy, f1_score, precision, recall, roc_auc, train_accuracy, cv_mean_accuracy (5-fold CV), cv_std_accuracy
  • Artifacts:
    • plots/confusion_matrix.png
    • plots/feature_importance.png
    • data/feature_importance.json
    • reports/classification_report.txt
    • model/ (serialized scikit-learn model + MLmodel signature)

Repository Structure

.
├── .github/
│   └── workflows/
│       └── ci.yml                          # GitHub Actions CI/CD workflow
└── MLProject/
    ├── MLProject                           # MLflow Project spec & entry points
    ├── conda.yaml                          # Pinned Conda/Pip environment
    ├── modelling.py                        # Training, 5-fold CV, & MLflow logging
    ├── Tautan ke Docker Hub.txt            # Published Docker Hub image reference
    └── heart_disease_preprocessing/
        └── heart_disease_preprocessed.csv  # Preprocessed training dataset

Local Usage & Serving

1. Run Training Locally

pip install mlflow==2.19.0 pandas==2.2.2 numpy==1.26.4 scikit-learn==1.5.0 matplotlib==3.11.0 seaborn==0.13.2
mlflow run MLProject --env-manager=local --experiment-name Heart-Disease-CI

Override hyperparameters via environment variables (N_ESTIMATORS, MAX_DEPTH, MIN_SAMPLES_SPLIT):

N_ESTIMATORS=200 MAX_DEPTH=10 python MLProject/modelling.py

2. View Experiments in MLflow UI

mlflow ui

3. Run the Published Docker Serving Container

Pull directly from Docker Hub or build locally from an MLflow RUN_ID:

# Option A: Pull pre-built image from Docker Hub
docker pull kyyril/heart-disease-classifier:latest
docker run -p 8080:8080 kyyril/heart-disease-classifier:latest

# Option B: Build locally from an MLflow run
mlflow models build-docker \
  --model-uri "runs:/<RUN_ID>/model" \
  --name "heart-disease-classifier:latest" \
  --enable-mlserver
docker run -p 8080:8080 heart-disease-classifier:latest

Query the MLServer /invocations endpoint:

curl -X POST http://localhost:8080/invocations \
  -H "Content-Type: application/json" \
  -d '{"dataframe_records": [{"age": 54, "sex": 1, "cp": 0, "trestbps": 130, "chol": 246, "fbs": 0, "restecg": 1, "thalach": 150, "exang": 0, "oldpeak": 1.2, "slope": 1, "ca": 0, "thal": 2}]}'

GitHub Actions Configuration

Configure these repository secrets under Settings → Secrets and variables → Actions for automated Docker Hub publishing:

Secret Description
DOCKER_USERNAME Docker Hub username (e.g., kyyril)
DOCKER_PASSWORD Docker Hub password or Personal Access Token (PAT)

About

MLflow Project CI Pipeline - Heart Disease Classifier - Submission SMSML Dicoding

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0