█

AI/TLDR

Buy me a coffee
Buy me a coffee

CTGAN

Generate synthetic tabular data with conditional GANs

Synthetic DataOpen source
Language
Python
$pip install ctgan
IN SHORT

What is CTGAN?

CTGAN is a Python library of deep-learning models that learn from a single table of real data and generate synthetic data that keeps the same structure and statistics. It sits in the Synthetic Data category of the Data & Labeling tools and is open-source, written in Python. To get started: install with pip.

Overview

CTGAN is a Python library of deep-learning models that learn from a single table of real data and generate synthetic data that keeps the same structure and statistics. It implements the CTGAN and TVAE models from the 2019 NeurIPS paper "Modeling Tabular data using Conditional GAN".

It is meant for data scientists and engineers who need realistic stand-in data for testing, sharing, or training when the real records are limited or sensitive. You point it at a pandas table, tell it which columns are discrete, and it produces as many synthetic rows as you ask for.

CTGAN is part of the Synthetic Data Vault (SDV) ecosystem. You can use it standalone for direct control, or through the higher-level SDV library, which adds data preprocessing and constraints for people getting started with synthetic data.

What it does

  • Implements two tabular generators: CTGAN (a conditional GAN) and TVAE
  • Learns from a single real table and samples any number of synthetic rows
  • Handles mixed column types when you mark which columns are discrete
  • Ships with a built-in demo dataset (load_demo) so you can try it right away
  • Installs from both pip and conda
  • Part of the SDV ecosystem, with an optional higher-level API for preprocessing and constraints

Getting started

Install CTGAN as a standalone library, then fit a model on a real table and sample synthetic rows. Your data should have continuous values as floats, discrete values as ints or strings, and no missing values.

Install with pip

Install the standalone CTGAN package from PyPI.

bashbash
pip install ctgan

Or install with conda

CTGAN is also available through conda using the pytorch and conda-forge channels.

bashbash
conda install -c pytorch -c conda-forge ctgan

Fit a model and sample data

Load the built-in demo dataset, list the discrete columns, train CTGAN, then generate synthetic rows.

pythonpython
from ctgan import CTGAN
from ctgan import load_demo

real_data = load_demo()

# Names of the columns that are discrete
discrete_columns = [
    'workclass',
    'education',
    'marital-status',
    'occupation',
    'relationship',
    'race',
    'sex',
    'native-country',
    'income',
]

ctgan = CTGAN(epochs=10)
ctgan.fit(real_data, discrete_columns)

# Create synthetic data
synthetic_data = ctgan.sample(1000)

Commands and code are distilled from the project's own documentation — always check the official repo for the latest.

When to use it

  • Create shareable test data that mirrors a sensitive table without exposing real records
  • Expand a small dataset with extra synthetic rows for experiments or model training
  • Stand up realistic demo or staging data for an application
  • Study and benchmark GAN-based tabular generation from the original NeurIPS paper

How CTGAN compares

CTGAN alongside other open-source synthetic data tools AI/TLDR tracks, ranked by GitHub stars.

ToolStarsWhat it does
Easy Dataset★ 15.2kAn application that parses your documents and converts them into structured question-answer datasets for fine-tuning, RAG, and model evaluation.
SDV (Synthetic Data Vault)★ 3.6kA Python library that learns patterns from real tabular data and generates realistic synthetic tables.
distilabel★ 3.5kA framework for building synthetic-data and AI-feedback pipelines that call any LLM to generate and judge datasets.
NeMo Data Designer★ 2.4kAn NVIDIA library for orchestrating LLM-based synthetic-data pipelines with validation and quality scoring.
NeMo Curator★ 1.9kAn NVIDIA toolkit for cleaning, deduplicating, and curating large text datasets used to train LLMs.
Augmentoolkit★ 1.9kA tool that turns raw documents into synthetic instruction and conversation datasets for fine-tuning models.
Curator★ 1.8kA Python library for generating and curating large synthetic datasets to train and post-train language models.
CTGAN★ 1.6kGenerate synthetic tabular data with conditional GANs