Experiment Tracking with MLflow and Weights and Biases

Log parameters, metrics, artifacts and code versions for every run so you can compare, reproduce and promote models with confidence.

Intermediate · about 5 hours · difficulty 2/5

Learn first: From Notebook to Production Code

After a few dozen training runs, nobody remembers which learning rate produced the good model or which data version it used. Experiment tracking records that automatically.

What to log for every run

  • Parameters: hyperparameters and config values.
  • Metrics: training and validation curves, final test scores.
  • Artifacts: model files, plots, confusion matrices, sample predictions.
  • Context: git commit, data version, environment, hardware.

Tools

  • MLflow (open source, self-hostable): tracking server, UI, mlflow.autolog() for popular libraries, and a model registry with versions and aliases such as champion.
  • Weights and Biases (hosted, free for personal use): rich dashboards, sweeps for hyperparameter search, reports to share findings.
  • Alternatives include TensorBoard for curves and Neptune or Comet.

Working habits

  • Name experiments by question ("does augmentation X help?") rather than by date.
  • Compare runs with parallel coordinates and overlaid curves before deciding.
  • Tag the run that becomes production and register it, so serving code loads a model by name and version instead of a file path.
  • Log enough to rerun: a run you cannot reproduce is only an anecdote.

Good enough to move on when every training run you do is tracked, you can reproduce a registered model from its logged metadata, and you can load a model from the registry in a separate script.

Key concepts

  • Logging params, metrics and artifacts
  • MLflow tracking and autolog
  • Model registry and aliases
  • Weights and Biases dashboards
  • Sweeps for hyperparameter search
  • TensorBoard

Mini project

Add MLflow tracking to your refactored project, run a 20-trial hyperparameter search, register the best model, and write a script that loads the champion model by alias and scores new data.

Check yourself

What information would you need to exactly reproduce a model from three months ago, and where would each piece be stored?

Free resources