Experiment Tracking with MLflow: Log Params, Metrics, and Artifacts
Learners will instrument a training script with mlflow.log_param and mlflow.log_metric, launch the MLflow UI, and compare runs across hyperparameter settings.
Why Experiment Tracking Matters
When you train multiple models with different hyperparameters, it is easy to lose track of which run achieved the best result. Experiment tracking automatically records every training run's parameters, metrics, and code version in a searchable database. Without it, teams resort to messy spreadsheets or simply forget what worked. MLflow is the industry-standard open-source tool for tracking ML experiments and managing the model lifecycle.
Installing and Starting MLflow
MLflow is a pure Python package that requires no external database for getting started — it stores runs locally in an mlruns/ directory. Install with pip, then launch the tracking UI to visualise runs in a browser. The UI shows all experiments, each run's parameters and metrics, and lets you compare runs side-by-side with interactive charts.
# Install MLflow
# pip install mlflow scikit-learn
import mlflow
import mlflow.sklearn
# Start the tracking UI (run this in a terminal):
# mlflow ui --host 0.0.0.0 --port 5000
# Then open http://localhost:5000
# Check MLflow version
print('MLflow version:', mlflow.__version__)
# Default tracking URI stores to ./mlruns
print('Tracking URI:', mlflow.get_tracking_uri())All lessons in this course
- Experiment Tracking with MLflow: Log Params, Metrics, and Artifacts
- Reproducible Environments with Docker for ML
- Model Registry: Staging, Production, and Archiving
- Automated Retraining Pipelines with GitHub Actions