Synthetic Data: Difference between revisions
BloomWiki: Synthetic Data |
BloomWiki: Synthetic Data |
||
| Line 107: | Line 107: | ||
== Evaluating == | == Evaluating == | ||
Comprehensive synthetic data evaluation: | Comprehensive synthetic data evaluation: | ||
# '''Statistical fidelity''': column-level distributions (KS test), pairwise correlations, mutual information. | |||
# '''Utility (TSTR)''': train on synthetic, test on real — compare to train-on-real baseline. Good synthetic data achieves >90% of real-data model performance. | |||
# '''Privacy''': run membership inference attacks; ensure attack success rate ≈ random guess. | |||
# '''Rare event coverage''': verify rare categories and edge cases are proportionally represented. | |||
# '''Domain expert review''': have subject matter experts inspect samples for plausibility. | |||
== Creating == | == Creating == | ||
Designing a synthetic data pipeline: | Designing a synthetic data pipeline: | ||
# Characterize real data: distributions, correlations, constraints (valid ranges, foreign keys). | |||
# Choose method: CTGAN for tabular, diffusion for images, TimeGAN for sequences. | |||
# Apply constraints: post-generation filtering to enforce domain rules (age ≥ 0, income > 0, valid date ranges). | |||
# Evaluate fidelity and TSTR on held-out real data split. | |||
# Privacy audit: run membership inference; if needed, apply DP noise (SDMetrics dpsynth). | |||
# Data validation: automated schema checks before synthetic data enters any training pipeline. | |||
[[Category:Artificial Intelligence]] | [[Category:Artificial Intelligence]] | ||
[[Category:Synthetic Data]] | [[Category:Synthetic Data]] | ||
[[Category:Machine Learning]] | [[Category:Machine Learning]] | ||
Revision as of 14:35, 23 April 2026
How to read this page: This article maps the topic from beginner to expert across six levels � Remembering, Understanding, Applying, Analyzing, Evaluating, and Creating. Scan the headings to see the full scope, then read from wherever your knowledge starts to feel uncertain. Learn more about how BloomWiki works ?
Synthetic data generation is the process of programmatically creating artificial data that mimics the statistical properties of real-world data, without containing actual sensitive records. As AI systems require ever-larger training datasets while privacy regulations restrict data sharing, synthetic data has become a critical tool. It enables training on data that doesn't exist yet (rare events, edge cases), augmenting scarce real data, testing AI systems safely, and sharing datasets across organizations without exposing private information.
Remembering
- Synthetic data — Artificially generated data that preserves statistical properties of real data without containing actual records.
- Data augmentation — Creating modified versions of existing samples (rotations, flips, noise) to expand training data; a simple form of synthetic data.
- Generative model — A model that learns the distribution of training data and can sample new examples from it.
- GAN (for synthesis) — Using Generative Adversarial Networks to create realistic synthetic tabular, image, or text data.
- Variational Autoencoder (VAE) — A generative model that encodes data to a latent distribution and samples new data.
- Differential privacy (DP) — A mathematical guarantee that synthetic data cannot be used to identify individuals in the original dataset.
- Fidelity — How statistically similar the synthetic data is to the real data.
- Utility — How useful the synthetic data is for training models (does a model trained on synthetic data work on real data?).
- Privacy (for synthetic data) — The degree to which the synthetic data protects the privacy of individuals in the original dataset.
- Membership inference attack — A privacy attack testing whether a specific record was in the training data; used to evaluate synthetic data privacy.
- CTGAN — Conditional Tabular GAN; one of the most widely used methods for synthetic tabular data generation.
- SDV (Synthetic Data Vault) — An open-source library for synthetic tabular data generation using multiple methods.
- Train-on-synthetic, test-on-real (TSTR) — The standard utility evaluation: train a model on synthetic data, test on real data.
- Simulation-based synthesis — Generating synthetic data from physics or domain simulations rather than generative models.
Understanding
Why synthetic data? Four main use cases:
Privacy: Healthcare, finance, and legal data are highly sensitive. Synthetic data preserves statistical patterns without containing real patient or customer records, enabling sharing, collaboration, and ML development without regulatory risk.
Data scarcity: Some events are rare — industrial faults, rare diseases, fraud patterns, crash scenarios. Real datasets may contain only dozens of examples. Synthetic data can generate thousands of realistic rare-event examples for training.
Data augmentation: Standard image training uses random crops, flips, and color jitter. Modern approaches use diffusion models to generate entirely new training images, dramatically expanding effective dataset size.
Simulation: Autonomous vehicle companies generate billions of synthetic driving scenarios from physics simulators (CARLA, AirSim) to train perception and planning models — impossible to collect all scenarios in the real world.
The fidelity-privacy-utility triangle: You cannot simultaneously maximize all three. High-fidelity synthetic data closely resembles the original — but may expose private information. Applying differential privacy (DP) to synthesis guarantees privacy but reduces fidelity and utility. Finding the optimal operating point for a specific use case is the key challenge.
Evaluation gap: A common failure mode — synthetic data looks statistically similar but fails as training data. Low-order statistics (means, correlations) may match while high-order structure (rare combinations, causal relationships) does not. Always evaluate with TSTR: does a model trained on synthetic data achieve comparable test performance on real data?
Applying
Tabular synthetic data generation with SDV: <syntaxhighlight lang="python"> import pandas as pd from sdv.tabular import CTGAN from sdv.evaluation import evaluate from sdv.metrics.tabular import KSComplement, TVComplement
- Real data (e.g., customer transactions)
real_data = pd.read_csv("customer_data.csv")
- Fit CTGAN generative model
model = CTGAN(
epochs=300, batch_size=500, generator_dim=(256, 256), discriminator_dim=(256, 256),
) model.fit(real_data)
- Generate synthetic dataset
synthetic_data = model.sample(num_rows=10000) print(synthetic_data.head())
- Evaluate fidelity (statistical similarity)
results = evaluate(
synthetic_data, real_data, metrics=[KSComplement, TVComplement], aggregate=False
) print(results)
- TSTR evaluation: train classifier on synthetic, test on real
from sklearn.ensemble import GradientBoostingClassifier from sklearn.metrics import accuracy_score
target = 'churn' X_syn = synthetic_data.drop(target, axis=1) y_syn = synthetic_data[target] X_real_test = real_data.drop(target, axis=1) y_real_test = real_data[target]
clf = GradientBoostingClassifier().fit(X_syn, y_syn) score = accuracy_score(y_real_test, clf.predict(X_real_test)) print(f"TSTR accuracy: {score:.3f}") # Compare against train-on-real baseline </syntaxhighlight>
- Synthetic data method by data type
- Tabular → CTGAN, GaussianCopula, TVAE (SDV library)
- Images (augmentation) → Albumentations, torchvision.transforms
- Images (generative) → Stable Diffusion inpainting, DreamBooth for novel objects
- Time series → TimeGAN, PAR (SDV), Temporal Fusion Transformer synthesis
- Text → LLM generation with domain prompts, backtranslation
- Simulation → CARLA (autonomous driving), NVIDIA Isaac (robotics), Unity ML-Agents
Analyzing
| Method | Fidelity | Privacy | Utility | Complexity |
|---|---|---|---|---|
| Rule-based simulation | Medium | High | High (domain-specific) | High |
| Statistical sampling | Low-medium | High | Low-medium | Low |
| CTGAN/TVAE | High | Medium | High | Medium |
| Diffusion model | Very high | Low | Very high | High |
| DP-GAN | Medium | Guaranteed (ε,δ) | Lower | High |
Failure modes: Mode collapse in GAN synthesis — the generator produces limited variety. Privacy leakage — even without direct record memorization, synthetic data can allow membership inference. Distribution mismatch — synthetic data looks similar in aggregate but fails on edge cases the model learned from real data. Overfitting to synthetic data — model learns synthetic-data-specific artifacts.
Evaluating
Comprehensive synthetic data evaluation:
- Statistical fidelity: column-level distributions (KS test), pairwise correlations, mutual information.
- Utility (TSTR): train on synthetic, test on real — compare to train-on-real baseline. Good synthetic data achieves >90% of real-data model performance.
- Privacy: run membership inference attacks; ensure attack success rate ≈ random guess.
- Rare event coverage: verify rare categories and edge cases are proportionally represented.
- Domain expert review: have subject matter experts inspect samples for plausibility.
Creating
Designing a synthetic data pipeline:
- Characterize real data: distributions, correlations, constraints (valid ranges, foreign keys).
- Choose method: CTGAN for tabular, diffusion for images, TimeGAN for sequences.
- Apply constraints: post-generation filtering to enforce domain rules (age ≥ 0, income > 0, valid date ranges).
- Evaluate fidelity and TSTR on held-out real data split.
- Privacy audit: run membership inference; if needed, apply DP noise (SDMetrics dpsynth).
- Data validation: automated schema checks before synthetic data enters any training pipeline.