A simple demonstration of MLOps practices for a customer churn prediction model.
Real-World Example:
Imagine you run a telecom company with thousands of customers. Some customers are happy and stay for years, while others leave (churn) after a few months. This model predicts which customers are likely to leave.
Example Customer:
- Sarah is 45 years old
- Been a customer for 24 months
- Pays $79.99/month
- Total spent: $1,920
- Called customer support 3 times this month
Model Prediction:
{
"churn": 1,
"churn_probability": 0.73
}Translation: Sarah has a 73% chance of canceling her subscription. Why? She's calling support frequently (unhappy) and paying relatively high fees. Your business can now:
- Offer her a discount
- Reach out with personalized support
- Prevent losing her before she leaves
The model looks at patterns like:
- High monthly charges → More likely to churn
- More support calls → Customer is frustrated
- Low tenure → Haven't built loyalty yet
This helps businesses save customers proactively instead of reacting after they've already left!
churn-model/
├── generate_data.py # Generate synthetic churn dataset
├── train.py # Train the model
├── api.py # FastAPI inference server
├── requirements.txt # Python dependencies
# Install dependencies
pip install -r requirements.txt
# Generate dataset
python generate_data.py
# Train model
python train.py
# Test API locally
python api.py
# Visit http://localhost:8000/docscurl -X POST http://localhost:8000/predict \
-H "Content-Type: application/json" \
-d '{
"age": 45,
"tenure_months": 24,
"monthly_charges": 79.99,
"total_charges": 1920.00,
"num_support_calls": 3
}'Response:
{
"churn": 1,
"churn_probability": 0.73
}