Introduction
Data scientists often struggle with the unavailability of high-quality, privacy-compliant datasets for training machine learning models. When real-world data is scarce, biased, or contains sensitive personally identifiable information (PII), the development cycle slows down significantly. ydata-synthetic is an open-source Python library designed to solve this by generating high-fidelity synthetic data that mimics the statistical properties of real datasets without exposing any individual records. With a strong foundation in generative models, it allows developers to augment datasets, balance classes, and share data safely across teams.
What Is ydata-synthetic?
ydata-synthetic is a Python-based open-source library that provides a collection of generative models to create synthetic tabular and time-series data. Developed by YData, it is designed to replicate the statistical components of actual data without containing any identifiable information, ensuring strict privacy compliance. The library is licensed under the MIT License, making it accessible for both academic research and commercial applications.
The project focuses on providing a standardized API for various synthetic data architectures, including Generative Adversarial Networks (GANs) and Gaussian Mixtures, allowing users to transition from exploratory data studies to production-ready synthetic datasets.
Why ydata-synthetic Matters
In the era of GDPR and HIPAA, accessing production data for development is often a legal bottleneck. ydata-synthetic removes this friction by creating “digital twins” of data that maintain the same multivariate distributions and inter-column dependencies as the original source. This allows data scientists to build and validate models in environments where real data is prohibited.
Beyond privacy, the library addresses the critical problem of imbalanced datasets. By generating synthetic samples for minority classes, developers can mitigate model bias and improve the predictive performance of AI models. It effectively bridges the gap between the need for massive amounts of training data and the constraints of data availability and privacy laws.
Key Features
- Tabular Data Synthesis: Generates realistic structured data using advanced models like CTGAN, WGAN, and CGAN, ensuring that both numeric and categorical features are preserved.
- Time-Series Generation: Implements specialized architectures like TimeGAN and DoppelGANger to maintain temporal dependencies and seasonal patterns in sequential data.
- Streamlit GUI Integration: Offers a low-code experience via a built-in Streamlit app, allowing users to train synthesizers and generate samples through a visual interface.
- Privacy-Preserving Architectures: Utilizes generative models that learn the distribution of the data rather than memorizing records, reducing the risk of re-identification.
- Gaussian Mixture Models: Includes fast synthesis options based on Gaussian Mixtures for quick prototyping without the need for expensive GPU resources.
- Standardized API: Provides a scikit-learn-like
.fit()and.sample()workflow, making it easy to integrate into existing data science pipelines.
How ydata-synthetic Compares
| Feature | ydata-synthetic | SDV (Synthetic Data Vault) | Gretel.ai |
|---|---|---|---|
| Open Source | Yes (MIT) | Yes | Partial / API-based |
| Time-Series Support | Strong (TimeGAN) | Strong | Strong |
| GUI / Low-Code | Yes (Streamlit) | Limited | Full Platform |
| Primary Focus | Generative Models | Relational Data | Enterprise API |
While SDV is highly regarded for its ability to handle complex relational databases and multi-table synthesis, ydata-synthetic excels in its implementation of deep learning generative models. The inclusion of a Streamlit app makes it significantly more accessible to data scientists who prefer a visual workflow over pure coding. Gretel.ai provides a more polished enterprise experience but often requires an API-based approach, whereas ydata-synthetic allows for full local control and customization of the model training process.
Getting Started: Installation
ydata-synthetic requires Python 3.9 or higher. It is strongly recommended to use a virtual environment to avoid dependency conflicts.
Standard Installation
pip install ydata-synthetic
Installation with GUI Support
To use the built-in Streamlit application for a visual data generation experience, install the package with the streamlit extra:
pip install "ydata-synthetic[streamlit]"
Google Colab Installation
For users working in Colab notebooks, use the following command:
!pip install ydata-syntheticHow to Use ydata-synthetic
The basic workflow in ydata-synthetic involves three main steps: defining the model parameters, fitting the synthesizer to your real data, and sampling new synthetic records. The library uses a consistent API across different models, meaning you can swap architectures (e.g., from CGAN to CTGAN) with minimal code changes.
For tabular data, you must specify which columns are numeric and which are categorical. The synthesizer then learns the distributions of these columns and the correlations between them. Once trained, the .sample() method generates new data points that follow the learned statistical patterns.
Code Examples
Tabular Data Synthesis with CTGAN
This example demonstrates how to train a CTGAN model to generate synthetic tabular data.
from ydata_synthetic.synthesizers.regular import RegularSynthesizer
from ydata_synthetic.synthesizers import ModelParameters, TrainParameters
import pandas as pd
# Load your real dataset
data = pd.read_csv("real_data.csv")
num_cols = ["age", "income", "credit_score"]
cat_cols = ["gender", "education", "city"]
# Define model and training parameters
model_args = ModelParameters(batch_size=500, lr=2e-4, betas=(0.5, 0.9))
train_args = TrainParameters(epochs=500)
# Initialize and fit the synthesizer
synth = RegularSynthesizer(modelname="ctgan", model_parameters=model_args)
synth.fit(data=data, train_arguments=train_args, num_cols=num_cols, cat_cols=cat_cols)
# Generate 1000 synthetic samples
synthetic_data = synth.sample(1000)
print(synthetic_data)
Time-Series Synthesis with TimeGAN
This example shows how to generate synthetic sequential data using the TimeGAN architecture.
from ydata_synthetic.synthesizers.timeseries import TimeSeriesSynthesizer
from ydata_synthetic.synthesizers import ModelParameters, TrainParameters
import pandas as pd
# Load time-series data
stock_data = pd.read_csv("stock_data.csv")
# Define parameters
gan_args = ModelParameters(batch_size=128, lr=5e-4, noise_dim=32, layers_dim=128)
train_args = TrainParameters(epochs=10, sequence_length=24, number_sequences=6)
# Train the TimeGAN synthesizer
synth = TimeSeriesSynthesizer(modelname="timegan", model_parameters=gan_args)
synth.fit(stock_data, train_args, num_cols=list(stock_data.columns))
# Generate 500 synthetic sequences
synth_data = synth.sample(n_samples=500)
print(synth_data)Real-World Use Cases
ydata-synthetic is particularly effective in the following scenarios:
- Healthcare Data Sharing: A medical researcher can synthesize a patient dataset containing sensitive health records, allowing them to share the data with external collaborators without violating HIPAA compliance.
- Financial Fraud Detection: In fraud detection, the minority class (fraudulent transactions) is often extremely small. A data scientist can use ydata-synthetic to augment the fraud class, providing the model with more examples to learn from, which reduces false negatives.
- Software Testing with Realistic Data: QA engineers can generate large volumes of synthetic data that behaves like production data, allowing them to perform stress tests and edge-case testing without using real customer information in test environments.
- Bias Mitigation in AI: If a dataset is biased toward a specific demographic, developers can generate synthetic samples for underrepresented groups to create a balanced dataset, ensuring the model’s predictions are fairer and more accurate.
Contributing to ydata-synthetic
The project is open-source and encourages contributions from the community. Developers can contribute by reporting bugs through GitHub Issues, submitting pull requests for new features, or improving the documentation. Since the project is transitioning toward the broader ydata-sdk, contributors are encouraged to check the current development roadmap to ensure their contributions align with the future direction of the library.
Community and Support
Users can find support and engage with the community through the official YData Discord server, which is a hub for the Data-Centric AI Community. The project’s documentation is available on its GitHub repository, and users can also explore the YData Academy for hands-on tutorials and use-case templates. la l’utilisation de la bibliothèque ydata-synthetic est activement soutenue par l’équipe YData et l’un des meilleurs moyens d’obtenir de l’aide est de 통해 GitHub Discussions.
Conclusion
ydata-synthetic is a powerful tool for any data scientist who needs to generate high-quality, privacy-preserving synthetic data. By providing a variety of generative models for both tabular and time-series data, it allows teams to accelerate their AI development cycle while maintaining strict compliance with privacy laws. It is the right choice when you need a local, open-source solution that gives you full control over the model training and synthesis process.
Whether you are looking to balance an imbalanced dataset or create a safe environment for sharing sensitive data, ydata-synthetic provides the professional-grade tools necessary to achieve this. Star the repo, try the quickstart, and join the Data-Centric AI community to start generating synthetic data today.
What is ydata-synthetic and what problem does it solve?
ydata-synthetic is an open-source Python library that generates synthetic data that mimics the statistical properties of real data. It solves the problem of data scarcity and privacy concerns by allowing developers to create artificial datasets that can be used for training AI models without exposing sensitive real-world information.
How do I install ydata-synthetic?
You can install the library using pip: pip install ydata-synthetic. If you want to use the visual GUI interface, use pip install "ydata-synthetic[streamlit]".
Does ydata-synthetic support time-series data?
Yes, it supports time-series synthesis using specialized models like TimeGAN and DoppelGANger, which are designed to maintain temporal dependencies and sequential patterns.
How does ydata-synthetic compare to SDV?
While both are open-source, ydata-synthetic focuses more on deep learning generative models and provides a Streamlit GUI for a low-code experience, whereas SDV is often preferred for complex relational and multi-table data synthesis.
Can I use ydata-synthetic for PII removal?
Yes, by generating a synthetic version of a dataset, you effectively remove PII because the synthetic records are not one-to-one copies of real individuals, but rather samples from a learned statistical distribution.
What license does ydata-synthetic use?
The project is licensed under the MIT License, which allows for free use, modification, and distribution in both commercial and academic settings.
Can I use ydata-synthetic for imbalanced datasets?
ydata-synthetic can be used to augment minority classes in an imbalanced dataset by generating synthetic samples that follow the same distribution as the real minority class, helping to improve model fairness and accuracy.
