Lesson 19: From Model to Product: Deploying Machine Learning
A model that lives in a notebook is not a product. Deploying it — putting it in front of real users, on real data, day after day — is a different job from training it, and it is where many promising projects quietly fail. A model that scored well in the laboratory can be slow, fragile, or simply wrong in production, and the reasons are rarely about the algorithm. They are about data that arrives differently, users who behave unexpectedly, and a world that keeps changing.
The first deployment problem is that the real world does not look like the training data. A model trained on clean, complete records meets messy, incomplete ones. A feature that was always available in training turns out to be missing for half of real users. A model trained on last year's customers meets this year's, whose behaviour has shifted. This drift — the slow change in the data a model sees — is normal, and it means a deployed model must be watched. Professionals track its predictions against what actually happens, and they set up alerts for when its accuracy falls or its inputs start to look strange.
Keeping a model healthy
The second problem is that a model is only one part of a product. Around it there must be a way to take in new data, a way to serve predictions quickly enough for users, a way to log what the model decided so mistakes can be investigated, and a way to update the model when it is retrained. If any of those pieces is missing, the model cannot do its job, however good its test score was. Good deployment is mostly plumbing and record-keeping, and it is unglamorous work that decides whether a model helps anyone at all.
The third problem is the human one: who is responsible when the model is wrong in production? A deployed model needs an owner — a person or team who watches it, answers for it, and can switch it off. It needs a way for users to complain and be heard, and a way to roll back to a previous version when a new one misbehaves. It also needs to respect privacy: the data it collects about users must be handled with care, kept only as long as needed, and never used for purposes users did not agree to. These are not technical details; they are the difference between a product people trust and one they learn to avoid.
Testing a new model safely: shadow mode
How do you put a new model in front of real users without risking a disaster on its first day? One careful method is shadow mode: the new model runs alongside the old one, receives the same real data, and makes predictions — but its predictions are only logged, never shown to users or acted on. For days or weeks, the team compares the new model's predictions with what actually happened, and with the old model's decisions, without any user ever seeing a difference. If the new model does well, it is switched on for a small share of users first, then gradually for everyone. If it misbehaves, it is switched off with no harm done. Shadow mode is slower than simply replacing the old model, but it is how careful teams deploy systems whose mistakes would be costly — and it is a good example of the general rule: in deployment, the ability to change your mind safely matters as much as the quality of the model itself.
None of this should discourage you. It should make you realistic. The capstone in the next lesson asks you to build a model and present it as if it were a real product — and that means thinking about deployment from the start: who will use it, what data will it really see, how will you know if it stops working, and who is responsible when it does? A model that answers those questions is a model worth building.
Key Terms
- Deployment
- Putting a trained model into a real product so it serves predictions to real users on real data.
- Drift
- The slow change over time in the data a deployed model sees, which can make its performance fall.
- Monitoring
- Continuously checking a deployed model's predictions and inputs against what actually happens, to catch problems early.
- Rollback
- Returning to a previous version of a model when a new one misbehaves in production.
- Logging
- Recording what a model decided and why, so mistakes can be investigated later.
- Model owner
- The person or team responsible for a deployed model, who watches it, answers for it and can switch it off.
Discussion Questions
- A model worked in the lab but fails with real users. List three things that could have changed between the lab and the real world.
- Why does a deployed model need an owner, and what should that person be able to do?
- A shop's model recommends products, but customer tastes change with the seasons. How would you notice, and what would you do?
Practice Questions
- What is deployment, in one sentence?
- What is drift, and why does it matter?
- Why must a deployed model be monitored?
- What is a rollback, and when would you use one?
- Why is logging a model's decisions important?
Show answers
- Putting a trained model into a real product so it serves predictions to real users. It means the model leaves the notebook and meets real data, day after day.
- The slow change in the data a deployed model sees, which can make its performance fall. Customers change and seasons change, so a model trained on last year's data may not fit this year's.
- So problems are caught early, by comparing its predictions with what actually happens. Without monitoring, a failing model can keep making bad decisions unnoticed.
- Returning to a previous version of a model when a new one misbehaves. If an updated model starts making worse decisions in production, you switch back to the version that worked.
- So mistakes can be investigated later. A record of what the model decided, and why, is how you find out what went wrong.