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.MirrorDescent().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:

# Mirror Descent (recommended)
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.0.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.0.0
File Size Uploaded
mbi-2.0.0.tar.gz 118.1 kB Details

Built distribution (wheel)

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

Total release size: 204.2 kB

Release files / mbi-2.0.0.tar.gz

Download URL mbi-2.0.0.tar.gz
Size 118.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2b48dcdce4aafabaae6fa59622d0e410c017cc79fddeebd08848deba4061b0d8
BLAKE2b-256 checksum
How to use checksums
aa7633ff83f128d561110d378550077b24711849e9c9ad2265413188a1c1f26d
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.0.0-py3-none-any.whl

Download URL mbi-2.0.0-py3-none-any.whl
Size 86.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5a335f438dd550da7d9bdeccecfaa5d58e41220d918156f96e1721d708b688cd
BLAKE2b-256 checksum
How to use checksums
aa371f40e5a869d7b3ffb7a071bba2f3549b1aca69802af3f46d1581f44089ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.7

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files

1.1.0

1 release file

1.0.0

2 release files

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