Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Azure ML Pipeline: Customer Churn Prediction

Business Problem

Building a model is only half the job. This project demonstrates an end-to-end ML pipeline that trains a churn prediction model in Microsoft Azure and serves it as a real-time REST API endpoint that any engineering team can call to get instant churn predictions for new customers.

Architecture

Local Data → Azure ML Dataset → Azure Compute Cluster → 
Training Job → Registered Model → FastAPI Endpoint → 
Real-time Predictions

What This Project Demonstrates

  • Connecting to and managing an Azure ML workspace programmatically
  • Uploading and versioning datasets in Azure ML
  • Creating and managing cloud compute clusters
  • Submitting and monitoring training jobs in the cloud
  • Registering trained models in Azure ML model registry
  • Deploying a model as a real-time REST API using FastAPI
  • Testing live endpoints with real customer data

Azure ML Components Used

Component Purpose
Azure ML Workspace Central hub for all ML assets
Azure ML Dataset Versioned, registered training data
Azure Compute Cluster Cloud compute for model training
Azure ML Environment Reproducible Python environment
Azure ML Jobs Cloud training pipeline
Azure ML Model Registry Versioned model storage

Model Performance

Metric Score
ROC AUC 0.8313
Accuracy 77%
Recall (Churn) 0.66
F1 Score (Churn) 0.60

API Endpoints

Endpoint Method Description
/ GET API info and version
/health GET Health check
/predict POST Real-time churn prediction
/docs GET Interactive Swagger documentation

Sample API Request

POST /predict
{
  "features": [[1, 29.85, 29.85, 0, 0, 1, 0, 0, 1, 0,
                 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1,
                 0, 0, 0, 1, 0, 0, 0, 1]]
}

Sample API Response

{
  "predictions": [0],
  "churn_probability": [0.0754],
  "interpretation": ["Low churn risk"]
}

Tech Stack

  • Python 3.9
  • Azure ML SDK (azure-ai-ml)
  • Azure Identity
  • XGBoost
  • scikit-learn
  • imbalanced-learn (SMOTE)
  • FastAPI
  • uvicorn

Project Structure

azure-ml-project/
├── notebooks/
│   └── 01_azure_ml_pipeline.ipynb   # Full pipeline notebook
├── src/
│   ├── train.py                     # Azure ML training script
│   ├── score.py                     # Azure ML scoring script
│   └── api.py                       # FastAPI local endpoint
├── .gitignore
├── README.md
└── requirements.txt

How to Run

# Clone the repo
git clone https://github.com/philipatosam/azure-ml-project.git
cd azure-ml-project

# Create and activate virtual environment
python3 -m venv venv
source venv/bin/activate

# Install dependencies
pip install -r requirements.txt

# Run the API locally
cd src
uvicorn api:app --reload --port 8000

# Visit interactive docs
open http://localhost:8000/docs

Azure Setup Required

  1. Create an Azure account at https://azure.microsoft.com/free
  2. Create an Azure ML workspace in the Azure Portal
  3. Update SUBSCRIPTION_ID, RESOURCE_GROUP, and WORKSPACE_NAME in the notebook
  4. Run the notebook cells in order to train and register the model

What I Would Do Next

  • Deploy to Azure Managed Online Endpoint on a paid tier
  • Add input validation and error handling to the API
  • Build a monitoring dashboard to track prediction drift over time
  • Set up CI/CD pipeline using GitHub Actions to auto-deploy on model updates
  • Add authentication to the API endpoint

About

Production-grade ML pipeline built with the Azure ML SDK covering dataset registration, compute cluster provisioning, cloud training, model registry, and real-time REST API deployment. Cloud-trained ROC AUC of 0.8313 matching local results.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages