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.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 multivariate-probit 0.2.0
File Size Uploaded Provenance Actions
multivariate_probit-0.2.0.tar.gz 79.1 kB Without provenance Details for multivariate_probit-0.2.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for multivariate-probit 0.2.0
File Interpreter ABI Platform Actions
multivariate_probit-0.2.0-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.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
multivariate_probit-0.2.0-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.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Total release size: 1.3 MB

Release files / multivariate_probit-0.2.0.tar.gz

Download URL multivariate_probit-0.2.0.tar.gz
Size 79.1 kB
Tags Source
SHA-256 checksum
How to use checksums
4e4ddafaebbbcc0184a6480b4253681a76db2184f0f0c1aa884fbda57ec63661
BLAKE2b-256 checksum
How to use checksums
74155fb38f3e0d803bedca19eaa55b8a0b0161d2b97f972bdb86b08a0ef8a1e2
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.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL multivariate_probit-0.2.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 613.5 kB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
b0eacabead6c3acb517e4dc7efc30ef6e0b0f1d3f0f2d62e749ffee5d29fb21f
BLAKE2b-256 checksum
How to use checksums
61aec3b2e4a9d0a98ea7d3c1bf9b2265afb9495cbcba31ec332e306ca0e41239
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.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL multivariate_probit-0.2.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 613.5 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
74b83479e6b9f5a1b71fba52da20fd6ae863272d656773d0528ace45f84c6a7c
BLAKE2b-256 checksum
How to use checksums
d49a729f22c02a539b0c623022ed4dbfbe3a9a271e0834cfcd708ac2bffd3f78
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.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