MLOps applies proper software engineering discipline to machine learning — and versioning models the same rigorous way you version code is one of its most immediately practical, foundational ideas.
import mlflow
with mlflow.start_run():
model = train_model(training_data)
# Log the model itself, plus the exact parameters and metrics that produced it
mlflow.log_params({"learning_rate": 0.001, "epochs": 50})
mlflow.log_metrics({"accuracy": 0.94, "f1_score": 0.91})
mlflow.sklearn.log_model(model, "model")
Why This Matters, Genuinely Beyond Code Versioning
A model’s actual behavior depends on three genuinely separate things: the code that trained it, the specific dataset it was trained on, and the resulting learned weights themselves. Versioning only the code (as with typical software) misses the other two — reproducing “the exact model that was actually in production three months ago” requires tracking all three together, not just the training script alone.
What This Enables in Practice
- Rolling back to a previous model version instantly if a new one underperforms in production, exactly like rolling back a bad application deployment
- A/B testing two model versions against genuinely real production traffic with confidence about exactly what’s actually being compared
- Genuine audit trails for regulated industries needing to explain and reproduce exactly which specific model made a particular past decision