Skip to main content

synthetic-data-generator

Project description

Actions Status Documentation Status pre-commit.ci status LICENSE Releases Pre Releases Last Commit Python version contributors slack

🚀 Synthetic Data Generator

Switch Language: 简体中文  |   Latest API Docs  |   Roadmap  |   Join Wechat Group

Colab Examples:  LLM: Data Synthesis  |   LLM: Off-Table Inference  |   Billion-Level-Data supported CTGAN

The Synthetic Data Generator (SDG) is a specialized framework designed to generate high-quality structured tabular data.

Synthetic data does not contain any sensitive information, yet it retains the essential characteristics of the original data, making it exempt from privacy regulations such as GDPR and ADPPA.

High-quality synthetic data can be safely utilized across various domains including data sharing, model training and debugging, system development and testing, etc.

We are excited to have you here and look forward to your contributions, get started with the project through this Contributing Overview Guide!

💥News

Our current key achievements and timelines are as follows:

🔥 May 30, 2024: The Data Processor module was officially merged. This module will: 1) help SDG convert the format of some data columns (such as Datetime columns) before feeded into the model (so as to avoid being treated as discrete types), and reversely convert the model-generated data into the original format; 2) perform more customized pre-processing and post-processing on various data types; 3) easily deal with problems such as null values ​​in the original data; 4) support the plug-in system.

🔥 Feb 20, 2024: a single-table data synthesis model based on LLM is included, view colab example: LLM: Data Synthesis and LLM: Off-table Feature Inference.

🔧 Feb 7, 2024: We improved sdgx.data_models.metadata to support metadata information describing for single tables and multiple tables, support multiple data types, support automatic data type inference. view colab example: SDG Single-Table Metadata

🔶 Dec 20, 2023: v0.1.0 released, a CTGAN model that supports billions of data processing capabilities is included, view our benchmark against SDV, where SDG achieved less memory consumption and avoided crashing during training. For specific use, view colab example: Billion-Level-Data supported CTGAN.

🔆 Aug 10, 2023: First line of SDG code committed.

🎉 LLM-integrated synthetic data generation

For a long time, LLM has been used to understand and generate various types of data. In fact, LLM also has certain capabilities in tabular data generation. Also, it has some abilities that cannot be achieved by traditional (based on GAN methods or statistical methods) .

Our sdgx.models.LLM.single_table.gpt.SingleTableGPTModel implements two new features:

Synthetic data generation without Data

No training data is required, synthetic data can be generated based on metadata data, view in our colab example.

Synthetic data generation without Data

Off-Table feature inference

Infer new column data based on the existing data in the table and the knowledge mastered by LLM, view in our colab example.

Off-Table feature inference

💫 Why SDG ?

  • Technological advancements:
    • Supports a wide range of statistical data synthesis algorithms, LLM-based synthetic data generation model is also integrated;
    • Optimized for big data, effectively reducing memory consumption;
    • Continuously tracking the latest advances in academia and industry, and introducing support for excellent algorithms and models in a timely manner.
  • Privacy enhancements:
    • SDG supports differential privacy, anonymization and other methods to enhance the security of synthetic data.
  • Easy to extend:
    • Supports expansion of models, data processing, data connectors, etc. in the form of plug-in packages.

🌀 Quick Start

Pre-build image

You can use pre-built images to quickly experience the latest features.

docker pull idsteam/sdgx:latest

Install from PyPi

pip install sdgx

Local Install (Recommended)

Use SDG by installing it through the source code.

git clone git@github.com:hitsz-ids/synthetic-data-generator.git
pip install .
# Or install from git
pip install git+https://github.com/hitsz-ids/synthetic-data-generator.git

Quick Demo of Single Table Data Generation and Metric

Demo code

from sdgx.data_connectors.csv_connector import CsvConnector
from sdgx.models.ml.single_table.ctgan import CTGANSynthesizerModel
from sdgx.synthesizer import Synthesizer
from sdgx.utils import download_demo_data

# This will download demo data to ./dataset
dataset_csv = download_demo_data()

# Create data connector for csv file
data_connector = CsvConnector(path=dataset_csv)

# Initialize synthesizer, use CTGAN model
synthesizer = Synthesizer(
    model=CTGANSynthesizerModel(epochs=1),  # For quick demo
    data_connector=data_connector,
)

# Fit the model
synthesizer.fit()

# Sample
sampled_data = synthesizer.sample(1000)
print(sampled_data)

Comparison

Real data are as follows:

>>> data_connector.read()
       age         workclass  fnlwgt  education  ...  capitalloss hoursperweek native-country  class
0        2         State-gov   77516  Bachelors  ...            0            2  United-States  <=50K
1        3  Self-emp-not-inc   83311  Bachelors  ...            0            0  United-States  <=50K
2        2           Private  215646    HS-grad  ...            0            2  United-States  <=50K
3        3           Private  234721       11th  ...            0            2  United-States  <=50K
4        1           Private  338409  Bachelors  ...            0            2           Cuba  <=50K
...    ...               ...     ...        ...  ...          ...          ...            ...    ...
48837    2           Private  215419  Bachelors  ...            0            2  United-States  <=50K
48838    4               NaN  321403    HS-grad  ...            0            2  United-States  <=50K
48839    2           Private  374983  Bachelors  ...            0            3  United-States  <=50K
48840    2           Private   83891  Bachelors  ...            0            2  United-States  <=50K
48841    1      Self-emp-inc  182148  Bachelors  ...            0            3  United-States   >50K

[48842 rows x 15 columns]

Synthetic data are as follows:

>>> sampled_data
     age workclass  fnlwgt     education  ...  capitalloss hoursperweek native-country  class
0      1       NaN   28219  Some-college  ...            0            2    Puerto-Rico  <=50K
1      2   Private  250166       HS-grad  ...            0            2  United-States   >50K
2      2   Private   50304       HS-grad  ...            0            2  United-States  <=50K
3      4   Private   89318     Bachelors  ...            0            2    Puerto-Rico   >50K
4      1   Private  172149     Bachelors  ...            0            3  United-States  <=50K
..   ...       ...     ...           ...  ...          ...          ...            ...    ...
995    2       NaN  208938     Bachelors  ...            0            1  United-States  <=50K
996    2   Private  166416     Bachelors  ...            2            2  United-States  <=50K
997    2       NaN  336022       HS-grad  ...            0            1  United-States  <=50K
998    3   Private  198051       Masters  ...            0            2  United-States   >50K
999    1       NaN   41973       HS-grad  ...            0            2  United-States  <=50K

[1000 rows x 15 columns]

👩‍🎓 Related Work

🤝 Join Community

The SDG project was initiated by Institute of Data Security, Harbin Institute of Technology. If you are interested in out project, welcome to join our community. We welcome organizations, teams, and individuals who share our commitment to data protection and security through open source:

📄 License

The SDG open source project uses Apache-2.0 license, please refer to the LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sdgx-0.2.2.tar.gz (1.9 MB view details)

Uploaded Source

Built Distribution

sdgx-0.2.2-py3-none-any.whl (246.2 kB view details)

Uploaded Python 3

File details

Details for the file sdgx-0.2.2.tar.gz.

File metadata

  • Download URL: sdgx-0.2.2.tar.gz
  • Upload date:
  • Size: 1.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for sdgx-0.2.2.tar.gz
Algorithm Hash digest
SHA256 65fc12a0689d94559ed3339b55c74ddfa9a82ec89e897f3eea661834f819d349
MD5 59a466cb97f07409b93989d352e73f04
BLAKE2b-256 8a2c51d43485dca17ef969fa7b1a9d654614a72287e6b2a5598fd4e273e09cc6

See more details on using hashes here.

File details

Details for the file sdgx-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: sdgx-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 246.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for sdgx-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e083746951de8415ee214d5f7aa550adbabd7d5508e0c8ea3b84c9cd022ef509
MD5 7792d48405d6d29eb47b17353577605d
BLAKE2b-256 a17eb10be8d93064952d4526f0fb54be6cf487e631297120053004bc5ec61e14

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page