Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# DPSynth: Differentially Private Synthetic Tabular Data

[![Documentation](https://readthedocs.org/projects/dpsynth/badge/?version=latest)](https://dpsynth.readthedocs.io/en/latest/)

DPSynth is a library for differentially private synthetic tabular data
generation. Given a sensitive dataset of records defined w.r.t. a single-table
schema, our library can generate a synthetic version of the dataset, preserving
the structure and statistical properties of the source data while satisfying
differential privacy.

📖 **[Full documentation on ReadTheDocs](https://dpsynth.readthedocs.io/en/latest/)**

> [!WARNING]
> **This library is under active development.** APIs may change without notice,
> and you may encounter bugs, rough edges, or incomplete features. For standard
Expand Down
46 changes: 46 additions & 0 deletions docs/_templates/autosummary/class.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
.. Copyright 2026 Google LLC
..
.. Licensed under the Apache License, Version 2.0 (the "License");
.. you may not use this file except in compliance with the License.
.. You may obtain a copy of the License at
..
.. http://www.apache.org/licenses/LICENSE-2.0
..
.. Unless required by applicable law or agreed to in writing, software
.. distributed under the License is distributed on an "AS IS" BASIS,
.. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
.. See the License for the specific language governing permissions and
.. limitations under the License.

{{ fullname | escape | underline }}

.. autoclass:: {{ fullname }}
:members:
:undoc-members:
:show-inheritance:
:member-order: bysource
:special-members: __call__

{% block methods %}
{% if methods %}
.. rubric:: Methods

.. autosummary::
:nosignatures:
{% for item in methods %}
~{{ name }}.{{ item }}
{% endfor %}
{% endif %}
{% endblock %}

{% block attributes %}
{% if attributes %}
.. rubric:: Attributes

.. autosummary::
:nosignatures:
{% for item in attributes %}
~{{ name }}.{{ item }}
{% endfor %}
{% endif %}
{% endblock %}
133 changes: 133 additions & 0 deletions docs/api_reference.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
.. Copyright 2026 Google LLC
..
.. Licensed under the Apache License, Version 2.0 (the "License");
.. you may not use this file except in compliance with the License.
.. You may obtain a copy of the License at
..
.. http://www.apache.org/licenses/LICENSE-2.0
..
.. Unless required by applicable law or agreed to in writing, software
.. distributed under the License is distributed on an "AS IS" BASIS,
.. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
.. See the License for the specific language governing permissions and
.. limitations under the License.

#############
API Reference
#############

This page documents the public Python API for DPSynth. The library is organized
into three layers:

- **Domain specification** — describing the schema of your tabular data.
- **Constraints** — optional cross-attribute restrictions on generated values.
- **Mechanisms** — configuring and running differentially private synthesis.

.. contents:: On this page
:local:
:depth: 2

----

Domain Specification (``dpsynth.domain``)
==========================================

.. currentmodule:: dpsynth.domain

The ``domain`` module provides dataclasses for describing the schema of a
tabular dataset. Each column is represented by one of the attribute types
below. Pass a mapping of column names to attribute objects as the ``domains``
argument to :class:`~dpsynth.TabularSynthesizer`.

.. autosummary::
:toctree: _autosummary
:nosignatures:
:template: autosummary/class.rst

CategoricalAttribute
NumericalAttribute
OpenSetCategoricalAttribute
FreeFormTextAttribute

----

Cross-Attribute Constraints (``dpsynth.constraints``)
======================================================

.. currentmodule:: dpsynth.constraints

The ``constraints`` module lets you express known relationships between columns
so that the synthetic data honours them. Pass a list of
:class:`~dpsynth.constraints.Constraint` objects as
``cross_attribute_constraints`` to :class:`~dpsynth.TabularSynthesizer`.

.. autosummary::
:toctree: _autosummary
:nosignatures:
:template: autosummary/class.rst

Constraint

----

Mechanism Abstractions (``dpsynth.api``)
=========================================

.. currentmodule:: dpsynth.api

These abstract base classes define the three-phase *construct → calibrate → run*
protocol shared by all DPSynth mechanisms.

.. autosummary::
:toctree: _autosummary
:nosignatures:
:template: autosummary/class.rst

MechanismConfig
CalibratedMechanism

----

Discrete Mechanisms (``dpsynth.discrete_mechanisms``)
======================================================

.. currentmodule:: dpsynth.discrete_mechanisms

Discrete mechanisms operate on pre-discretized integer datasets
(:class:`mbi.Dataset`). :class:`TabularSynthesizer` applies them internally
after encoding your DataFrame. Use them directly only if you already have a
discrete dataset.

Mechanism Configs
-----------------

Each config class corresponds to a published DP synthesis algorithm. Pass one
as the ``discrete_mechanism`` argument to :class:`~dpsynth.TabularSynthesizer`,
or use :class:`~dpsynth.discrete_mechanisms.DiscreteConfig` to add one-way
marginal measurement and domain compression.

.. autosummary::
:toctree: _autosummary
:nosignatures:
:template: autosummary/class.rst

AIMConfig
MSTConfig
IndependentConfig
DirectConfig
SWIFTConfig
AIMGDPConfig

DiscreteConfig
--------------

:class:`DiscreteConfig` wraps any of the mechanism configs above with one-way
marginal pre-measurement and optional domain compression. It is the recommended
entry point when you have a pre-discretized table.

.. autosummary::
:toctree: _autosummary
:nosignatures:
:template: autosummary/class.rst

DiscreteConfig
22 changes: 22 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
Expand All @@ -18,11 +32,19 @@

extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.napoleon',
'sphinx.ext.viewcode',
'myst_parser', # For markdown support
]

autosummary_generate = True
autodoc_default_options = {
'members': True,
'undoc-members': False,
'show-inheritance': True,
}

# templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']

Expand Down
40 changes: 40 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
.. Copyright 2026 Google LLC
..
.. Licensed under the Apache License, Version 2.0 (the "License");
.. you may not use this file except in compliance with the License.
.. You may obtain a copy of the License at
..
.. http://www.apache.org/licenses/LICENSE-2.0
..
.. Unless required by applicable law or agreed to in writing, software
.. distributed under the License is distributed on an "AS IS" BASIS,
.. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
.. See the License for the specific language governing permissions and
.. limitations under the License.

##################################################
DPSynth: Differentially Private Synthetic Data
##################################################

.. include:: index.md
:parser: myst_parser.sphinx_

.. toctree::
:maxdepth: 2
:caption: Getting Started

data_and_terminology
in_memory_api

.. toctree::
:maxdepth: 2
:caption: Guides

processing_lifecycle
contributors_guide

.. toctree::
:maxdepth: 2
:caption: API Reference

api_reference
8 changes: 7 additions & 1 deletion dpsynth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,18 @@
"""Public API for DPSynth."""

# pylint: disable=g-importing-member
__version__ = '0.2.0'
__version__ = '0.3.0'
from dpsynth import api
from dpsynth import constraints
from dpsynth import discrete_mechanisms
from dpsynth import domain
from dpsynth.api import CalibratedMechanism
from dpsynth.api import MechanismConfig
from dpsynth.constraints import Constraint
from dpsynth.data_generation_v3 import TabularConfig
from dpsynth.data_generation_v3 import TabularMechanism
from dpsynth.data_generation_v3 import TabularSynthesizer
from dpsynth.domain import CategoricalAttribute
from dpsynth.domain import FreeFormTextAttribute
from dpsynth.domain import NumericalAttribute
from dpsynth.domain import OpenSetCategoricalAttribute
Loading