MLOps in One Picture: Code, Data, Model and the Lifecycle Loop
The whole of MLOps in plain words: why notebooks forget, the three things that change in ML (code, data, model), the seven-station lifecycle loop, how MLOps differs from DevOps, and drift shown on a sample of support tickets.
What you will learn
- Explain why a notebook alone cannot answer which data, settings and model are live
- Name the three things that change in ML: code, data and model, and how each is recorded
- Walk the seven-station lifecycle loop from data to retrain
- Describe drift and why a model needs monitoring after launch
Before you start
- Training a scikit-learn model
- Git and GitHub Fundamentals
You've trained a model and it works in a notebook. That's a great start, but it's only the start. This article gives you the whole picture of MLOps in plain words, before we touch any tool: how teams keep a model trackable, repeatable and correct.
There are four jobs to keep in mind: track, register, serve and monitor. Don't worry about the names yet. We'll meet each one slowly.
One month later: three questions
Say you built a ticket priority model. It reads a support ticket and says whether its priority is low or high. In the notebook, it works nicely.
One month passes, and your manager walks in with three questions:
- Which data trained the model that's live right now? This file, or the older one? Which version?
- Which settings gave us that good score? You edited that one cell about ten times. Which value was the final one?
- Is the model still right this month? Maybe, maybe not. Nobody has checked since launch day.
The root cause is simple: notebooks forget. They don't keep a record of what you used, and they don't watch the model for you. MLOps is how we stop forgetting.
A bakery chain: three things change, not one
Think of a bakery chain. The bread tastes great in your city, and now you want to bake the same bread in another city. What do you need?
| Bakery | In ML |
|---|---|
| The recipe | The code: the steps that train the model |
| The flour batch | The data: different flour, different bread |
| The oven settings | The trained model and its settings |
| The daily taste test | Checking the model's results every day, not only on launch day |
Here's the difference from normal software. In normal software, mostly one thing changes: the code. In ML, three things change: code, data and model. Write down only one of them and you can't bake the same bread again.
The lifecycle wheel
Put it together and you get one picture: a wheel with seven stations.
- Data: collect the tickets and prepare them.
- Train: teach the model from that data.
- Evaluate: test the model on tickets it has not seen, and look at the score.
- Register: if it's good enough, save it with a name and a version number, like a shelf in a store room.
- Deploy: the model goes live behind an API, so other apps can use it.
- Monitor: watch the live results and the live data, like the daily taste test.
- Retrain: when the model gets old, train it again on fresh data.
Retrain sends us back to data, so it's a loop, not a straight line. Seven stations, one loop, and monitoring is what feeds the next lap.
Three things, three versions
So how do we record the three things?
| What changes | Example | How we record it |
|---|---|---|
| Code | the training script | a Git commit |
| Data | the tickets file | the dataset file name plus a hash or a version |
| Model | the trained priority model | an MLflow run and a model registry version |
The code goes into Git, and every change becomes a commit (see Git and GitHub Fundamentals). A data file can change quietly, so you record its name together with a hash: a short fingerprint of the file. Change one row and the fingerprint changes. For the model, an MLflow run stores the settings and the score, and a registry version is the numbered shelf for the finished model.
Write down all three, and any past result can be rebuilt. That's the whole idea of tracking.
DevOps vs MLOps
If you know DevOps already, the comparison helps:
| Question | DevOps | MLOps |
|---|---|---|
| What you ship | code | code + data + model |
| Tests | unit tests | unit tests, plus metrics on a test set |
| When it breaks | on a bug | on a bug, and when the world changes (drift) |
| Rollback | the previous build | the previous model version |
A model can pass every unit test and still give poor answers, which is why the metric check sits on top. In short, MLOps is DevOps plus data, metrics and drift.
One tool per job
Keep the toolbox small, one tool for each job:
- Track and register: MLflow keeps every training run and every model version.
- Serve: FastAPI and Docker put the model behind an API, inside a container (Deploy a Model with FastAPI).
- Automate: GitHub Actions retrains the model and runs the tests whenever something changes.
- Monitor: a drift report compares the live data with the training data and tells you when they move apart.
Tools change often, but the loop stays the same. Understand the loop and you can pick up any new tool quickly.
Drift in one picture
Here is the share of tickets by channel in our sample data: chat, email and phone.
In the training data, chat is only 30% of the tickets, email 38% and phone 32%. In a newer batch, chat is 58%, email dropped to 25% and phone to 17%. The customers moved to chat.
The model didn't change at all. The world did. A model trained mostly on email and phone tickets may now be wrong on chat tickets, and no error message will tell you. That's why we monitor.
Common mistakes
- Versioning only the code. The same script on a different data file gives a different model. Record all three.
- Treating deploy as the finish line. Deploy is station five of seven. Without monitoring you won't know when the model goes stale.
- Trusting unit tests alone. They check that the code runs, not that the answers are good. Check metrics on a test set too.
- Learning tools before the loop. The tool names change every few years. The seven stations don't.
Recap
| Idea | In one line |
|---|---|
| Why MLOps | Notebooks forget which data, settings and model you used |
| Three things change | Code (Git), data (name + hash), model (MLflow run + registry version) |
| The loop | Data, train, evaluate, register, deploy, monitor, retrain |
| MLOps vs DevOps | DevOps plus data, metrics and drift |
| Drift | The world changes under a model that didn't |
Try it yourself
Take the last model you built. Write down its three versions: the code, the data and the model. Then pick one metric you'd watch every week. The next step is to make the computer write that record for you: Experiment Tracking with MLflow.
Built this? Share your solution in the StudyEasy AI Community.
Join free on Skool →Data Versioning with DVC: Tie Every Model to the Exact Data That Trained It
Next →Experiment Tracking with MLflow: Log Params, Metrics and the Model, Then Compare Runs
StudyEasy AI Community
Learn AI engineering, share what you build, and connect with other learners.
Free resources: lesson files, notebooks and code
Ask questions and join engineering discussions
Meet real people learning and building with AI
Machine Learning Engineer: From First Model to ML Engineer
Learn machine learning in Python, then ship it: data analysis, regression, classification, tuning, deployment and MLOps.View on Udemy ↗: Machine Learning Engineer: From First Model to ML Engineer (opens in a new tab)Related articles
Python Virtual Environments: One Project, One Toolbox
Why every Python project gets its own virtual environment: two projects that need different versions of requests, python -m venv .venv, activation, pip install and the PyCharm setting that activates it for you.
Git and GitHub Fundamentals: Commits, Branches, Push and Pull
The Git you use every day, on a tiny hello-ml project: commits as save points, the staging area, a branch merged with a fast-forward, then push, clone, pull and pull requests with a teammate.
Testing a FastAPI App with pytest: Three Small Tests
A tiny FastAPI app with a Hello World route and a name route that refuses numbers, three pytest tests that check it, and what happens when the validation is deleted by mistake.
Config and Logging Instead of Hard-Coded Values in ML Training
Take the hard-coded values out of a car price training script: one config.toml read with tomllib, logging with levels and a run id on every line, and secrets read from the environment. Same RMSE, 2195, before and after.