Data Science · Chapter 41 of 43
Model Deployment
DEPLOYMENT makes your model usable — usually as a REST API endpoint or embedded in a dashboard/app.
Monitor accuracy AND data drift once live. Models decay over time.
Example 1 (python)
# Minimal FastAPI service
from fastapi import FastAPI
import joblib
app = FastAPI()
model = joblib.load('model.pkl')
@app.post('/predict')
def predict(data: dict):
return {'y': int(model.predict([data['x']])[0])}One-file inference API.
Example 2 (python)
# Docker + cloud (AWS/GCP/Azure) for scalePackage and ship reproducibly.
Key points
- Serve via REST API (FastAPI/Flask).
- Containerise with Docker.
- Monitor drift and accuracy.
- Retrain on fresh data.
💡 Note: In production, most failures come from stale data or bad monitoring — not from a bad model architecture.
