Skip to main content

MBI: Marginal-Based Estimation and Inference

(with applications to differential privacy)

drawing

DOI Continuous integration Documentation Status

Metrics for ryan112358/mbi repository

Documentation can be found at https://private-pgm.readthedocs.io/en/latest/!

Consider joining the Google Differential Privacy community in Slack.

Quick Start

from mbi import Domain, estimation, marginal_loss, callbacks

# Define a domain
domain = Domain(["age", "sex", "income"], [10, 2, 5])

# Provide noisy marginal measurements
measurements = [
    marginal_loss.LinearMeasurement(noisy_marginal_1, ("age", "sex")),
    marginal_loss.LinearMeasurement(noisy_marginal_2, ("sex", "income")),
]

# Estimate a graphical model
model = estimation.UniversalAcceleratedMethod().estimate(
    domain, measurements, iters=1000
)

# Use the model
synthetic_data = model.synthetic_data(rows=1000)
age_sex_marginal = model.project(("age", "sex")).datavector()

Estimators

All estimators share the same Estimator API:

# Universal Accelerated Method (recommended)
model = estimation.UniversalAcceleratedMethod().estimate(domain, measurements)

# Mirror Descent
model = estimation.MirrorDescent().estimate(domain, measurements)

# Dual Averaging
model = estimation.DualAveraging().estimate(domain, measurements)

# Interior Gradient
model = estimation.InteriorGradient().estimate(domain, measurements)

Extension estimators provide alternative representations:

from mbi.extensions.mixture_of_products import MixtureOfProductsEstimator
from mbi.extensions.reweighted_dataset import ReweightedDatasetEstimator

# Mixture of Products (scalable, no graphical model)
model = MixtureOfProductsEstimator(num_components=100).estimate(domain, measurements)

# Reweighted Dataset (produces a weighted dataset)
model = ReweightedDatasetEstimator(seed_data=data).estimate(domain, measurements)

Callbacks

Monitor optimization progress with callbacks:

cb = callbacks.default(measurements)
model = estimation.MirrorDescent().estimate(
    domain, measurements, iters=1000, callback_fn=cb,
)

Metadata

Release files for mbi 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mbi 2.1.0
File Size Uploaded Provenance Actions
mbi-2.1.0.tar.gz 127.3 kB Without provenance Details for mbi-2.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mbi 2.1.0
File Interpreter ABI Platform Actions
mbi-2.1.0-py3-none-any.whl Python 3 none any Details for mbi-2.1.0-py3-none-any.whl

Total release size: 217.7 kB

Release files / mbi-2.1.0.tar.gz

Download URL mbi-2.1.0.tar.gz
Size 127.3 kB
Tags Source
SHA-256 checksum
How to use checksums
92ca589f4160cb704cd6a54f055cecf85cc9a7a87cda665f8d332e36ae36ad92
BLAKE2b-256 checksum
How to use checksums
ae43e2ba5be672a2e8fcd11fbaa9028960e61fbb33bb376c161a2f7416be5831
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.7

Release files / mbi-2.1.0-py3-none-any.whl

Download URL mbi-2.1.0-py3-none-any.whl
Size 90.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
69275d5f4e0e81c4176b8ffcb46c02061606a093a0b99c7837d78c955df8bf03
BLAKE2b-256 checksum
How to use checksums
6989130de51a40304d4acef3385f86621ea517fef0308852e946159219db3ee7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.7

Security for mbi 2.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page