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.0 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.0.tar.gz (24.6 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.0-py3-none-any.whl (28.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: privsyn_core-0.1.0.tar.gz
  • Upload date:
  • Size: 24.6 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.0.tar.gz
Algorithm Hash digest
SHA256 fbf8d210544d4d24fe1564f132803b23e3038085a7742f1d7ba36e5c965ac181
MD5 82e3b7e4a5da92a5ece5d2fc6d4da32a
BLAKE2b-256 c917d8b4c15947c64c8d8969e7f3f143312111aea4ecbe09838dafdfd2b8fcc0

See more details on using hashes here.

Provenance

The following attestation bundles were made for privsyn_core-0.1.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: privsyn_core-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 28.6 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5ea7951c0d6c90888f9f39656ce86cec5d0977a55c03032d93325f2d5c90c104
MD5 6d79f488555aa006f4c3a694b6c2c13e
BLAKE2b-256 08c0a7a30d12c768d2533fecc3c5e503d970fe1f067f3cc3f6d2bd7f7922058f

See more details on using hashes here.

Provenance

The following attestation bundles were made for privsyn_core-0.1.0-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