multivariate-probit 0.3.4__tar.gz → 0.3.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/CITATION.cff +2 -2
  2. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/PKG-INFO +1 -1
  3. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/docs/api.md +5 -2
  4. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/pyproject.toml +1 -1
  5. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/src/multivariate_probit/__init__.py +1 -1
  6. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/src/multivariate_probit/_mvn.py +2 -1
  7. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/src/multivariate_probit/model.py +14 -3
  8. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/tests/test_evaluators.py +48 -1
  9. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/.github/ISSUE_TEMPLATE/use-case.md +0 -0
  10. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/.gitignore +0 -0
  11. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/LICENSE +0 -0
  12. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/README.md +0 -0
  13. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/benchmarks/bench.py +0 -0
  14. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/benchmarks/benchmarks.ipynb +0 -0
  15. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/benchmarks/ref_d12_n3000_100_rho0.4_s0.npz +0 -0
  16. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/benchmarks/ref_d16_n3000_100_rho0.4_s0.npz +0 -0
  17. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/benchmarks/ref_d3_n3000_100_rho0.4_s0.npz +0 -0
  18. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/benchmarks/ref_d5_n3000_100_rho0.4_s0.npz +0 -0
  19. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/benchmarks/ref_d8_n3000_100_rho0.4_s0.npz +0 -0
  20. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/benchmarks/ref_pairwise_d12_n3000_100_s0.npz +0 -0
  21. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/benchmarks/ref_pairwise_d16_n3000_100_s0.npz +0 -0
  22. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/benchmarks/ref_pairwise_d3_n3000_100_s0.npz +0 -0
  23. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/benchmarks/ref_pairwise_d5_n3000_100_s0.npz +0 -0
  24. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/benchmarks/ref_pairwise_d8_n3000_100_s0.npz +0 -0
  25. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/benchmarks/results.csv +0 -0
  26. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/docs/benchmarks.md +0 -0
  27. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/docs/fiml.md +0 -0
  28. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/docs/ifm.md +0 -0
  29. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/docs/implementation.md +0 -0
  30. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/docs/limitations.md +0 -0
  31. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/docs/studies/README.md +0 -0
  32. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/docs/studies/comparators.md +0 -0
  33. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/docs/studies/ghk.md +0 -0
  34. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/docs/studies/index-correlation-shortcut.md +0 -0
  35. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/docs/studies/log-score-evaluator.md +0 -0
  36. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/docs/studies/margin-gaps.md +0 -0
  37. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/docs/studies/mulan-multilabel.md +0 -0
  38. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/docs/studies/multilabel-benchmarks.md +0 -0
  39. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/docs/studies/sparse-label-transfer.md +0 -0
  40. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/docs/studies/uci-credit.md +0 -0
  41. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/docs/use-cases/README.md +0 -0
  42. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/docs/use-cases/claims-fast-track.md +0 -0
  43. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/docs/use-cases/content-moderation.md +0 -0
  44. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/docs/use-cases/cyber.md +0 -0
  45. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/docs/use-cases/fraud-vendor-fusion.md +0 -0
  46. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/docs/use-cases/hcc-codes.md +0 -0
  47. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/docs/use-cases/property-imagery.md +0 -0
  48. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/hatch_build.py +0 -0
  49. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/src/multivariate_probit/_corr.py +0 -0
  50. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/src/multivariate_probit/_remote.py +0 -0
  51. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/src/multivariate_probit/ifm.py +0 -0
  52. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/src/multivariate_probit/inner.py +0 -0
  53. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/src/multivariate_probit/linear.py +0 -0
  54. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/src/multivariate_probit/orthant/__init__.py +0 -0
  55. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/src/multivariate_probit/results.py +0 -0
  56. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/tests/conftest.py +0 -0
  57. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/tests/test_calibration.py +0 -0
  58. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/tests/test_conditional.py +0 -0
  59. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/tests/test_contract.py +0 -0
  60. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/tests/test_correlation_projection.py +0 -0
  61. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/tests/test_linear.py +0 -0
  62. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/tests/test_modal_fit.py +0 -0
  63. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/tests/test_rf.py +0 -0
  64. {multivariate_probit-0.3.4 → multivariate_probit-0.3.6}/tests/test_xgboost.py +0 -0
@@ -6,8 +6,8 @@ authors:
6
6
  - family-names: Shipman
7
7
  given-names: Mark
8
8
  orcid: "https://orcid.org/0009-0008-7193-1263"
9
- version: 0.3.4
10
- date-released: 2026-11-05
9
+ version: 0.3.6
10
+ date-released: 2026-11-28
11
11
  license: MIT
12
12
  repository-code: "https://github.com/sign-of-fourier/multivariate-probit"
13
13
  url: "https://quantecarlo.com/multivariate-probit"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: multivariate-probit
3
- Version: 0.3.4
3
+ Version: 0.3.6
4
4
  Summary: Joint probabilities for correlated binary outcomes: P(any), P(all), patterns and conditionals that agree. Any classifier per outcome; scikit-learn-style API.
5
5
  Project-URL: Homepage, https://quantecarlo.com/multivariate-probit
6
6
  Project-URL: Source, https://github.com/sign-of-fourier/multivariate-probit
@@ -36,7 +36,7 @@ MultivariateProbit(
36
36
  | `project_correlation` | `True` | Project a pairwise estimate onto the nearest positive-definite correlation matrix. No effect when `dependence="joint"`. |
37
37
  | `random_state` | `None` | Controls the cross-fitting split and `sample`. |
38
38
  | `evaluator` | `"quadrature"` | Backend for the orthant probabilities behind `dependence="joint"` and every joint query: `"quadrature"`, `"scipy"`, `"orthant"` or `"ghk"`. See [Evaluators](#evaluators). |
39
- | `resolution` | `"high"` | Passed to `evaluator="orthant"`; ignored otherwise. `"high"`, `"highest"` (most accurate, about 2–3× the time of `"high"`: median error under 0.00005 on an equicorrelated Σ against up to 0.0001 at `"high"`, and 0.0001–0.0031 on a near-singular Σ against 0.0006–0.0061; see [benchmarks.md](benchmarks.md)), `"smooth"` (the cost of `"highest"`, continuous in the parameters with no threshold where the method changes, for gradient-based fitting; not uniformly more accurate than `"high"`) or `"low"` (cheapest). |
39
+ | `resolution` | `"high"` | Passed to `evaluator="orthant"`; ignored otherwise. `"high"`, `"highest"` (most accurate, about 2–3× the time of `"high"`: median error under 0.00005 on an equicorrelated Σ against up to 0.0001 at `"high"`, and 0.0001–0.0031 on a near-singular Σ against 0.0006–0.0061; see [benchmarks.md](benchmarks.md)), `"smooth"` (the cost of `"highest"`, continuous in the parameters with no threshold where the method changes, for gradient-based fitting; not uniformly more accurate than `"high"`), `"surgical"` (accurate mode for small problems, up to about 10 outcomes: on grouped covariances at d = 6, median error about 0.00002 against about 0.0003 at `"highest"`, no systematic lean, about 5–10× the cost of `"highest"`, growing with d²; from 0.3.5), `"low"` (cheapest) or `"ovus"` (Bhat's OVUS, for comparison). |
40
40
  | `fitter` | `"ifm"` | `"ifm"`: the local two-stage fit. `"modal"`: full maximum likelihood on a hosted GPU service ([fiml.md](fiml.md)) — `inner="linear"` only, `inner_params` may set only `alpha`; `dependence`, `cv`, `optimizer` and `project_correlation` do not apply. Uploads X, Y and `sample_weight`. An int `random_state` seeds its Sobol draws (default seed 0). |
41
41
  | `n_draws` | `512` | Sobol draws per row for `fitter="modal"` and `evaluator="ghk"`; ignored otherwise. Powers of 2 keep the Sobol set balanced. |
42
42
 
@@ -69,7 +69,10 @@ MultivariateProbit(
69
69
 
70
70
  The speed/accuracy trade-off is the caller's. None of the backends falls back to
71
71
  another: one that cannot run as asked raises. All results are clipped to
72
- [0, 1]. `dependence="pairwise"` needs only bivariate probabilities, which are
72
+ [0, 1]. Within `"orthant"`, rows its engine puts at or below 0 (deep tail, true
73
+ probability around 1e-6) are recomputed at `resolution="ovus"`, so a positive
74
+ probability stays positive and its log finite (from 0.3.6; before, such rows
75
+ returned exactly 0). `dependence="pairwise"` needs only bivariate probabilities, which are
73
76
  always computed in closed form, so it is unaffected during fitting; joint
74
77
  queries on a pairwise fit still use the chosen backend.
75
78
 
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "multivariate-probit"
7
- version = "0.3.4"
7
+ version = "0.3.6"
8
8
  description = "Joint probabilities for correlated binary outcomes: P(any), P(all), patterns and conditionals that agree. Any classifier per outcome; scikit-learn-style API."
9
9
  readme = "README.md"
10
10
  license = { file = "LICENSE" }
@@ -34,7 +34,7 @@ from .linear import ProbitRegressor
34
34
  from .model import MultivariateProbit
35
35
  from .results import MultivariateProbitProba
36
36
 
37
- __version__ = "0.3.4"
37
+ __version__ = "0.3.6"
38
38
 
39
39
  __all__ = [
40
40
  "MultivariateProbit",
@@ -205,7 +205,8 @@ def lower_orthant(A, corr_stack, evaluator="quadrature", n_quad=24, resolution="
205
205
 
206
206
  ``n_quad`` is used only by ``"quadrature"``, ``resolution`` only by
207
207
  ``"orthant"`` and ``n_draws`` only by ``"ghk"``. A backend that cannot run as asked raises; nothing falls
208
- back to another backend. Results are clipped to [0, 1].
208
+ back to another backend. Results are clipped to [0, 1]; ``"orthant"`` recomputes rows its engine puts at
209
+ or below 0 with its own ``resolution="ovus"`` (0.3.6).
209
210
  """
210
211
  A = np.atleast_2d(np.asarray(A, dtype=float))
211
212
  if evaluator == "quadrature":
@@ -164,12 +164,16 @@ class MultivariateProbit:
164
164
  earlier.
165
165
 
166
166
  Results are clipped to [0, 1]. No backend ever falls back to another.
167
+ Within ``"orthant"``, rows its engine puts at or below 0 (deep tail,
168
+ true probability around 1e-6) are recomputed at ``resolution="ovus"``,
169
+ so a positive probability stays positive and its log finite (from
170
+ 0.3.6; before, such rows returned exactly 0).
167
171
  ``dependence="pairwise"`` needs only bivariate probabilities, which
168
172
  are always computed in closed form, so it ignores this setting.
169
173
  n_quad : int, default=24
170
174
  Gauss-Legendre order for ``evaluator="quadrature"``. Lower it if
171
175
  fitting with many outcomes gets slow.
172
- resolution : {"high", "highest", "smooth", "low", "ovus"}, default="high"
176
+ resolution : {"high", "highest", "surgical", "smooth", "low", "ovus"}, default="high"
173
177
  Passed to ``evaluator="orthant"``; ignored otherwise. ``"highest"``
174
178
  is the most accurate setting, at about 2-3 times the time of
175
179
  ``"high"``: in docs/benchmarks.md its median error is under 0.00005 on
@@ -178,11 +182,18 @@ class MultivariateProbit:
178
182
  ``"smooth"`` costs the same as ``"highest"`` and is continuous in the
179
183
  parameters (no threshold where the method changes, near-duplicates
180
184
  included), for gradient-based fitting; it is not uniformly more
181
- accurate than ``"high"``. ``"low"`` is the cheapest. ``"ovus"`` is
185
+ accurate than ``"high"``. ``"surgical"`` is the accurate setting for
186
+ small problems (up to about 10 outcomes), for likelihoods where small
187
+ errors add up over many rows: on grouped covariances at d = 6 its median
188
+ error is about 0.00002 against about 0.0003 for ``"highest"``, with no
189
+ systematic lean, at about 5-10 times the cost of ``"highest"``; its
190
+ cost grows with d squared, so above about 10 ``"highest"`` is the
191
+ better trade. ``"low"`` is the cheapest. ``"ovus"`` is
182
192
  Bhat's (2018) OVUS approximation (the one inside MACML), same values
183
193
  as pybhatlib's ``mvncd(method="ovus")``, for side-by-side
184
194
  comparison. ``"highest"`` and ``"smooth"`` are not available in 0.3.0
185
- and earlier, ``"ovus"`` not before 0.3.4.
195
+ and earlier, ``"ovus"`` not before 0.3.4, ``"surgical"`` not before
196
+ 0.3.5.
186
197
  optimizer : str, default="Nelder-Mead"
187
198
  Passed to ``scipy.optimize.minimize`` for ``dependence="joint"``.
188
199
  Derivative-free by design: the orthant likelihood has no convenient
@@ -120,7 +120,8 @@ def test_orthant_without_key_runs_at_low_resolution_up_to_three(tmp_path):
120
120
  @orthant_built
121
121
  @pytest.mark.parametrize(
122
122
  "d, resolution, message",
123
- [(4, "low", "n=4 requires a license"), (3, "high", "resolution='high' requires a license")],
123
+ [(4, "low", "n=4 requires a license"), (3, "high", "resolution='high' requires a license"),
124
+ (3, "surgical", "resolution='surgical' requires a license")],
124
125
  )
125
126
  def test_orthant_without_key_refuses_rather_than_falling_back(tmp_path, d, resolution, message):
126
127
  out = _run_orthant(
@@ -209,3 +210,49 @@ def test_orthant_loads_an_extension_from_memory():
209
210
  with open(ORTHANT_DIR / f"_ofree.{_tag()}.so", "rb") as f:
210
211
  mod = _import_extension(f.read(), "_ofree")
211
212
  assert callable(mod.cdf)
213
+
214
+
215
+ @orthant_built
216
+ @pytest.mark.skipif(not os.environ.get("ORTHANT_KEY"), reason="needs $ORTHANT_KEY")
217
+ def test_orthant_surgical_with_key(tmp_path):
218
+ out = _run_orthant(
219
+ """
220
+ eta, Y, corr = problem(5)
221
+ corr[:2, :2] = 0.8
222
+ np.fill_diagonal(corr, 1.0)
223
+ got = pattern_prob(eta, Y, corr, evaluator="orthant", resolution="surgical")
224
+ ref = pattern_prob(eta, Y, corr)
225
+ assert np.abs(got - ref).max() < 2e-3, np.abs(got - ref).max()
226
+ """,
227
+ key=os.environ["ORTHANT_KEY"],
228
+ tmp_path=tmp_path,
229
+ )
230
+ assert out.returncode == 0, out.stderr
231
+
232
+
233
+ @orthant_built
234
+ @pytest.mark.skipif(not os.environ.get("ORTHANT_KEY"), reason="needs $ORTHANT_KEY")
235
+ def test_orthant_tiny_probabilities_stay_positive(tmp_path):
236
+ # Grouped choice orthants with the chosen alternative fixed: some true P ~1e-6, where the engine
237
+ # returned exactly 0 before 0.3.6. Those rows now come back from resolution="ovus".
238
+ out = _run_orthant(
239
+ """
240
+ from multivariate_probit import orthant
241
+ g = np.random.default_rng(68); d = 16; J = d + 1
242
+ D = np.hstack([np.ones((d, 1)), -np.eye(d)])
243
+ up, cov = np.empty((300, d)), np.empty((300, d, d))
244
+ for i in range(300):
245
+ lv = [g.integers(0, m, J) for m in (4, 4, 2)]
246
+ Om = 0.25 * np.eye(J) + sum(w * (l[:, None] == l[None, :]) for w, l in zip((0.40, 0.20, 0.15), lv))
247
+ v = g.standard_normal(J)
248
+ up[i], cov[i] = v[0] - v[1:], D @ Om @ D.T
249
+ ov = orthant.cdf(up, cov, resolution="ovus")
250
+ for r in ("high", "highest"):
251
+ p = orthant.cdf(up, cov, resolution=r)
252
+ assert (p > 0).all(), (r, (p <= 0).sum())
253
+ assert (p == ov).sum() >= 1, r
254
+ """,
255
+ key=os.environ["ORTHANT_KEY"],
256
+ tmp_path=tmp_path,
257
+ )
258
+ assert out.returncode == 0, out.stderr