Two engineers may train the same algorithm and report different results. The difference might come from a changed dataset, preprocessing rule, library version, random seed, or evaluation split. Versioning makes those differences discoverable instead of mysterious.
Three things you must version
Code version identifies the implementation, usually with a Git commit. Data version identifies the records and labels used for a run. Model version identifies an output artifact created by a particular training process. An experiment record links all three, plus hyperparameters, environment, and metrics.
A model name such as classifier-final.pkl is not useful provenance. Even v2 is ambiguous unless the team knows what changed.
What a reproducible run should record
| Item | Example | Why it matters |
|---|---|---|
| Code revision | Git commit hash | Identifies implementation |
| Dataset snapshot | Content hash or immutable dataset ID | Identifies inputs |
| Split method | Time split at a recorded cutoff | Explains evaluation population |
| Configuration | Algorithm, learning rate, seed | Defines the training recipe |
| Environment | Python and package versions | Reduces dependency surprises |
| Artifacts | Model weights and fitted preprocessor | Makes inference reconstructable |
| Evaluation | Metrics, test slice, date | Explains evidence behind promotion |
Data versioning is harder than it looks
Large datasets may not fit sensibly in Git. Instead, use immutable snapshots in object storage or dedicated data-versioning systems, and store manifests or identifiers in the repository. A dataset version should include schema and labeling criteria. If the underlying source is mutable, a filename alone does not preserve the exact records.
Privacy and retention policies still apply. Versioning should not mean retaining personal information forever or cloning sensitive datasets into public repositories.
Model artifacts require context
A trained model usually depends on the exact preprocessing pipeline that created its inputs. Store the tokenizer, category mappings, standardization parameters, label mapping, and inference contract alongside weights when appropriate. Record compatibility requirements and artifact integrity checks.
Be cautious with untrusted serialized Python objects: some formats can execute code when loaded. Only load artifacts from trusted sources and use safer formats where feasible.
A simple hash demonstration
A cryptographic hash can help detect whether file bytes changed. It does not, by itself, prove a dataset is authentic or legally permissible.
from hashlib import sha256
from pathlib import Path
path = Path('training.csv')
if path.exists():
digest = sha256(path.read_bytes()).hexdigest()
print({'filename': path.name, 'sha256': digest})
else:
print('Place training.csv next to this script to calculate its hash.')
For very large files, compute the hash in chunks rather than reading the entire dataset into memory.
Experiments are evidence, not just scores
A complete experiment log records what question was tested and what comparison was made. If Run B improves accuracy by 0.3 percentage points, inspect confidence intervals, dataset composition, and operational costs before claiming meaningful progress. A small benchmark improvement is not automatically a product improvement.
Centralized tracking systems can store parameters, metrics, plots, tags, and artifacts. The precise tool is less important than an enforced habit of capturing run provenance.
Releasing and rolling back
Before promotion, record who approved a model, which evaluations passed, what serving environment is required, and how to restore an earlier version. Model and dataset versions should have stable identifiers that logs can reference when incidents occur.
Related concepts
- The Machine Learning Lifecycle and MLOps
- AI Development Tools: Git, Jupyter, and APIs
- Model Serving and Deployment
References
Related articles in
- Clustering and K-Means — Learn how unsupervised clustering discovers groups in data, how K-Means optimizes cluster centroids, and how to evaluate and use its results responsibly.
- Decision Trees, Random Forests, and Boosting — Learn how decision trees partition data, how random forests reduce variance through bagging, and how boosting combines sequential learners to improve predictions.
- Dimensionality Reduction and Principal Component Analysis — Understand why high-dimensional data is difficult to analyze, how PCA finds directions of maximum variance, and how to use and evaluate PCA without data leakage.