A model in a notebook helps nobody. This last post covers getting one somewhere it can be used, and the specific ways that goes wrong.
What deployment actually involves

Most deployments are one of three shapes. Batch — run predictions on a schedule and write them to a database; simplest, and enough for most business problems. Real-time API — a web service answering one request at a time. Embedded — the model runs on the user’s device.
Start with batch if you can. Real-time infrastructure is a substantial cost, and a surprising number of problems do not need an answer within milliseconds.
Save the pipeline, not the model
⚠️ This is the mistake that produces silently wrong predictions
Production must reproduce all of that identically — the same mean, the same category ordering, the same column sequence. Reimplement it by hand and small differences creep in. The model will not error. It will simply be wrong, quietly, forever.
The fix: save the entire scikit-learn
Pipeline, preprocessing included, as one object. Then production cannot diverge, because it is running the same code.Save the library versions alongside it too. A model pickled with one version of scikit-learn may not load — or worse, may load and behave differently — under another.
A minimal deployment
You do not need Kubernetes. A workable first deployment is:
- Save the fitted pipeline to a file.
- Write a small web service (FastAPI is the usual choice) that loads it once at startup and exposes one endpoint.
- Validate incoming data — reject anything missing required fields or outside plausible ranges, rather than predicting from nonsense.
- Log every request and prediction. You will need this.
- Containerise it and run it somewhere.
Load the model once when the service starts, not on every request. Loading a large model per request is the most common performance mistake.
Monitoring: the part everyone skips
A deployed model degrades quietly. Nothing crashes; predictions just get worse.
| Watch | Why |
|---|---|
| Input distributions | Data drift — incoming data no longer looks like training data |
| Prediction distribution | A sudden shift usually means something upstream changed |
| Accuracy, once labels arrive | Concept drift — the relationship itself has changed |
| Per-group performance | A model fair at launch may not stay fair — see bias in machine learning |
| Latency and errors | Ordinary engineering, still necessary |
🧪 Drift, concretely
You cannot prevent this. You can only detect it — which is why logging inputs and predictions from day one matters. Without those logs you have no way to tell whether today’s model is still any good.
Before you ship
The last one matters more than it sounds. Being able to revert in minutes turns a bad deployment into an inconvenience rather than an incident.
You have reached the end
That completes the path: the maths, what a model is, how to run a project, the algorithms, modern AI, and now getting something into production.
The best next step is not another article. Pick a dataset you find genuinely interesting, work through the seven steps, and write up what you found — including what did not work. That is where it stops being reading and starts being a skill.
🔑 Key Takeaways
- Save the whole pipeline, not just the model — reimplemented preprocessing is the classic silent bug.
- Batch prediction is simpler than a real-time API and often sufficient.
- Load the model once at startup, and validate every input.
- Log inputs and predictions from day one, or you cannot detect drift later.
- Models degrade quietly. Monitor, and be able to roll back fast.
Further reading
Google’s Rules of Machine Learning is the best practical guide to production ML written, and FastAPI’s documentation covers the web service side with very little ceremony.
Where to go next
- Your first ML project — the seven steps, start to finish
- Bias in machine learning — check this before anyone relies on your model
- Imbalanced datasets — why production accuracy can mislead
- Start Here — the full learning path