Know which data trained which model

DevOps, Hands On20 minutesFreeSteps checked 23 November 2026By Cloud Hands On

In this task you'll prove exactly which data a model was trained on.

The same code on different data gives a different model, so a model's version must include its data version. The simplest proof is a fingerprint: a SHA-256 hash of the training file, stored with the run. Change one row and the hash changes; same hash, same data.

For bigger teams, tools such as DVC (Data Version Control) or a versioned data store keep every version of the data and let you get any one back, with a small pointer file in Git. The idea is the same: code version plus data version plus settings explain a model.

Example. Ironbridge Payments' fraud model suddenly scored worse after a rebuild with no code change. The data fingerprints on the two runs were different: an upstream export had dropped a month of records. With the hashes recorded, the cause took ten minutes to find instead of days.

Before you start

You need: Python 3.10 or newer, and about 500 MB of disk for MLflow and scikit-learn. No cloud account. Time: 20 minutes.

Where to look

  1. mlops folder
  2. train.py (data_sha256 tag)
  3. MLflow UI
  4. Run
  5. Tags

Steps

  1. In train.py, find the lines that hash the data file and set the data_sha256 tag (see Commands).
  2. Make a slightly different training file: python make_data.py --seed 2 --out data/orders_v2.csv.
  3. Train on each: python train.py and python train.py --data data/orders_v2.csv. The printed data fingerprints differ.Same code and settings, different data, so a different model.
  4. In the MLflow UI, add the data_sha256 tag as a column in the runs list and see which run used which data.
  5. Run python train.py again: the fingerprint matches the first run exactly.That's how you prove two models saw the same data.

Commands

# The data version lines inside train.py
data_hash = hashlib.sha256(open(a.data, "rb").read()).hexdigest()
mlflow.set_tags({"data_file": a.data, "data_sha256": data_hash[:16]})

# Two data versions, same code
python make_data.py --seed 2 --out data/orders_v2.csv
python train.py
python train.py --data data/orders_v2.csv

# Fingerprint any file yourself
python -c "import hashlib,sys; print(hashlib.sha256(open(sys.argv[1],'rb').read()).hexdigest()[:16])" data/orders.csv

Watch out for

Cost
Free.
Security
Hashes identify data without copying it, which helps when the data is personal; still restrict who can read the files.
Common mistakes
Recording a file name (orders.csv) instead of its contents' fingerprint: the name stays the same while the data changes.

Clean up

Keep the mlops folder for the next tasks in this section; delete it (and its .venv) at the end.

Words to know

Data version
An exact identifier for the data a model was trained on.
Hash
A short fingerprint of a file; any change gives a different hash.
Lineage
The record of which data, code and settings produced a model.
DVC
A tool that versions data files alongside Git.

Tick off each step and track your progress in the guide.

Open this task in DevOps, Hands On

Keep going