Skip to main content

multivariate-probit

Multivariate probit models for correlated binary outcomes, with a pluggable inner model.

The model

Each outcome is a threshold on a latent Gaussian variable, and the outcomes are tied together by the correlation of those latents:

Y_j = 1[ η_j(x) + e_j > 0 ],    e ~ N(0, Σ),    j = 1 … d

η_j is an arbitrary real-valued function of the features — linear by default, or XGBoost, a random forest, or anything else that fits (X, y). Σ is a correlation matrix (unit diagonal) carrying the dependence between outcomes. Marginally, P(Y_j = 1 | x) = Φ(η_j(x)).

Fitting is cross-fit two-stage IFM: every margin is fitted independently, then Σ is estimated by maximum likelihood with those margins held fixed. That separation is what lets the inner model be a black box. The algorithm, and the alternatives that were tested and rejected, are in docs/ifm.md.

Install

pip install multivariate-probit           # core: numpy + scipy
pip install multivariate-probit[xgboost]  # adds the "xgboost" preset
pip install multivariate-probit[all]      # every preset

Quickstart

from multivariate_probit import MultivariateProbit

model = MultivariateProbit(inner="linear").fit(X, Y)   # Y is (n, d), 0/1

proba = model.predict_proba(X)
proba.marginal                  # P(Y_j = 1 | x), shape (n, d)
proba.joint([1, 0, 1])          # P(Y = pattern | x), shape (n,)
proba.all()                     # P(every outcome = 1 | x)
proba.any(outcomes=[0, 2])      # P(at least one of these | x)

model.correlation_              # the fitted Σ, shape (d, d)
model.transform(X)              # latent scores η, shape (n, d)
model.sample(X, n_samples=100)  # simulated outcome patterns
model.score(X, Y)               # mean joint log-likelihood

predict_proba returns an object that behaves like the marginal-probability array (np.asarray(proba), indexing, .shape) and additionally answers the joint questions Σ was estimated for. Marginal predictions do not involve Σ at all; everything joint does.

Everything here is a squashing function over a latent index

The inner model never sees another outcome's labels. What stage two consumes is an unbounded index η_j(x) on (-∞, ∞); Φ is the only squashing function applied to it. A legal margin either produces that index directly, or emits a probability that is pushed back through Φ⁻¹ — a classifier with predict_proba. An uncalibrated decision_function score is not enough, since its scale is arbitrary.

That is the whole abstraction, and it is why the inner model is swappable without touching the estimation code.

Inner models

Preset Estimator Requires
"linear" (default), "probit" native probit via IRLS —
"xgboost", "xgb" XGBClassifier, tuned for calibration xgboost
"rf", "random_forest" RandomForestClassifier scikit-learn
MultivariateProbit(inner="xgboost")                        # a preset
MultivariateProbit(inner=XGBClassifier(max_depth=4))       # any sklearn-shaped model
MultivariateProbit(inner=["linear", "xgboost", "linear"])  # one per outcome

available_inners() lists the presets; register_inner(name, factory) adds your own. See docs/api.md for the inner-model contract.

Two knobs that cost time

  • dependence — "joint" (default) maximises the full d-variate likelihood for Σ. "pairwise" maximises each pair's bivariate likelihood instead: consistent, orders of magnitude cheaper, and the right choice once you have more than a handful of outcomes.
  • cv — 5 by default, cross-fitting the margins so Σ is never estimated from in-sample predictions. This is not optional hygiene: in-sample margins drive every fitted correlation to +1. cv=None skips it, which is defensible for the linear default and reckless for anything that can overfit.

Status

Alpha. The linear and XGBoost paths are covered by tests; the rf preset is wired but untested. Standard errors are not computed — correlation_ is a point estimate. Known gaps are listed in docs/limitations.md.

Documentation

Development

pip install -e ".[dev]"
pytest

License

MIT. See LICENSE.

Metadata

Release files for multivariate-probit 0.2.1

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

Source distribution (sdist)

Source distribution for multivariate-probit 0.2.1
File Size Uploaded Provenance Actions
multivariate_probit-0.2.1.tar.gz 79.1 kB Without provenance Details for multivariate_probit-0.2.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for multivariate-probit 0.2.1
File Interpreter ABI Platform Actions
multivariate_probit-0.2.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64 Details for multivariate_probit-0.2.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
multivariate_probit-0.2.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64 Details for multivariate_probit-0.2.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Total release size: 1.4 MB

Release files / multivariate_probit-0.2.1.tar.gz

Download URL multivariate_probit-0.2.1.tar.gz
Size 79.1 kB
Tags Source
SHA-256 checksum
How to use checksums
f14e79211e8f1d84cc97baca47228f462b6f1e261dd048bc5b377c6274561230
BLAKE2b-256 checksum
How to use checksums
0554483bc28e71b04cf94a65ccaa072ec9ea041f3c9567c17a3e3ed997b43b1f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.9

Release files / multivariate_probit-0.2.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL multivariate_probit-0.2.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 642.6 kB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
74e360a40f6f6967c2e0f5246bcba45c4c955a42e020925037167b79680688ea
BLAKE2b-256 checksum
How to use checksums
71b6f3b3ea97bd74dbfe07a68270ddb613d3780d48e251ccce16d70c7c66250b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.9

Release files / multivariate_probit-0.2.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL multivariate_probit-0.2.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 642.6 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
b12136e31fc007ea2d4975651bf27d683d6c9e617124b1ae892672469cb6c48c
BLAKE2b-256 checksum
How to use checksums
b689ef72ed7c7b48eb3632eb4257e5e29401158b6ec28c7008d854fec88a2812
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.9

Security for multivariate-probit 0.2.1

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