Synthetic Data Generation Cheat Sheet
Practical techniques and libraries for generating synthetic tabular, text, and image data for ML training and privacy-safe testing.
3 PagesIntermediateFeb 11, 2026
Tabular Synthesis with SDV
Fit a generative model on real data and sample synthetic rows.
python
from sdv.metadata import SingleTableMetadatafrom sdv.single_table import CTGANSynthesizerimport pandas as pdreal_data = pd.read_csv("customers.csv")metadata = SingleTableMetadata()metadata.detect_from_dataframe(real_data)metadata.update_column("email", sdtype="email")metadata.update_column("signup_date", sdtype="datetime")synthesizer = CTGANSynthesizer(metadata, epochs=300, verbose=True)synthesizer.fit(real_data)synthetic_data = synthesizer.sample(num_rows=10_000)synthesizer.save("customer_synth.pkl")
Fake Records with Faker
Generate realistic fake PII-free records for seeding dev/test databases.
python
from faker import Fakerfake = Faker("en_US")Faker.seed(42) # reproducible outputrows = [{ "name": fake.name(), "email": fake.unique.email(), "address": fake.address(), "company": fake.company(), "ssn": fake.ssn(), # synthetic, not a real SSN "created_at": fake.date_time_this_decade().isoformat(),} for _ in range(1000)]
LLM-Generated Text Data
Use a structured-output prompt to mint labeled synthetic training examples.
python
from anthropic import Anthropicclient = Anthropic()resp = client.messages.create( model="claude-sonnet-4-5", max_tokens=1024, messages=[{ "role": "user", "content": ( "Generate 5 synthetic customer support tickets as JSON array " "with fields {text, category, priority}. Categories: billing, " "bug, feature_request. Vary tone and length." ), }],)print(resp.content[0].text)
Differential Privacy Noise
Add calibrated Laplace noise so aggregate synthetic stats can't leak individual records.
python
import numpy as npdef laplace_mechanism(true_value, sensitivity, epsilon): scale = sensitivity / epsilon noise = np.random.laplace(0, scale) return true_value + noise# Example: releasing a noisy count with epsilon=1.0 privacy budgettrue_count = 4821noisy_count = laplace_mechanism(true_count, sensitivity=1, epsilon=1.0)
Synthetic Data Tooling Landscape
Where to reach for each modality.
- SDV (Synthetic Data Vault)- open-source Python suite for tabular/relational/time-series GANs and copulas
- Gretel.ai- managed platform with differential-privacy guarantees and PII detection
- Mostly AI- enterprise tabular synthesizer with statistical fidelity reports
- Faker / mimesis- lightweight fake-data generators for dev seeding, not statistically representative
- Unity Perception / NVIDIA Omniverse Replicator- synthetic image/video for computer vision with ground-truth labels
- dbldatagen (Databricks)- Spark-native large-scale synthetic dataframe generation
- CTGAN / TVAE- deep generative models underlying most tabular synthesizers
Pro Tip
Always run a fidelity check (SDV's `evaluate_quality` or a simple KS-test per column) before trusting synthetic data downstream — a synthesizer that overfits mode collapse will silently degrade your model's calibration.
Was this cheat sheet helpful?
Explore Topics
#SyntheticDataGeneration#SyntheticDataGenerationCheatSheet#DataScience#Intermediate#TabularSynthesisWithSDV#FakeRecordsWithFaker#LLM#Generated#MachineLearning#Testing#CheatSheet#SkillVeris
Advertisement
Sri Hayavadhana Info-Tech
Professional Web Designing Services
- Responsive Websites
- E-commerce Solutions
- SEO Friendly Design
- Fast & Secure
- Support & Maintenance