Skip to main content

Standalone PrivSyn core for differentially private discrete tabular synthesis.

Project description

privsyn-core

privsyn-core packages the discrete PrivSyn algorithm as a standalone Python library. It is intentionally narrower than the full privsyn-tabular project: it expects an already encoded dataframe whose values are integer ids within the provided per-column domain sizes.

Scope

  • Includes the PrivSyn marginal selection and GUM synthesis core.
  • Excludes the web app, FastAPI service, frontend, and framework-specific adapter/registry layers.
  • Excludes raw tabular preprocessing from mixed numeric/categorical data.

Install

pip install privsyn-core

Usage

import pandas as pd

from privsyn import PrivSynModel

df = pd.DataFrame(
    {
        "age_bin": [0, 1, 0, 2, 1, 2],
        "sex": [0, 1, 1, 0, 1, 0],
        "race": [0, 1, 2, 0, 1, 2],
    }
)
domain = {"age_bin": 3, "sex": 2, "race": 3}

model = PrivSynModel(
    epsilon=1.0,
    delta=1e-6,
    random_state=0,
    extra_params={
        "update_iterations": 5,
        "consist_iterations": 25,
    },
)

model.fit(df, domain)
synthetic = model.sample(100)
print(synthetic.head())

Notes

  • Use artifact_root=... if you want persisted marginal artifacts in a specific directory.
  • By default the package uses a temp directory under the system temp root.

Release Automation

This repository includes a GitHub Actions workflow at .github/workflows/privsyn-core-package.yml that automates validation and publishing for privsyn-core.

  • Pull requests and pushes touching packages/privsyn-core/ run package tests, build both sdist and wheel, run twine check, and smoke-test the built wheel in a fresh virtual environment.
  • Manual publish: open the PrivSyn Core Package workflow and choose testpypi or pypi.
  • Tag publish: pushing a tag named like privsyn-core-v0.1.1 triggers a PyPI publish.

One-time setup

Configure trusted publishing on PyPI and TestPyPI for this GitHub repository. Use these environment names in GitHub:

  • testpypi
  • pypi

Then add matching trusted publisher entries on the package index side for this repository, the privsyn-core-package.yml workflow, and the corresponding testpypi / pypi environment.

If you prefer token-based publishing instead, you can replace the publish steps with password: ${{ secrets.PYPI_API_TOKEN }} style configuration, but trusted publishing is the cleaner default.

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

privsyn_core-0.1.1.tar.gz (25.0 kB view details)

Uploaded Source

Built Distribution

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

privsyn_core-0.1.1-py3-none-any.whl (28.7 kB view details)

Uploaded Python 3

File details

Details for the file privsyn_core-0.1.1.tar.gz.

File metadata

  • Download URL: privsyn_core-0.1.1.tar.gz
  • Upload date:
  • Size: 25.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for privsyn_core-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f5a3a86ef84c1fb55278e1f2fe7003fb1c645f656db32df16bb3ed87fedb0995
MD5 22e3d1f982a4a0cc34415729eb8c44cb
BLAKE2b-256 b4e877ff9fedb726825cc1af8ddd20cf25df25e00f6cb19cb26f0f5dac377500

See more details on using hashes here.

Provenance

The following attestation bundles were made for privsyn_core-0.1.1.tar.gz:

Publisher: privsyn-core-package.yml on vvv214/privsyn-tabular

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file privsyn_core-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: privsyn_core-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 28.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for privsyn_core-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8371a14bd6a30e4373a0e9b77c1f6ac7f51482daa6d9f251273c895ecadadaae
MD5 5b9968e4600b52ebe36f8581ed314b30
BLAKE2b-256 ace72ccfc87a3e72c93038c7f57e9941847bf94fe2b69e7cceeff33ec71b4f80

See more details on using hashes here.

Provenance

The following attestation bundles were made for privsyn_core-0.1.1-py3-none-any.whl:

Publisher: privsyn-core-package.yml on vvv214/privsyn-tabular

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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