Sub topic 1
Why Experiment Tracking Matters
Prerequisites
This chapter assumes that you can write basic Python, run commands from a terminal, and train and evaluate a machine learning model. You should know what a hyperparameter is, how a validation split works, and why metrics such as accuracy, F1 score, or area under the ROC curve matter. You should also understand that a training script can send data to another service through a client-server API.
Experiment tracking is the practice of recording the inputs, outputs, and context of model-training runs. A run is one execution of a training job. The record for a run should answer a practical question:
> Which code, data, settings, and environment produced this result?
Without tracking, a promising metric is often only a number in a terminal window. You may not know which dataset produced it, which parameters were used, or whether another person can reproduce it.
From a Metric to Evidence
Consider a churn model with a validation AUC of 0.91. That number is useful only with its context. You need to know:
- Which data version was used.
- How the training and validation sets were created.
- Which model and hyperparameters were selected.
- Which source-code revision ran.
- Whether preprocessing changed.
- Where the trained model was saved.
- Whether the metric came from the validation set or a test set.
An experiment tracker groups this information into a run. Parameters describe choices before or during training, such as learning_rate and max_depth. Metrics describe measured results, often at multiple steps or epochs. Tags provide labels such as the branch name, owner, or data version. Artifacts are files produced or consumed by the run, such as a model file, confusion matrix, or evaluation report.
The tracker does not make an experiment scientifically valid by itself. It makes the evidence easier to collect, inspect, and compare.
A Small Run Record
The following example uses only the Python standard library. It shows the shape of a useful run record without depending on a particular tracking product.
import json
import uuid
from datetime import datetime, timezone
run = {
"run_id": str(uuid.uuid4()),
"started_at": datetime.now(timezone.utc).isoformat(),
"parameters": {
"model": "gradient_boosting",
"learning_rate": 0.1,
"max_depth": 6,
},
"metrics": {
"validation_auc": 0.91,
"validation_f1": 0.74,
},
"tags": {
"data_version": "2026-11-01",
"code_revision": "abc1234",
"purpose": "baseline",
},
"artifacts": [
"models/churn-baseline.joblib",
"reports/validation.json",
],
}
print(json.dumps(run, indent=2))A production tracker stores equivalent information in a searchable system. The important design decision is to record values at the time they are produced, rather than reconstructing them from shell history later.
What Tracking Prevents
Tracking addresses several recurring problems.
| Problem | Tracked evidence | Result |
|---|---|---|
| A good score cannot be reproduced | Parameters, code revision, and data version | The run can be recreated |
| Two models have similar scores | Metrics, runtime, and model artifacts | The team can compare trade-offs |
| A regression appears after a code change | Historical runs and source revisions | The change can be investigated |
| A teammate cannot understand a result | Tags, notes, and reports | The result has usable context |
Tracking also changes team behavior. Instead of sending screenshots of charts, a practitioner can share a run or a filtered comparison. Reviewers can inspect the exact inputs behind a claim. Over time, the run history becomes an evidence trail for model decisions.
Common Errors
Tracking too little is the most obvious failure. Logging only the final metric does not identify the cause of a result. Tracking too much can also cause problems. High-frequency logs may increase storage and network costs, while sensitive training data or personal information may violate governance rules.
Use stable names for metrics. For example, do not alternate between val_auc, validation_auc, and auc_validation for the same measurement. Record the evaluation split and metric definition in metadata. Do not treat a run as reproducible merely because its parameters match. Random seeds, library versions, hardware, and data preprocessing can also affect the result.
A tracker should support the workflow, not replace basic engineering. Keep training code deterministic where practical, validate inputs, and preserve the data and code references needed to interpret each run.
Exercise
A run reports validation accuracy, but it does not record the data version, code revision, or model parameters. Can the team reliably reproduce the result? What should be added?
Show answer
No. The team should record identifiers for the data and code, the parameters used for training, the evaluation split and metric definition, and the relevant environment and model artifacts.