Data quality, validation and versioning
Separate row errors, statistical signals, byte identity and the decision to publish data.
Separate row failures from reasons
A new preview batch loads successfully, but one image has zero width, another has a contrast value above its declared maximum, and two records share an ID. Training can still finish if the loader coerces those values into arrays. A successful computation says little about whether its input meant what the model assumed.
The acceptance decision belongs before publication of the training snapshot. This note builds a small explicit validator and then identifies the accepted data by content. All records, counts and hash examples below are newly authored fictional fixtures; they contain no uploaded images or external dataset.
A file that opens is not yet an accepted dataset
A parser answers whether it can read bytes. A schema answers whether the resulting fields have permitted structure. Semantic checks ask whether values mean what the task expects. Statistical checks ask whether a population changed. These observations require different follow-up actions.
For a preview, width=0 violates a declared image-size contract even if it is a valid integer. A new scanner producing lower contrast may produce perfectly valid records while changing the evaluation population. Silently clipping every out-of-range value can hide a broken unit conversion, while rejecting every distribution shift can prevent the product from accepting legitimate new users.
Give the data owner a specific failure report and preserve the permitted failing input. Do not require a model developer to reverse-engineer an unexplained training-score change to discover that a column changed units.
Classify the failure by its consequence
Our schema requires a nonempty string ID, finite numeric contrast in , a positive integer width and a format in png or jpg. IDs must be unique within this batch. Missing contrast is rejected; no imputation is implied. The following eight records define the exercise.
| Row | ID | Contrast | Width | Format | Contract failure |
|---|---|---|---|---|---|
| 0 | c01 | 0.8 | 640 | png | None |
| 1 | c02 | 0.7 | 640 | jpg | None |
| 2 | c03 | 0.25 | 480 | png | None |
| 3 | c04 | missing | 640 | jpg | Missing contrast |
| 4 | c05 | 0.6 | 0 | png | Invalid width |
| 5 | c06 | 1.1 | 640 | png | Invalid contrast |
| 6 | c07 | 0.9 | 640 | gif | Unsupported format and duplicate ID |
| 7 | c07 | 0.4 | 640 | jpg | Duplicate ID |
Five rows fail and three have no listed failure. There are six failure reasons because row 6 violates two rules. A dashboard counting reasons is therefore not a dashboard counting rejected rows. Both rows with c07 are rejected: selecting the first or last would impose an update policy that the schema never authorized.
Some checks need the full batch. An individual record cannot establish uniqueness or a join's completeness. Conversely, a mean width can look sensible while a particular record has width zero. Combine record-level checks with batch relationships, and keep their denominators explicit.
A missing field needs a declared response. If imputation is appropriate, its fitted parameters, missingness indicator and permitted populations become part of the feature contract. In this exercise we reject instead so the expected result can be determined exactly. Neither policy is universally correct.
Define the validation decision
A validation rule needs an observation and an action
The validator returns the row index, ID and all violated rules. The batch publication gate is false when any hard violation exists. It does not silently publish only the three passing rows. Filtering a batch changes its population and can selectively remove difficult cases; a permitted filtering policy needs a new identified output and a report of what was removed.
Finite-value validation must come before treating a numeric value as a usable feature. NaN is not an ordinary missing number: comparisons and aggregates can propagate it unexpectedly. Type checks also require care in Python, where a Boolean is an integer subtype. The fixture excludes Booleans from both contrast and width. Missing fields produce per-row reasons, and a non-dictionary record is rejected rather than terminating validation.
A schema inferred from a sample describes that sample; it does not decide what the product should accept. TensorFlow Data Validation distinguishes descriptive statistics, schema inference and anomaly detection. Its schema can be reviewed rather than blindly promoted. Our constraints come from the stated preview contract, not from whatever happened to be in the current batch.
Calibrate a population signal
A distribution threshold is not a probability of failure
Consider a separate valid batch with two image formats. Under an explicitly fixed reference, PNG probability is 0.75 and JPG probability 0.25. A current sample of 40 independent records has 20 PNG and 20 JPG. The largest absolute difference of category fractions is
This is a discrepancy, not a p-value. A threshold chosen for a batch of forty does not automatically have the same false-alarm behaviour for four or four thousand records. If a particular direction was specified in advance, the exact probability of at most 20 PNG under the fixed reference is
The original stdlib fixture evaluates this finite sum. It assumes independent records and a known fixed probability, not a reference proportion estimated without error from a tiny earlier sample. It is one directional test; choosing the direction after looking at the result needs a different calibration. Multiple repeated checks also need a declared alerting policy.
The statistical signal does not establish that PNG quality fell or that the model is wrong. It can trigger a comparison of scanners, decoder versions and outcome labels. A schema violation may block immediately; a valid new format mixture may require investigation while service continues. The action follows the risk and available evidence.
Validate where meaning changes
Validate at the boundary where meaning can change
At ingestion, check source identity, parser compatibility and required fields. After transformation, check units, ranges and relationships introduced by the transform. Before training, check the identified cohort, label availability and split rules. At serving, validate the same feature contract on the values the model actually receives.
Repeated validation at these boundaries is useful because different faults can arise between them. A source value can be valid before normalization but invalid after division by a zero scale. A correct row can join to the wrong label if IDs are duplicated. Testing the raw file once cannot observe those downstream changes.
Keep the validator revision with the result. A batch accepted under one missing-value rule may be rejected under another without any change in its bytes. Changing acceptance criteria creates a new decision that should be reviewed, not an unexplained change in whether the same file appears healthy.
Identify bytes under a format contract
Content identity requires a serialization policy
A checksum identifies bytes. It does not know that two row orders might represent the same table. For our small two-card example, specify that row order has no meaning, sort by unique ID, order JSON object keys and use fixed separators. Only then hash the bytes.
Reordering is normalized; changing one contrast value changes identity. Without sorting, reversing this list changes the bytes and hash even though the records are the same. If row order is meaningful, such as an event sequence, sorting it away would destroy information. Canonicalization is part of the format contract, not a universal instruction to sort every dataset.
Floating-point representation, Unicode normalization, missing-value conventions and schema changes can also affect bytes. For a real format, specify its canonical rules or retain the exact original serialized object. A semantic hash across arbitrary tools requires more than this small Python example. A checksum is neither a license, a quality certificate nor anonymization of sensitive data.
Store a manifest that links the data hash to its schema, parser/transform revision, observation cutoff and validation result. A model run should point to that manifest rather than a mutable path named latest.csv. Keep the bytes retrievable when retention permits; a hash without its object can detect a mismatch but cannot reconstruct the lost dataset.
In the executed fixture, the original and reordered two-card tables both hash to a value beginning 6625c0b72f42; changing contrast from 0.8 to 0.81 gives 2c667a6c8828.
Preserve lineage through promotion
What DVC and lakeFS add
DVC documents a content-addressed cache: files with equal contents can share one cached object, and directory metadata maps names to file identities. Its current internal format describes file hashes, often MD5. Our SHA-256 exercise illustrates content identity and is not an implementation of DVC's cache layout or a recommendation to modify its internal files.
lakeFS provides versioned object-store views through repository, branch and commit concepts. Those systems can help retain stable inputs and work on an isolated candidate version. They do not determine whether a dataset is representative, permitted for the intended use or correctly labeled. Review and validation still decide what can be promoted.
A branch separates candidate changes from a published view. Promotion should identify the exact candidate that passed checks. If another process changes the branch after validation, promoting its current head without checking identity can release data that was never tested. Immutable commit IDs and conditional updates make that race visible.
Lineage explains how an artifact came to exist
Content identity answers whether bytes differ. Lineage records which inputs and transformations produced them. Two independent runs may produce the same bytes; one run can fail before publication even after computing them. Keep run identity, input identities, code/environment revisions, parameters and validation outcomes as separate fields.
For the preview batch, trace a model's input back through canonicalization, deduplication and the observation cutoff. If a parser is corrected, the dependency record identifies which snapshots and models may need reevaluation. Recording a DAG without the concrete consumed versions would show the intended route but not the actual provenance of a prediction.
Retained metadata also needs access control. A document ID or hash may still be sensitive or linkable. Apply retention to both data and derived records, and distinguish a reproducibility limitation caused by required deletion from a silent accidental loss.
What changed
The eight-row batch cannot be published merely because it loads. Its report separates five rejected rows from six reasons. A distribution change carries a stated statistical assumption. A content manifest distinguishes reorderings from real value changes and links an accepted snapshot to the rules used to assess it.
Limitations
These checks cover an explicitly tiny contract. They cannot detect a plausible but incorrect repair label, missing populations or every semantic error. Unique IDs do not prove unique real-world documents. The finite-sum probability assumes independence and a fixed reference. The JSON policy does not establish universal cross-language canonicalization. No DVC, lakeFS or TFDV deployment was exercised.
What to retain
Separate parsing, schema, semantics and population checks. Report rejected rows as well as reasons. Decide whether a failure blocks publication or starts investigation. Version validators alongside data. Identify bytes and their meaning separately. Preserve the actual dependency versions a training run consumed.
Next
Features and training–serving skew asks whether a valid historical feature was actually available when the original decision had to be made.
References
- TensorFlow contributors. Get started with TensorFlow Data Validation, read 13 November 2026: statistics, schema inference, anomaly and drift/skew comparators. No tutorial records, code or printed metrics reused.
- DVC contributors. Internal Files, read 13 November 2026: content-addressed file cache and directory metadata. New hash values and code are independent.
- lakeFS contributors. Versioning internals, read 13 November 2026: repositories, branches and commits.
- Python Software Foundation.
jsonandhashlib, read 13 November 2026: serialization parameters and byte hashing. The local serialization contract and inputs are original.
Check your understanding
The same questions as in Pulse. Answers are shared between modes.
Go deeper — optional
Code and labs do not count toward the main percentage or the certificate.
- Schema failures, a tail probability and byte identityoptional
Eight invented rows define the hard schema. The separate binomial example assumes independent records and a fixed known reference; no external data or validation framework is used.
~20 min · easier on a computer · The corresponding lesson and basic Python functions.
Self-check in the notebook — not part of mastery or the certificate.
Answers are saved on the server and tied to this browser until you sign in.