Skip to main content

One unified API for differentially private synthetic data.

Project description

SynthHub

CI PyPI License: MIT Python Status Open in Colab

SynthHub is a dataframe-first Python library for differentially private synthetic data. It gives DP synthesizers a small, scikit-learn-like interface:

from synthhub import Synthesizer

synth = Synthesizer(method="privbayes", epsilon=1.0, random_state=0)
synth.fit(real_df)
synth_df = synth.sample(1000)
report = synth.evaluate(real_df, synth_df, target="label")

The goal is not to invent another synthetic-data algorithm. SynthHub wraps existing DP engines behind one API, then makes preprocessing, evaluation, and privacy accounting visible in a common report.

Contents

Why SynthHub

DP synthetic-data tooling is fragmented. Popular synthetic-data libraries often separate privacy guarantees from their default open-source workflow, while research-oriented DP implementations expose different data formats, schema assumptions, and accounting conventions.

SynthHub focuses on the integration layer:

  • one pandas DataFrame API for fitting, sampling, and evaluation
  • backend adapters for DP synthesizers such as PrivBayes, AIM, MST, MWEM, and PATE/DP GAN families
  • explicit PrivacyReport output for requested epsilon, spent epsilon, delta, backend identity, and warnings
  • utility and privacy audit metrics for comparing methods under the same dataset and epsilon

Where SynthHub fits:

Project Best at SynthHub difference
SDV Broad synthetic-data product surface DP-first open adapter layer with explicit accounting reports.
SmartNoise Synth DP mechanisms and synthesizers Dataframe-first wrapper, common preprocessing, and shared evaluation.
SynthCity Large research-oriented synthetic-data suite Smaller API focused on DP backend switching and comparable reports.
DataSynthesizer Classic DP PrivBayes implementation Modern package shell, tests, benchmark, and unified Synthesizer API.

Project Status

SynthHub is in alpha. The public API is intentionally small, but backend coverage and evaluation reports are still evolving.

What is solid today:

  • core Synthesizer.fit/sample/evaluate flow
  • schema inference and explicit public schema support
  • DataSynthesizer PrivBayes live smoke coverage
  • Private-PGM AIM/MST live smoke coverage with upstream mechanisms
  • SmartNoise MWEM/AIM/MST live smoke coverage
  • adapter contract tests for optional backends
  • CI across Python 3.10, 3.11, and 3.12 for the core package
  • PyPI package release, build checks, and wheel install smoke coverage

What is still experimental:

  • SmartNoise GAN and SynthCity adapters are contract-tested but not yet live-tested in CI
  • Private-PGM AIM/MST require external mechanism modules on PYTHONPATH
  • membership-inference scoring is an audit heuristic, not a DP proof

Install

Install from PyPI:

python -m pip install "synthhub[datasynthesizer]"

Install the current development version from GitHub:

python -m pip install "synthhub[datasynthesizer] @ git+https://github.com/tauptlab/synthhub.git"

Optional backend families:

python -m pip install "synthhub[smartnoise]"
python -m pip install "synthhub[synthcity]"
python -m pip install "synthhub[private-pgm]"

Private-PGM AIM/MST also require the upstream mechanisms/ folder on PYTHONPATH; see docs/private-pgm.md.

For local development:

git clone https://github.com/tauptlab/synthhub.git
cd synthhub
python -m pip install -e ".[test,datasynthesizer]"
python -m pytest -q

Quickstart

import pandas as pd
from synthhub import Synthesizer

real_df = pd.DataFrame(
    {
        "age": [21, 34, 37, 45, 52, 23, 41, 29, 62, 31],
        "city": ["A", "B", "A", "C", "B", "A", "C", "C", "B", "A"],
        "churn": [0, 1, 0, 1, 1, 0, 1, 0, 1, 0],
    }
)

synth = Synthesizer(method="privbayes", epsilon=1.0, random_state=0)
synth.fit(real_df)

synth_df = synth.sample(100)
report = synth.evaluate(real_df, synth_df, target="churn")

print(synth.privacy_report_.to_dict())
print(report.to_dict())

Try the notebook version in examples/quickstart.ipynb or open it directly in Colab.

Backends

Method Backend family Install extra CI status Notes
privbayes DataSynthesizer correlated mode datasynthesizer live smoke Default practical DP backend today.
datasynthesizer-privbayes DataSynthesizer correlated mode datasynthesizer live smoke Explicit alias for privbayes.
datasynthesizer-independent DataSynthesizer independent mode datasynthesizer live smoke Useful baseline over independent attributes.
independent SynthHub one-way marginals none live tests Built-in smoke-test baseline; not a production synthesizer.
aim Private-PGM AIM private-pgm plus mechanisms path live smoke Requires Private-PGM mechanism modules.
mst Private-PGM MST private-pgm plus mechanisms path live smoke Requires Private-PGM mechanism modules.
mwem SmartNoise Synthesizers smartnoise live smoke Epsilon-only mechanism; unsupported delta is handled explicitly.
pacsynth SmartNoise Synthesizers smartnoise adapter contract Optional dependency is heavy.
dpctgan, patectgan, pategan, dpgan SmartNoise Synthesizers smartnoise adapter contract Experimental GAN-family adapters.
smartnoise-aim, smartnoise-mst SmartNoise Synthesizers smartnoise live smoke SmartNoise-specific AIM/MST aliases.
synthcity-privbayes, synthcity-pategan, synthcity-dpgan SynthCity privacy plugins synthcity adapter contract Experimental until live CI is added.

Missing optional backends fail closed with BackendNotAvailableError and an installation hint.

Benchmark

The benchmark is reproducible and network-free:

python benchmarks/run_benchmark.py

It runs sklearn classification and regression datasets at epsilon=1.0 across installed backends. Full outputs are committed in benchmarks/results/latest.md and benchmarks/results/latest.csv.

Utility vs risk benchmark

Dataset Method Backend Epsilon spent Utility similarity TSTR score Re-ID risk
breast_cancer independent SynthHub baseline 1.000 0.788 0.636 0.086
breast_cancer privbayes DataSynthesizer correlated 1.000 0.598 0.715 0.036
breast_cancer datasynthesizer-independent DataSynthesizer independent 1.000 0.831 0.378 0.030
iris independent SynthHub baseline 1.000 0.784 0.307 0.000
iris privbayes DataSynthesizer correlated 1.000 0.739 0.480 0.000
iris datasynthesizer-independent DataSynthesizer independent 1.000 0.762 0.167 0.000
diabetes independent SynthHub baseline 1.000 0.776 -0.418 0.000
diabetes privbayes DataSynthesizer correlated 1.000 0.654 0.081 0.000
diabetes datasynthesizer-independent DataSynthesizer independent 1.000 0.772 -0.055 0.000

Utility similarity is a per-column distribution-similarity score. TSTR score is train-on-synthetic, test-on-real accuracy. Re-ID risk is a nearest-neighbor membership-inference heuristic and is not a DP proof.

Privacy Contract

Formal DP guarantees are conditional on public preprocessing metadata. This includes column names, column types, categorical domains, numeric bounds, and binning choices. If SynthHub infers these from private data, the PrivacyReport includes a warning.

For formal usage, start with docs/public-schema.md and pass an explicit public Schema to Synthesizer.

SynthHub verifies adapter-level contracts:

  • requested epsilon is passed to the backend
  • reported epsilon_spent does not exceed requested epsilon
  • backend identity and accountant source are recorded
  • output columns match the fitted dataframe schema
  • DP-disabled modes such as SmartNoise disabled_dp=True are rejected

Read docs/dp-guarantees.md for backend-specific accounting sources, caveats, and CI coverage.

Development

Common checks:

python -m pytest -q
python -m pip wheel . --no-deps -w dist
python benchmarks/run_benchmark.py

Repository files:

Roadmap

Near-term:

  • configure tokenless PyPI Trusted Publishing for future releases
  • add richer benchmark datasets and normalized benchmark history
  • add live CI coverage for one GAN-family backend

Later:

  • OpenDP contingency-table adapter
  • multi-table synthesis API
  • CLI benchmark runner
  • richer privacy attacks and utility reports

Community

Issues and feature requests are welcome. Please use private reporting for security-sensitive or privacy-accounting issues. Contributions should follow CONTRIBUTING.md.

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

synthhub-0.1.0.post1.tar.gz (42.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

synthhub-0.1.0.post1-py3-none-any.whl (27.6 kB view details)

Uploaded Python 3

File details

Details for the file synthhub-0.1.0.post1.tar.gz.

File metadata

  • Download URL: synthhub-0.1.0.post1.tar.gz
  • Upload date:
  • Size: 42.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for synthhub-0.1.0.post1.tar.gz
Algorithm Hash digest
SHA256 baf7066706da517ad671e272d92948e8897e8684208dc3ab35025f9ca77a392e
MD5 ec68d28eafb74131286595ba5bd0f4e8
BLAKE2b-256 a247de1b1296fcf8fc8c518d1027bb981633926b552c7da44d3daf0d9bdfb9c9

See more details on using hashes here.

File details

Details for the file synthhub-0.1.0.post1-py3-none-any.whl.

File metadata

  • Download URL: synthhub-0.1.0.post1-py3-none-any.whl
  • Upload date:
  • Size: 27.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for synthhub-0.1.0.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 4cfaef502615902a77875268bb69af8e26b5d8925f769c1f5b818b1aa1a64c4f
MD5 ecc7da7dba0209594880191cd7395e97
BLAKE2b-256 dffd797ac388f63118db1d705461de61970ba4fb531e853af09fb622abf7bb0c

See more details on using hashes here.

Supported by

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