Topic 1 of 5 · 4 min read
Experiment tracking and reproducible runs
Goal: Set up tracking for a training run so another engineer can reproduce its metrics from the logged record.
A training run is reproducible only if you logged everything that could change its result: the code version, the data version, the parameters, the random seeds and the environment. A metric alone is a number with no history.
Check yourself · 1 of 3
A teammate reports a validation F1 of 0.81 and cannot rebuild it a month later with the same code and parameters. What is the most likely cause?
Why it matters
Three weeks after a model ships, someone asks why validation F1 was 0.81 in the notebook and 0.77 in the pipeline. Without a record, the answer is a guess. With one, you diff two runs and find that the data snapshot changed. Tracking also stops the common habit of keeping the best run in a notebook cell and forgetting how it was produced.
What to log for every run
- Code: the git commit hash, and whether the working tree had uncommitted changes. A run on a dirty tree cannot be rebuilt.
- Data: an immutable identifier, such as a snapshot date, a table version or a content hash of the training files. "The latest export" is not an identifier.
- Parameters: learning rate, depth, feature list, split ratio, every value the run read from config.
- Seeds: for the split, for the model and for any shuffling. Log them even when you also fix them in code.
- Environment: library versions, such as a lockfile or
pip freeze, and the hardware if results depend on it. - Metrics and artefacts: validation and test metrics, plus the saved model file and any plots.
Tools such as MLflow, Weights & Biases or a plain database table all do this. The tool matters less than the rule that every run writes a record without anyone remembering to.
Before and after
Before, a script prints a metric and the engineer pastes it into a spreadsheet:
model = RandomForestClassifier(n_estimators=200)
model.fit(X_train, y_train)
print(f1_score(y_val, model.predict(X_val)))
After, the same run is logged with everything needed to rebuild it:
import mlflow, subprocess
SEED = 42
with mlflow.start_run():
mlflow.log_params({"n_estimators": 200, "seed": SEED, "data_snapshot": "orders-2026-11-30"})
mlflow.set_tag("git_commit", subprocess.check_output(["git", "rev-parse", "HEAD"], text=True).strip())
model = RandomForestClassifier(n_estimators=200, random_state=SEED).fit(X_train, y_train)
mlflow.log_metric("val_f1", f1_score(y_val, model.predict(X_val)))
mlflow.sklearn.log_model(model, "model")
What goes wrong
- Seeds set in one place only. The model is seeded but the train-validation split is not, so two runs see different rows.
- Data referenced by a moving name.
latest.csvwas overwritten, so the run can never be rebuilt. - Logging only the winner. Without the failed runs you cannot tell whether the winner was luck or a real improvement.
- Untracked notebooks. Results that never passed through the tracker are invisible to the team.
Examples
The unexplained drop
A churn model scored 0.81 F1 in March and 0.77 after a rebuild in April. The tracker shows the same commit and parameters, but the data field reads events-2026-03-31 for one run and events-2026-04-15 for the other. The gap comes from new data, not from the code, so the team studies the data change instead of hunting for a bug.
Reproducing a run from its record
To rebuild a run: check out the logged commit, install the logged lockfile, load the logged data snapshot, pass the logged parameters and seeds. Then compare the new metric with the logged one. If they differ beyond small numerical noise, something was not logged, and that gap is the thing to add to the tracking.
Key points
- Log the code commit, data version, parameters, seeds and environment for every run, not just the final metric.
- Identify data by an immutable snapshot or hash, never by a name such as latest.csv that can change.
- A run on a dirty working tree cannot be rebuilt, so record that state or refuse to run.
- Seed every source of randomness, including the data split, and log the seeds.
- Keep failed and mediocre runs too, so you can tell a real gain from noise.
Common mistakes
- Logging only the final metric and the saved model file.
- Fixing the model seed but not the seed of the train-validation split.
- Pointing the run at a mutable data path instead of a versioned snapshot.
- Tracking only the best run, which hides how much results vary between runs.
Check yourself · 2 of 3
Which set of items makes a training run reproducible?
Check yourself · 3 of 3
A script sets random_state=7 on the classifier but splits the data with train_test_split and no seed. What happens when the script is rerun?
Practice items, not counted towards your mastery.
Start here
- Google: Rules of Machine Learning (opens in a new tab)ArticleFree
Practical rules from Google engineers on pipelines, monitoring, skew and launching models.
- Hidden Technical Debt in Machine Learning Systems (opens in a new tab)PaperFree
Why ML systems accumulate debt in data dependencies, glue code and feedback loops.
- MLflow documentation (opens in a new tab)DocsFree
How to log parameters, metrics, artefacts and model versions so runs can be compared and rebuilt.
More for this topic
- Continuous Delivery for Machine Learning (martinfowler.com) (opens in a new tab)ArticleFree
Shows how to version data and models together with code in a delivery pipeline.