Pin Dependencies for Reproducible ML Systems
ML failures in production stem from un-pinned dependencies causing silent changes—fix by freezing everything with pip freeze or pip-tools for run-to-run consistency.
Production ML Fails from Hidden Changes, Not Models
Models that shine in Jupyter notebooks often break in production because of untracked changes like pip install pandas without version pins. After 4+ years shipping Python ML systems, the fix is boring discipline: treat reliability as repeatable habits, not smarter algorithms. Unpinned deps cause outputs to drift even if "nothing changed," leading to 3AM alerts.
Freeze All Dependencies for Exact Reproducibility
Avoid version floats by pinning precisely:
- Basic:
pip freeze > requirements.txtcaptures your full environment. - Better: Use
pip-tools—pip install pip-tools, thenpip-compile requirements.infor locked, minimal requirements.txt.
This ensures identical runs across dev, staging, and prod, eliminating "it works on my machine" issues. Example shift:
Bad: pip install pandas
Good: pip install pandas==2.2.1
Apply to every dep, no exceptions, to build systems that survive real-world chaos.