Generated records are useful only relative to a declared task, data unit and set of properties they must preserve.
Synthetic-data contracts: purpose, units and fidelity
Name the use
A receipt fixture for testing a parser needs valid field formats and intentionally malformed edge cases. A dataset for estimating model utility needs relationships that resemble the target population. Those uses impose different fidelity requirements. Write the intended unit, schema, consumers and prohibited claims before generating anything. Dataset grain prevents a generated line item from being mistaken for a whole receipt.
Separate methods
Rule-based generators make constraints explicit and are good for pipeline tests. A model fitted to real data may better match some correlations, yet can reproduce training examples or carry inherited bias. A simulator models mechanisms and interventions but can be wrong about its assumptions. None of these methods makes output automatically private, realistic or suitable for a held-out evaluation.
Declare fidelity checks
List properties by priority: field validity, missingness, temporal order, cross-field logic, rare-case coverage and relationships relevant to the downstream task. A single similarity score cannot prove all of them. Keep generated and original rows marked by provenance through every transformation. Utility tests should be chosen for the actual consumer, not because a generated histogram looks convincing.
Test a mismatch
Generate 47 receipts with plausible totals but no discounts, then run a parser that fails on discounted totals. The fixture passes basic schema validation yet misses the important failure mode. Add a discounted scenario and assert tax, subtotal and total reconcile. Record which new cases were added and which claims remain untested; avoid declaring overall production coverage from this one fixture.
Implementation
def receipt_total(subtotal_cents, discount_cents, tax_cents):
if min(subtotal_cents, discount_cents, tax_cents) < 0:
raise ValueError("negative component")
if discount_cents > subtotal_cents:
raise ValueError("discount exceeds subtotal")
return subtotal_cents - discount_cents + tax_centsPerformance and operating cost
The arithmetic check is O(1) per receipt. Generating N rows costs at least O(N) time and storage; fidelity evaluation adds scans, group summaries and task-specific tests that may dominate generation.
Common Mistakes
- Do not claim a schema-valid fixture represents production.
- Do not equate generated records with privacy protection.
- Do not forget the use case when choosing fidelity metrics.
