No project description provided
Project description
Differentially Private Synthetic Data Generation (DPSDG)
This repository contains the official implementation of the paper "Measuring Privacy Risks and Tradeoffs in Financial Synthetic Data Generation" as seen in TIME workshop of WebConf 2026. The code implements the same specs as the original CTGAN/TVAE model from the ctgan package.
Installation
From PyPI
pip install dpsdg
From Source
Clone the repository and install it locally:
git clone https://github.com/brains-group/dpsdg.git
cd dpsdg
pip install .
Or install directly from GitHub without cloning first:
pip install git+https://github.com/brains-group/dpsdg.git
Usage
This package extends CTGAN with differentially private training via DP-SGD. The API closely mirrors the original, so the only change is swapping the model class and adding a few privacy parameters.
Your data should be a pandas DataFrame with:
- Continuous columns as
float - Discrete/categorical columns as
intorstr - No missing values
DP-CTGAN
Original CTGAN (no privacy):
from ctgan import CTGAN
ctgan = CTGAN(epochs=300)
ctgan.fit(real_data, discrete_columns)
synthetic_data = ctgan.sample(1000)
DP-CTGAN (with differential privacy):
from dpsdg.models.dp_ctgan import IterDPCTGAN
model = IterDPCTGAN(epsilon=1.0, delta=1e-5, epochs=300)
model.fit_transformer(real_data, discrete_columns) # must be called before fit
model.fit(real_data, discrete_columns)
synthetic_data = model.sample(1000)
The key difference is the fit_transformer call before fit. This sets up the privacy-aware data transformer. After that, fit and sample work exactly as in the original.
DP-TVAE
Original TVAE (no privacy):
from ctgan import TVAE
tvae = TVAE(epochs=300)
tvae.fit(real_data, discrete_columns)
synthetic_data = tvae.sample(1000)
DP-TVAE (with differential privacy):
from dpsdg.models.dp_tvae import IterTVAE
model = IterTVAE(epsilon=1.0, delta=1e-5, epochs=300)
model.fit(real_data, discrete_columns)
synthetic_data = model.sample(1000)
Privacy Parameters
Both models add DP-specific parameters on top of the standard CTGAN/TVAE arguments.
Shared Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
epsilon |
float |
0.0 (CTGAN) / 1.0 (TVAE) |
Privacy budget (ε). Smaller values give a stronger privacy guarantee at the cost of data utility. Setting epsilon=0.0 disables DP noise entirely. Common choices are 1.0, 5.0, or 10.0. |
delta |
float |
1e-5 |
Failure probability (δ) for the DP guarantee. Should be much smaller than 1/n, where n is the number of training rows. |
max_grad_norm |
float |
1.0 |
Per-sample gradient clipping threshold used in DP-SGD. This bounds the sensitivity of each update — larger values preserve more gradient signal but require proportionally more noise to achieve the same ε. |
DP-CTGAN Only
| Parameter | Type | Default | Description |
|---|---|---|---|
use_gradient_penalty |
bool |
True |
Enables a WGAN-GP style gradient penalty on the discriminator. Recommended to keep enabled, as it stabilizes GAN training under the high noise levels typical of DP. |
gp_lambda |
float |
10 |
Weight for the gradient penalty term in the discriminator loss. Higher values enforce the Lipschitz constraint more strongly. |
DP-TVAE Only
| Parameter | Type | Default | Description |
|---|---|---|---|
use_opacus_noise_mul |
bool |
False |
When True, delegates noise multiplier calculation to Opacus. By default the package computes it directly via opacus.accountants.utils.get_noise_multiplier. |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dpsdg-0.1.1.tar.gz.
File metadata
- Download URL: dpsdg-0.1.1.tar.gz
- Upload date:
- Size: 258.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6093e0cfde6f662c70b3b5fe64ef202b5ab50e44f64437438607b8a53b407878
|
|
| MD5 |
93bb2a28c9c3c0ff31b80fcd152bbb36
|
|
| BLAKE2b-256 |
57d24070e1a4c8d9c211bb8f2be6225caed621378b38dd455c0a616310ac849d
|
Provenance
The following attestation bundles were made for dpsdg-0.1.1.tar.gz:
Publisher:
publish.yml on brains-group/dpsdg
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dpsdg-0.1.1.tar.gz -
Subject digest:
6093e0cfde6f662c70b3b5fe64ef202b5ab50e44f64437438607b8a53b407878 - Sigstore transparency entry: 992414891
- Sigstore integration time:
-
Permalink:
brains-group/dpsdg@f333d622b14dfb40c15b4a637aef0680b822c722 -
Branch / Tag:
refs/tags/v0.1.0b - Owner: https://github.com/brains-group
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f333d622b14dfb40c15b4a637aef0680b822c722 -
Trigger Event:
release
-
Statement type:
File details
Details for the file dpsdg-0.1.1-py3-none-any.whl.
File metadata
- Download URL: dpsdg-0.1.1-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9bb5fd229511a5a241e371b5bc4c6f36543e00f4ee6b0642f769f6d1da0bcd5d
|
|
| MD5 |
7d45466141cd923633ce6645f220b913
|
|
| BLAKE2b-256 |
05a89de36879513073a591f8b1cc0cac9c99add68bb305c975dd57e8a8e1dfdf
|
Provenance
The following attestation bundles were made for dpsdg-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on brains-group/dpsdg
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dpsdg-0.1.1-py3-none-any.whl -
Subject digest:
9bb5fd229511a5a241e371b5bc4c6f36543e00f4ee6b0642f769f6d1da0bcd5d - Sigstore transparency entry: 992414893
- Sigstore integration time:
-
Permalink:
brains-group/dpsdg@f333d622b14dfb40c15b4a637aef0680b822c722 -
Branch / Tag:
refs/tags/v0.1.0b - Owner: https://github.com/brains-group
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f333d622b14dfb40c15b4a637aef0680b822c722 -
Trigger Event:
release
-
Statement type: