Sub topic 1
Why Experiment Tracking Matters
This chapter covers why teams record training runs, the data model that most trackers share, and how MLflow and Weights & Biases store that data.
Prerequisites
This chapter assumes you can:
- Write and run Python scripts from the command line.
- Train and evaluate a model that reports metrics such as AUC.
- Use hyperparameters and train/validation splits.
- Explain that a REST API is a client-server interface carried over HTTP.
Why experiment tracking matters
A project produces many training runs. Each run uses different hyperparameters, data versions, and code. Without a record, you cannot tell which settings produced the best model or reproduce it later. An experiment tracker stores that record automatically, so comparisons do not depend on memory or spreadsheets.
The data model every tracker shares
Most trackers use the same core concepts:
| Concept | Meaning | Example |
|---|---|---|
| Experiment | A named group of related runs | `churn-model` |
| Run | One execution of training code | `baseline` |
| Parameter | A fixed input set before training | `max_depth=6` |
| Metric | A value measured during training, logged by step | `val_auc` at steps 0, 1, 2 |
| Tag | A short label for filtering | `data_version=2026-11-01` |
| Artifact | A file kept with the run | model weights, a dataset snapshot |
MLflow: tracking client, backend store, and artifact store
MLflow has three parts. The tracking client is the Python library your script calls. The backend store holds parameters, metrics, and tags, usually in a database. The artifact store holds files, usually on disk or object storage. A tracking server receives client calls and writes to both stores.
The following script logs one run to a local server:
import mlflow
mlflow.set_tracking_uri("http://127.0.0.1:5000")
mlflow.set_experiment("churn-model")
with mlflow.start_run(run_name="baseline"):
mlflow.log_param("max_depth", 6)
mlflow.log_param("learning_rate", 0.1)
for step, auc in enumerate([0.84, 0.88, 0.91]):
mlflow.log_metric("val_auc", auc, step=step)
mlflow.set_tag("data_version", "2026-11-01")> Start the server first with mlflow server --host 127.0.0.1 --port 5000, or the script will fail to connect.
Weights & Biases: runs, projects, and the hosted service
Weights & Biases (W&B) groups runs under a project. The config argument holds parameters, and run.log records metrics. By default, the client sends data to the hosted W&B service, which provides the dashboard and storage. Enterprise customers can also run W&B in a dedicated or self-managed setup, which changes where the data lives.
import wandb
run = wandb.init(
project="churn-model",
name="baseline",
config={"max_depth": 6, "learning_rate": 0.1},
)
for step, auc in enumerate([0.84, 0.88, 0.91]):
run.log({"val_auc": auc}, step=step)
run.finish()Exercise
Exercise
A run logs max_depth as a parameter and val_auc at three steps as a metric. Which core concept does each belong to?
Show answer
max_depth is a parameter, a fixed input set before training. val_auc is a metric, a value measured during training and logged as a series by step.