evalsuite-python 1.2.0__tar.gz → 1.3.0__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 (166) hide show
  1. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/CHANGELOG.md +62 -0
  2. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/PKG-INFO +81 -3
  3. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/README.md +80 -2
  4. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/pyproject.toml +2 -0
  5. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/rust/Cargo.lock +6 -6
  6. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/rust/Cargo.toml +1 -1
  7. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/rust/evalsuite-core/src/lib.rs +1 -0
  8. evalsuite_python-1.3.0/rust/evalsuite-core/src/survival.rs +84 -0
  9. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/rust/evalsuite-py/src/lib.rs +67 -1
  10. evalsuite_python-1.3.0/src/evalsuite/__init__.py +1055 -0
  11. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/_evalci.py +10 -13
  12. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/_native.py +1 -1
  13. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/_update.py +2 -1
  14. evalsuite_python-1.3.0/src/evalsuite/agreement.py +405 -0
  15. evalsuite_python-1.3.0/src/evalsuite/bayes.py +325 -0
  16. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/calibration.py +52 -11
  17. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/core/registry.py +24 -0
  18. evalsuite_python-1.3.0/src/evalsuite/drift.py +291 -0
  19. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/fairness.py +23 -10
  20. evalsuite_python-1.3.0/src/evalsuite/forecasting.py +383 -0
  21. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/judging.py +36 -9
  22. evalsuite_python-1.3.0/src/evalsuite/multilabel.py +448 -0
  23. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/rag_report.py +2 -1
  24. evalsuite_python-1.3.0/src/evalsuite/recalibration.py +265 -0
  25. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/stats/intervals.py +174 -21
  26. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/stats/planning.py +2 -0
  27. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/survival.py +68 -9
  28. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/text/judge.py +36 -29
  29. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/version.py +1 -1
  30. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/test_update.py +3 -1
  31. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/test_v12.py +2 -2
  32. evalsuite_python-1.3.0/tests/test_v121.py +181 -0
  33. evalsuite_python-1.3.0/tests/test_v121_coverage.py +222 -0
  34. evalsuite_python-1.3.0/tests/test_v13.py +325 -0
  35. evalsuite_python-1.3.0/tests/test_v13_edges.py +221 -0
  36. evalsuite_python-1.2.0/src/evalsuite/__init__.py +0 -343
  37. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/CONTRIBUTING.md +0 -0
  38. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/LICENSE +0 -0
  39. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/LICENSE-APACHE +0 -0
  40. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/rust/evalsuite-core/Cargo.toml +0 -0
  41. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/rust/evalsuite-core/README.md +0 -0
  42. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/rust/evalsuite-core/src/agreement.rs +0 -0
  43. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/rust/evalsuite-core/src/coco.rs +0 -0
  44. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/rust/evalsuite-core/src/curve.rs +0 -0
  45. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/rust/evalsuite-core/src/groups.rs +0 -0
  46. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/rust/evalsuite-core/src/hash.rs +0 -0
  47. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/rust/evalsuite-core/src/meteor.rs +0 -0
  48. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/rust/evalsuite-core/src/permutation.rs +0 -0
  49. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/rust/evalsuite-core/src/qa.rs +0 -0
  50. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/rust/evalsuite-core/src/ranks.rs +0 -0
  51. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/rust/evalsuite-core/src/resample.rs +0 -0
  52. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/rust/evalsuite-core/src/surface.rs +0 -0
  53. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/rust/evalsuite-core/src/ter.rs +0 -0
  54. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/rust/evalsuite-core/src/text.rs +0 -0
  55. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/rust/evalsuite-py/Cargo.toml +0 -0
  56. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/__main__.py +0 -0
  57. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/_bench_metrics.py +0 -0
  58. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/_lazy.py +0 -0
  59. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/api.py +0 -0
  60. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/benchmarks.py +0 -0
  61. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/cards.py +0 -0
  62. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/classification/__init__.py +0 -0
  63. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/classification/_common.py +0 -0
  64. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/classification/metrics.py +0 -0
  65. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/cli/__init__.py +0 -0
  66. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/cli/main.py +0 -0
  67. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/clinical/__init__.py +0 -0
  68. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/clinical/metrics.py +0 -0
  69. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/clinical/report.py +0 -0
  70. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/core/__init__.py +0 -0
  71. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/core/context.py +0 -0
  72. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/core/exceptions.py +0 -0
  73. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/core/export.py +0 -0
  74. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/core/result.py +0 -0
  75. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/core/types.py +0 -0
  76. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/core/validation.py +0 -0
  77. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/harness.py +0 -0
  78. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/html_report.py +0 -0
  79. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/integrations.py +0 -0
  80. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/llm_benchmarks.py +0 -0
  81. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/llmsys/__init__.py +0 -0
  82. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/llmsys/_common.py +0 -0
  83. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/llmsys/agents.py +0 -0
  84. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/llmsys/code.py +0 -0
  85. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/llmsys/efficiency.py +0 -0
  86. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/llmsys/longcontext.py +0 -0
  87. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/llmsys/multilingual.py +0 -0
  88. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/llmsys/robustness.py +0 -0
  89. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/llmsys/safety.py +0 -0
  90. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/llmsys/uncertainty.py +0 -0
  91. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/monitor.py +0 -0
  92. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/plot.py +0 -0
  93. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/py.typed +0 -0
  94. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/regression/__init__.py +0 -0
  95. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/regression/metrics.py +0 -0
  96. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/reporting.py +0 -0
  97. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/stats/__init__.py +0 -0
  98. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/stats/_resolve.py +0 -0
  99. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/stats/compare.py +0 -0
  100. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/stats/effect.py +0 -0
  101. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/stats/hypothesis.py +0 -0
  102. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/stats/paired.py +0 -0
  103. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/stats/results.py +0 -0
  104. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/text/__init__.py +0 -0
  105. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/text/_common.py +0 -0
  106. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/text/factuality.py +0 -0
  107. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/text/generation.py +0 -0
  108. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/text/qa.py +0 -0
  109. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/text/rag.py +0 -0
  110. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/text/reasoning.py +0 -0
  111. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/text/report.py +0 -0
  112. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/text/retrieval.py +0 -0
  113. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/text/semantic.py +0 -0
  114. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/text/spice.py +0 -0
  115. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/text/structured.py +0 -0
  116. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/vision/__init__.py +0 -0
  117. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/vision/detection.py +0 -0
  118. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/src/evalsuite/vision/segmentation.py +0 -0
  119. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/__init__.py +0 -0
  120. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/classification/__init__.py +0 -0
  121. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/classification/test_against_sklearn.py +0 -0
  122. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/clinical/__init__.py +0 -0
  123. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/clinical/test_outputs.py +0 -0
  124. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/clinical/test_v020.py +0 -0
  125. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/conftest.py +0 -0
  126. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/integration/__init__.py +0 -0
  127. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/integration/test_qa.py +0 -0
  128. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/integration/test_readme_examples.py +0 -0
  129. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/integration/test_repo_hygiene.py +0 -0
  130. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/llmsys/__init__.py +0 -0
  131. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/llmsys/test_code_longcontext_efficiency.py +0 -0
  132. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/llmsys/test_edges.py +0 -0
  133. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/llmsys/test_fast_text.py +0 -0
  134. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/llmsys/test_hardening.py +0 -0
  135. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/llmsys/test_safety_robustness.py +0 -0
  136. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/llmsys/test_uncertainty_agents_multilingual.py +0 -0
  137. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/output/__init__.py +0 -0
  138. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/output/test_benchmarks.py +0 -0
  139. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/output/test_cli.py +0 -0
  140. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/output/test_plot.py +0 -0
  141. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/output/test_reporting.py +0 -0
  142. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/regression/__init__.py +0 -0
  143. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/regression/test_against_sklearn.py +0 -0
  144. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/stats/__init__.py +0 -0
  145. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/stats/test_branches.py +0 -0
  146. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/stats/test_compare.py +0 -0
  147. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/stats/test_fast_paths.py +0 -0
  148. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/stats/test_reference.py +0 -0
  149. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/test_cards.py +0 -0
  150. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/test_harness.py +0 -0
  151. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/test_integrations.py +0 -0
  152. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/test_monitor.py +0 -0
  153. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/test_native.py +0 -0
  154. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/test_v111_fixes.py +0 -0
  155. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/text/__init__.py +0 -0
  156. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/text/test_against_references.py +0 -0
  157. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/text/test_text_edges.py +0 -0
  158. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/text/test_v040.py +0 -0
  159. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/unit/__init__.py +0 -0
  160. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/unit/test_core.py +0 -0
  161. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/unit/test_edges.py +0 -0
  162. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/vision/__init__.py +0 -0
  163. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/vision/test_detection.py +0 -0
  164. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/vision/test_edges.py +0 -0
  165. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/vision/test_outputs.py +0 -0
  166. {evalsuite_python-1.2.0 → evalsuite_python-1.3.0}/tests/vision/test_segmentation.py +0 -0
@@ -6,6 +6,68 @@ All notable changes to this project are documented here. The format follows
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [1.3.0] - 2026-11-28
10
+
11
+ ### Added
12
+
13
+ - **Calibration suite.** `recalibrate(y, p, method=...)` fits Platt scaling, isotonic regression, temperature
14
+ scaling (binary or multiclass probability matrices), beta calibration or histogram binning on held-out data
15
+ and returns a calibrator to apply to new predictions. `calibration_report(..., n_resamples=)` adds percentile
16
+ bootstrap intervals for the Brier score, ECE, MCE, calibration intercept and slope. Platt and isotonic match
17
+ scikit-learn.
18
+ - **Multi-label and ranking.** `multilabel_report` (subset accuracy, Hamming loss, micro / macro / sample F1,
19
+ precision, recall, Jaccard, label-ranking average precision, coverage error, ranking loss, micro / macro ROC
20
+ AUC, per-label table, bootstrap intervals; values match scikit-learn). `ranking_report` (nDCG@k, AP@k, RR,
21
+ P@k, R@k per query, matching trec_eval; bootstrap intervals over queries; paired randomization tests against a
22
+ baseline with Holm adjustment).
23
+ - **Forecasting.** `mase`, `rmsse`, `pinball_loss`, `interval_score`, `msis`, `interval_coverage`, `crps`
24
+ (ensemble or normal), `diebold_mariano` (Harvey–Leybourne–Newbold correction) and `forecast_report`.
25
+ Validated against sktime, scikit-learn, properscoring and the dieboldmariano package.
26
+ - **Drift.** `drift_report(reference, current)`: per feature Kolmogorov–Smirnov or chi-square tests,
27
+ population stability index, Wasserstein (in reference SDs) or Jensen–Shannon distance, missing-rate changes;
28
+ Holm-adjusted and flagged only when the shift is material. Accepts pandas, Polars and Arrow tables, dicts and
29
+ arrays.
30
+ - **Agreement studies.** `icc` (all six Shrout–Fleiss / McGraw–Wong forms with F tests and exact or
31
+ Satterthwaite intervals; wide or long data; matches pingouin), `bland_altman` (bias, limits of agreement with
32
+ intervals, proportional bias, plot) and `lins_ccc`.
33
+ - **Bayesian comparison.** `bayes_compare` (Bayesian bootstrap posterior of a metric difference; P(A better),
34
+ P(practically equivalent), P(B better)) and `bayes_correlated_ttest` for cross-validation scores (Benavoli et
35
+ al. 2017; matches baycomp).
36
+
37
+ ### Changed
38
+
39
+ - Multi-label metrics and their bootstrap are vectorized (about 12× faster than a per-example loop);
40
+ Bayesian ROC AUC / average-precision draws are computed all at once.
41
+
42
+ ## [1.2.1] - 2026-11-26
43
+
44
+ Faster to import, faster to resample, and a deep clean of the 1.2 modules.
45
+
46
+ ### Changed
47
+
48
+ - **Load only what you use.** `import evalsuite` no longer imports NumPy, SciPy or any EvalSuite module: every
49
+ function, class and submodule is imported the first time it is used (PEP 562). Import time drops from about
50
+ 100 ms to about 30 ms and the command line starts in about 55 ms instead of 145 ms. Code is unchanged:
51
+ `es.accuracy`, `from evalsuite import *`, `es.list_metrics()` and IDE completion work as before.
52
+ - **Speed.**
53
+ - Cluster bootstrap (`evaluate(..., clusters=)`, `bootstrap_ci(..., clusters=)`): confusion-matrix metrics
54
+ from per-cluster counts, ROC AUC / average precision and mean losses from cluster multiplicities;
55
+ `bootstrap_ci` about 10× faster and `evaluate` about 3× faster on 100,000 observations.
56
+ - Concordance index in the compiled core: about 29× faster (bit-identical); bootstrap intervals run
57
+ resamples in parallel.
58
+ - `judge_report` Bradley–Terry bootstrap about 10× faster; `fairness_report` about 2× faster.
59
+
60
+ ### Fixed
61
+
62
+ - `es.rag_report` and `es.html_report` could become modules instead of functions after their modules were
63
+ imported (lazy loading guards this).
64
+ - `rubric_report` rejects non-numeric or NaN scores with a clear message instead of a raw error or a NaN row.
65
+ - `fairness_report` rejects missing group values instead of silently forming a "None" group.
66
+ - `sample_size_proportion` rejects a half-width of 0.5 or more.
67
+ - Singular wording in reports ("1 comparison", "1 question") and clearer length errors for survival and
68
+ fairness inputs.
69
+ - A power test's tolerance for older SciPy on Python 3.9.
70
+
9
71
  ## [1.2.0] - 2026-11-26
10
72
 
11
73
  EvalSuite for LLM evaluation and research-grade statistics.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: evalsuite-python
3
- Version: 1.2.0
3
+ Version: 1.3.0
4
4
  Classifier: Development Status :: 5 - Production/Stable
5
5
  Classifier: Intended Audience :: Science/Research
6
6
  Classifier: Intended Audience :: Healthcare Industry
@@ -104,11 +104,18 @@ evaluation into one consistent, validated, documented framework.
104
104
  > **On an older version? Upgrade once:** `pip install -U evalsuite-python`. From 1.1.2 on, EvalSuite tells you
105
105
  > when a newer release is out (`evalsuite upgrade`).
106
106
 
107
- > **Status: stable (1.2.0).** [Example notebooks](notebooks/README.md) (Colab) ·
107
+ > **Status: stable (1.3.0).** [Example notebooks](notebooks/README.md) (Colab) ·
108
108
  > [in-browser tools](https://evalsuite-nine.vercel.app/tools) · [changelog](CHANGELOG.md)
109
109
 
110
110
  **What's new**
111
111
 
112
+ - **1.3** — a calibration suite (Platt, isotonic, temperature, beta and histogram recalibration; bootstrap
113
+ intervals in `calibration_report`), multi-label and ranking reports (trec_eval-exact nDCG, AP, MRR with
114
+ intervals and randomization tests), forecasting (MASE, RMSSE, pinball loss, interval score, CRPS,
115
+ Diebold–Mariano), a feature-by-feature drift report, agreement studies (all six ICC forms, Bland–Altman,
116
+ Lin's CCC) and Bayesian model comparison (probability that A beats B, region of practical equivalence).
117
+ - **1.2.1** — `import evalsuite` loads only what you use (about 30 ms, no NumPy until needed); faster cluster
118
+ bootstrap, concordance index (compiled core), judge and fairness reports; a deep clean of the 1.2 modules.
112
119
  - **1.2** — LLM evaluation and research-grade statistics: benchmark presets (GSM8K, MMLU, ARC, TruthfulQA,
113
120
  HumanEval) for the leaderboard, a judge report (win rates, position / length / self-preference bias, agreement
114
121
  with humans), rubric reports, an end-to-end RAG report that blames each failure on retrieval or generation, a
@@ -287,8 +294,15 @@ es.calibration_report(y_true, y_prob) # Brier, ECE, MCE, intercept, slope, Hosm
287
294
  es.calibration_slope(y_true, y_prob) # ideal 1; < 1 means predictions are too extreme
288
295
  es.calibration_intercept(y_true, y_prob) # ideal 0 (calibration-in-the-large)
289
296
  es.hosmer_lemeshow(y_true, y_prob, n_groups=10)
297
+ es.calibration_report(y_true, y_prob, n_resamples=1000) # the same, with bootstrap intervals
298
+
299
+ cal = es.recalibrate(y_true[:100], y_prob[:100], method="isotonic") # or platt, temperature, beta, histogram
300
+ calibrated = cal(y_prob[100:]) # fit on held-out data, apply to new predictions
290
301
  ```
291
302
 
303
+ Recalibration maps match scikit-learn (Platt, isotonic) and `betacal`; temperature scaling also takes a
304
+ multiclass probability matrix.
305
+
292
306
  ## Statistical tests
293
307
 
294
308
  ```python
@@ -493,6 +507,70 @@ es.time_dependent_auc(time, event, risk, [20, 40, 60]) # cumulative/dynamic AUC
493
507
  `brier_score_survival` and `integrated_brier_score` take predicted survival probabilities. All agree with
494
508
  scikit-survival to 1e-15 (Harrell's C is about 17× faster).
495
509
 
510
+ ## Multi-label and ranking
511
+
512
+ ```python
513
+ rng = np.random.default_rng(0)
514
+ Y = (rng.random((300, 5)) < 0.3).astype(int)
515
+ scores = np.clip(0.4 * Y + rng.random((300, 5)), 0, 1)
516
+ ml = es.multilabel_report(Y, y_score=scores) # subset accuracy, Hamming, micro/macro F1, LRAP, ranking loss, AUC
517
+ print(ml.summary())
518
+
519
+ qrels = {"q1": {"d1": 2, "d2": 1}, "q2": {"d3": 1}}
520
+ runs = {"bm25": {"q1": ["d2", "d9", "d1"], "q2": ["d3"]}, "dense": {"q1": ["d1", "d2"], "q2": ["d7", "d3"]}}
521
+ rank = es.ranking_report(qrels, runs, k=10) # nDCG, AP, MRR, P@k, R@k with CIs; randomization tests vs baseline
522
+ ```
523
+
524
+ Multi-label values match scikit-learn; per-query ranking measures match `trec_eval` exactly.
525
+
526
+ ## Forecasting
527
+
528
+ ```python
529
+ rng = np.random.default_rng(1)
530
+ history = np.cumsum(rng.normal(size=120))
531
+ actual = history[-1] + np.cumsum(rng.normal(size=12))
532
+ forecast_a, forecast_b = actual + rng.normal(0, 0.5, 12), np.full(12, history[-1])
533
+ es.mase(actual, forecast_a, y_train=history, m=1) # < 1 beats the naive forecast
534
+ es.interval_score(actual, forecast_a - 1.5, forecast_a + 1.5, level=0.9)
535
+ es.crps(actual, mean=forecast_a, sd=1.0)
536
+ es.diebold_mariano(actual, forecast_a, forecast_b, h=1) # Harvey–Leybourne–Newbold corrected
537
+ es.forecast_report(actual, {"naive": forecast_b, "model": forecast_a}, y_train=history)
538
+ ```
539
+
540
+ ## Drift
541
+
542
+ ```python
543
+ rng = np.random.default_rng(2)
544
+ reference = {"age": rng.normal(50, 10, 2000), "site": rng.choice(["a", "b"], 2000)}
545
+ current = {"age": rng.normal(55, 10, 2000), "site": rng.choice(["a", "b", "c"], 2000)}
546
+ drift = es.drift_report(reference, current) # KS / chi-square, PSI, Wasserstein / Jensen–Shannon, missing rates
547
+ print(drift.drifted()) # Holm-adjusted and material: ['site', 'age']
548
+ ```
549
+
550
+ DataFrames (pandas, Polars, Arrow), dicts of columns and arrays all work.
551
+
552
+ ## Agreement studies
553
+
554
+ ```python
555
+ rng = np.random.default_rng(3)
556
+ truth = rng.normal(100, 15, 40)
557
+ ratings = np.column_stack([truth + rng.normal(0, 5, 40) for _ in range(3)]) # subjects × raters
558
+ es.icc(ratings)["ICC2"] # all six Shrout–Fleiss forms with F tests and CIs (as pingouin / psych)
559
+ es.bland_altman(ratings[:, 0], ratings[:, 1]) # bias, limits of agreement with CIs, proportional bias
560
+ es.lins_ccc(ratings[:, 0], ratings[:, 1])
561
+ ```
562
+
563
+ ## Bayesian comparison
564
+
565
+ ```python
566
+ b = es.bayes_compare(y_true, pred_lr, pred_gb, metric="accuracy", rope=0.01)
567
+ print(b.p_a_better, b.p_rope, b.p_b_better, b.decision()) # e.g. 0.97 0.03 0.00 'A better'
568
+ es.bayes_correlated_ttest(fold_scores_a, fold_scores_b, rope=0.01) # k-fold CV scores (Benavoli et al. 2017)
569
+ ```
570
+
571
+ Probabilities instead of p-values: how likely A is better, practically equivalent within the ROPE, or worse.
572
+ The correlated t-test matches `baycomp`.
573
+
496
574
  ## LLM judges, rubrics and RAG
497
575
 
498
576
  ```python
@@ -532,7 +610,7 @@ scripts, no external requests).
532
610
  ## Evaluation in pull requests
533
611
 
534
612
  ```yaml
535
- - uses: mkcs28/evalsuite-python@v1.2.0
613
+ - uses: mkcs28/evalsuite-python@v1.3.0
536
614
  with:
537
615
  predictions: predictions.csv
538
616
  y-true: label
@@ -13,11 +13,18 @@ evaluation into one consistent, validated, documented framework.
13
13
  > **On an older version? Upgrade once:** `pip install -U evalsuite-python`. From 1.1.2 on, EvalSuite tells you
14
14
  > when a newer release is out (`evalsuite upgrade`).
15
15
 
16
- > **Status: stable (1.2.0).** [Example notebooks](notebooks/README.md) (Colab) ·
16
+ > **Status: stable (1.3.0).** [Example notebooks](notebooks/README.md) (Colab) ·
17
17
  > [in-browser tools](https://evalsuite-nine.vercel.app/tools) · [changelog](CHANGELOG.md)
18
18
 
19
19
  **What's new**
20
20
 
21
+ - **1.3** — a calibration suite (Platt, isotonic, temperature, beta and histogram recalibration; bootstrap
22
+ intervals in `calibration_report`), multi-label and ranking reports (trec_eval-exact nDCG, AP, MRR with
23
+ intervals and randomization tests), forecasting (MASE, RMSSE, pinball loss, interval score, CRPS,
24
+ Diebold–Mariano), a feature-by-feature drift report, agreement studies (all six ICC forms, Bland–Altman,
25
+ Lin's CCC) and Bayesian model comparison (probability that A beats B, region of practical equivalence).
26
+ - **1.2.1** — `import evalsuite` loads only what you use (about 30 ms, no NumPy until needed); faster cluster
27
+ bootstrap, concordance index (compiled core), judge and fairness reports; a deep clean of the 1.2 modules.
21
28
  - **1.2** — LLM evaluation and research-grade statistics: benchmark presets (GSM8K, MMLU, ARC, TruthfulQA,
22
29
  HumanEval) for the leaderboard, a judge report (win rates, position / length / self-preference bias, agreement
23
30
  with humans), rubric reports, an end-to-end RAG report that blames each failure on retrieval or generation, a
@@ -196,8 +203,15 @@ es.calibration_report(y_true, y_prob) # Brier, ECE, MCE, intercept, slope, Hosm
196
203
  es.calibration_slope(y_true, y_prob) # ideal 1; < 1 means predictions are too extreme
197
204
  es.calibration_intercept(y_true, y_prob) # ideal 0 (calibration-in-the-large)
198
205
  es.hosmer_lemeshow(y_true, y_prob, n_groups=10)
206
+ es.calibration_report(y_true, y_prob, n_resamples=1000) # the same, with bootstrap intervals
207
+
208
+ cal = es.recalibrate(y_true[:100], y_prob[:100], method="isotonic") # or platt, temperature, beta, histogram
209
+ calibrated = cal(y_prob[100:]) # fit on held-out data, apply to new predictions
199
210
  ```
200
211
 
212
+ Recalibration maps match scikit-learn (Platt, isotonic) and `betacal`; temperature scaling also takes a
213
+ multiclass probability matrix.
214
+
201
215
  ## Statistical tests
202
216
 
203
217
  ```python
@@ -402,6 +416,70 @@ es.time_dependent_auc(time, event, risk, [20, 40, 60]) # cumulative/dynamic AUC
402
416
  `brier_score_survival` and `integrated_brier_score` take predicted survival probabilities. All agree with
403
417
  scikit-survival to 1e-15 (Harrell's C is about 17× faster).
404
418
 
419
+ ## Multi-label and ranking
420
+
421
+ ```python
422
+ rng = np.random.default_rng(0)
423
+ Y = (rng.random((300, 5)) < 0.3).astype(int)
424
+ scores = np.clip(0.4 * Y + rng.random((300, 5)), 0, 1)
425
+ ml = es.multilabel_report(Y, y_score=scores) # subset accuracy, Hamming, micro/macro F1, LRAP, ranking loss, AUC
426
+ print(ml.summary())
427
+
428
+ qrels = {"q1": {"d1": 2, "d2": 1}, "q2": {"d3": 1}}
429
+ runs = {"bm25": {"q1": ["d2", "d9", "d1"], "q2": ["d3"]}, "dense": {"q1": ["d1", "d2"], "q2": ["d7", "d3"]}}
430
+ rank = es.ranking_report(qrels, runs, k=10) # nDCG, AP, MRR, P@k, R@k with CIs; randomization tests vs baseline
431
+ ```
432
+
433
+ Multi-label values match scikit-learn; per-query ranking measures match `trec_eval` exactly.
434
+
435
+ ## Forecasting
436
+
437
+ ```python
438
+ rng = np.random.default_rng(1)
439
+ history = np.cumsum(rng.normal(size=120))
440
+ actual = history[-1] + np.cumsum(rng.normal(size=12))
441
+ forecast_a, forecast_b = actual + rng.normal(0, 0.5, 12), np.full(12, history[-1])
442
+ es.mase(actual, forecast_a, y_train=history, m=1) # < 1 beats the naive forecast
443
+ es.interval_score(actual, forecast_a - 1.5, forecast_a + 1.5, level=0.9)
444
+ es.crps(actual, mean=forecast_a, sd=1.0)
445
+ es.diebold_mariano(actual, forecast_a, forecast_b, h=1) # Harvey–Leybourne–Newbold corrected
446
+ es.forecast_report(actual, {"naive": forecast_b, "model": forecast_a}, y_train=history)
447
+ ```
448
+
449
+ ## Drift
450
+
451
+ ```python
452
+ rng = np.random.default_rng(2)
453
+ reference = {"age": rng.normal(50, 10, 2000), "site": rng.choice(["a", "b"], 2000)}
454
+ current = {"age": rng.normal(55, 10, 2000), "site": rng.choice(["a", "b", "c"], 2000)}
455
+ drift = es.drift_report(reference, current) # KS / chi-square, PSI, Wasserstein / Jensen–Shannon, missing rates
456
+ print(drift.drifted()) # Holm-adjusted and material: ['site', 'age']
457
+ ```
458
+
459
+ DataFrames (pandas, Polars, Arrow), dicts of columns and arrays all work.
460
+
461
+ ## Agreement studies
462
+
463
+ ```python
464
+ rng = np.random.default_rng(3)
465
+ truth = rng.normal(100, 15, 40)
466
+ ratings = np.column_stack([truth + rng.normal(0, 5, 40) for _ in range(3)]) # subjects × raters
467
+ es.icc(ratings)["ICC2"] # all six Shrout–Fleiss forms with F tests and CIs (as pingouin / psych)
468
+ es.bland_altman(ratings[:, 0], ratings[:, 1]) # bias, limits of agreement with CIs, proportional bias
469
+ es.lins_ccc(ratings[:, 0], ratings[:, 1])
470
+ ```
471
+
472
+ ## Bayesian comparison
473
+
474
+ ```python
475
+ b = es.bayes_compare(y_true, pred_lr, pred_gb, metric="accuracy", rope=0.01)
476
+ print(b.p_a_better, b.p_rope, b.p_b_better, b.decision()) # e.g. 0.97 0.03 0.00 'A better'
477
+ es.bayes_correlated_ttest(fold_scores_a, fold_scores_b, rope=0.01) # k-fold CV scores (Benavoli et al. 2017)
478
+ ```
479
+
480
+ Probabilities instead of p-values: how likely A is better, practically equivalent within the ROPE, or worse.
481
+ The correlated t-test matches `baycomp`.
482
+
405
483
  ## LLM judges, rubrics and RAG
406
484
 
407
485
  ```python
@@ -441,7 +519,7 @@ scripts, no external requests).
441
519
  ## Evaluation in pull requests
442
520
 
443
521
  ```yaml
444
- - uses: mkcs28/evalsuite-python@v1.2.0
522
+ - uses: mkcs28/evalsuite-python@v1.3.0
445
523
  with:
446
524
  predictions: predictions.csv
447
525
  y-true: label
@@ -133,6 +133,8 @@ ignore = ["N803", "N806", "RUF022", "UP007", "UP045", "RUF001", "RUF002", "RUF00
133
133
  # Developer script recording parity fixtures for the Rust crate: each case's lambda runs immediately.
134
134
  "scripts/rust_fixtures.py" = ["B007", "B023", "E501", "E731", "E741", "RUF005"]
135
135
  "scripts/make_notebooks.py" = ["E501", "S102"]
136
+ # The type-checking-only re-exports in the package root are served lazily by __getattr__.
137
+ "src/evalsuite/__init__.py" = ["F401", "F403", "F405", "F822"]
136
138
  "notebooks/*.ipynb" = ["E501", "I001", "S311"]
137
139
 
138
140
  [tool.mypy]
@@ -319,7 +319,7 @@ checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826"
319
319
 
320
320
  [[package]]
321
321
  name = "evalsuite"
322
- version = "1.2.0"
322
+ version = "1.3.0"
323
323
  dependencies = [
324
324
  "criterion",
325
325
  "evalsuite-core",
@@ -334,14 +334,14 @@ dependencies = [
334
334
 
335
335
  [[package]]
336
336
  name = "evalsuite-capi"
337
- version = "1.2.0"
337
+ version = "1.3.0"
338
338
  dependencies = [
339
339
  "evalsuite",
340
340
  ]
341
341
 
342
342
  [[package]]
343
343
  name = "evalsuite-cli"
344
- version = "1.2.0"
344
+ version = "1.3.0"
345
345
  dependencies = [
346
346
  "clap",
347
347
  "csv",
@@ -351,14 +351,14 @@ dependencies = [
351
351
 
352
352
  [[package]]
353
353
  name = "evalsuite-core"
354
- version = "1.2.0"
354
+ version = "1.3.0"
355
355
  dependencies = [
356
356
  "rayon",
357
357
  ]
358
358
 
359
359
  [[package]]
360
360
  name = "evalsuite-py"
361
- version = "1.2.0"
361
+ version = "1.3.0"
362
362
  dependencies = [
363
363
  "evalsuite-core",
364
364
  "pyo3",
@@ -367,7 +367,7 @@ dependencies = [
367
367
 
368
368
  [[package]]
369
369
  name = "evalsuite-wasm"
370
- version = "1.2.0"
370
+ version = "1.3.0"
371
371
  dependencies = [
372
372
  "evalsuite",
373
373
  "js-sys",
@@ -3,7 +3,7 @@ members = ["evalsuite-core", "evalsuite-py"]
3
3
  resolver = "2"
4
4
 
5
5
  [workspace.package]
6
- version = "1.2.0"
6
+ version = "1.3.0"
7
7
  edition = "2021"
8
8
  rust-version = "1.82"
9
9
  license = "MIT OR Apache-2.0"
@@ -16,5 +16,6 @@ pub mod qa;
16
16
  pub mod ranks;
17
17
  pub mod resample;
18
18
  pub mod surface;
19
+ pub mod survival;
19
20
  pub mod ter;
20
21
  pub mod text;
@@ -0,0 +1,84 @@
1
+ //! Survival analysis: Harrell's concordance index in O(n log n) with a Fenwick tree.
2
+
3
+ /// `(Σ w_i (concordant_i + ties_i / 2), Σ w_i comparable_i, comparable pairs)` over events `i`, where `j` is
4
+ /// comparable to event `i` when `t_j > t_i`, or `t_j == t_i` with `j` censored; risks within `tol` are ties.
5
+ /// Subjects are processed in decreasing time (stable), censored subjects at a time before its events, exactly
6
+ /// as EvalSuite's Python implementation, so the sums are accumulated in the same order and bit-identical.
7
+ pub fn concordance(t: &[f64], event: &[u8], risk: &[f64], w: &[f64], tol: f64) -> (f64, f64, u64) {
8
+ let n = t.len();
9
+ let mut order_r: Vec<f64> = risk.to_vec();
10
+ order_r.sort_by(|a, b| a.partial_cmp(b).unwrap_or(std::cmp::Ordering::Equal));
11
+ let below = |x: f64| order_r.partition_point(|&v| v < x);
12
+ let at_most = |x: f64| order_r.partition_point(|&v| v <= x);
13
+ let slot: Vec<usize> = risk.iter().map(|&r| below(r)).collect();
14
+ let mut order_t: Vec<usize> = (0..n).collect();
15
+ order_t.sort_by(|&a, &b| {
16
+ (-t[a])
17
+ .partial_cmp(&-t[b])
18
+ .unwrap_or(std::cmp::Ordering::Equal)
19
+ }); // stable, as NumPy's
20
+ let mut tree = vec![0u64; n + 1];
21
+ let add = |tree: &mut Vec<u64>, pos: usize| {
22
+ let mut i = pos + 1;
23
+ while i <= n {
24
+ tree[i] += 1;
25
+ i += i & i.wrapping_neg();
26
+ }
27
+ };
28
+ let prefix = |tree: &Vec<u64>, pos: usize| {
29
+ let mut i = pos;
30
+ let mut s = 0u64;
31
+ while i > 0 {
32
+ s += tree[i];
33
+ i -= i & i.wrapping_neg();
34
+ }
35
+ s
36
+ };
37
+ let (mut num, mut den, mut pairs, mut inserted) = (0.0f64, 0.0f64, 0u64, 0u64);
38
+ let mut i = 0;
39
+ while i < n {
40
+ let ti = t[order_t[i]];
41
+ let mut j = i;
42
+ while j < n && t[order_t[j]] == ti {
43
+ j += 1;
44
+ }
45
+ let group = &order_t[i..j];
46
+ for &k in group.iter().filter(|&&k| event[k] == 0) {
47
+ add(&mut tree, slot[k]);
48
+ inserted += 1;
49
+ }
50
+ for &k in group.iter().filter(|&&k| event[k] != 0) {
51
+ let less = prefix(&tree, below(risk[k] - tol));
52
+ let ties = prefix(&tree, at_most(risk[k] + tol)) - less;
53
+ if inserted > 0 {
54
+ num += w[k] * (less as f64 + 0.5 * ties as f64);
55
+ den += w[k] * inserted as f64;
56
+ pairs += inserted;
57
+ }
58
+ }
59
+ for &k in group.iter().filter(|&&k| event[k] != 0) {
60
+ add(&mut tree, slot[k]);
61
+ inserted += 1;
62
+ }
63
+ i = j;
64
+ }
65
+ (num, den, pairs)
66
+ }
67
+
68
+ #[cfg(test)]
69
+ mod tests {
70
+ use super::*;
71
+
72
+ #[test]
73
+ fn small_example() {
74
+ // times 1..4, all events, risk decreasing with time: every comparable pair concordant
75
+ let (num, den, pairs) = concordance(
76
+ &[1.0, 2.0, 3.0, 4.0],
77
+ &[1, 1, 1, 1],
78
+ &[4.0, 3.0, 2.0, 1.0],
79
+ &[1.0; 4],
80
+ 1e-8,
81
+ );
82
+ assert_eq!((num, den, pairs), (6.0, 6.0, 6));
83
+ }
84
+ }
@@ -10,7 +10,8 @@
10
10
  //! are bit-identical for any number of threads.
11
11
 
12
12
  use evalsuite_core::{
13
- agreement, coco, curve, groups, meteor, permutation, qa, ranks, resample, surface, ter, text,
13
+ agreement, coco, curve, groups, meteor, permutation, qa, ranks, resample, surface, survival,
14
+ ter, text,
14
15
  };
15
16
  use pyo3::exceptions::PyValueError;
16
17
  use pyo3::prelude::*;
@@ -395,6 +396,69 @@ fn coco_evaluate<'py>(
395
396
  ))
396
397
  }
397
398
 
399
+ /// Harrell's concordance sums `(numerator, denominator, comparable pairs)`. `time`, `risk` and `weight` are float64
400
+ /// views and `event` a uint8 view, all of `n` elements, kept alive and unchanged by the caller during the call.
401
+ #[pyfunction]
402
+ fn concordance(
403
+ py: Python<'_>,
404
+ time: (usize, usize),
405
+ event: (usize, usize),
406
+ risk: (usize, usize),
407
+ weight: (usize, usize),
408
+ tol: f64,
409
+ ) -> PyResult<(f64, f64, u64)> {
410
+ let t: &[f64] = view(time.0, time.1)?;
411
+ let e: &[u8] = view(event.0, event.1)?;
412
+ let r: &[f64] = view(risk.0, risk.1)?;
413
+ let w: &[f64] = view(weight.0, weight.1)?;
414
+ if e.len() != t.len() || r.len() != t.len() || w.len() != t.len() {
415
+ return Err(PyValueError::new_err(
416
+ "time, event, risk and weight must have the same length",
417
+ ));
418
+ }
419
+ Ok(py.detach(|| survival::concordance(t, e, r, w, tol)))
420
+ }
421
+
422
+ #[allow(clippy::too_many_arguments)]
423
+ /// [`concordance`] on every row of `indices` (an int64 view of `rows × n` subject indices), resamples in
424
+ /// parallel. Each row gathers time, event, risk and weight at its indices, exactly as NumPy fancy indexing.
425
+ #[pyfunction]
426
+ fn concordance_resamples(
427
+ py: Python<'_>,
428
+ time: (usize, usize),
429
+ event: (usize, usize),
430
+ risk: (usize, usize),
431
+ weight: (usize, usize),
432
+ tol: f64,
433
+ indices: (usize, usize),
434
+ rows: usize,
435
+ ) -> PyResult<Vec<(f64, f64, u64)>> {
436
+ let t: &[f64] = view(time.0, time.1)?;
437
+ let e: &[u8] = view(event.0, event.1)?;
438
+ let r: &[f64] = view(risk.0, risk.1)?;
439
+ let w: &[f64] = view(weight.0, weight.1)?;
440
+ let idx: &[i64] = view(indices.0, indices.1)?;
441
+ let n = t.len();
442
+ if e.len() != n || r.len() != n || w.len() != n || rows == 0 || idx.len() % rows != 0 {
443
+ return Err(PyValueError::new_err("inconsistent lengths"));
444
+ }
445
+ if idx.iter().any(|&i| i < 0 || i as usize >= n) {
446
+ return Err(PyValueError::new_err("index out of range"));
447
+ }
448
+ let m = idx.len() / rows;
449
+ Ok(py.detach(|| {
450
+ idx.par_chunks(m)
451
+ .map(|row| {
452
+ let tt: Vec<f64> = row.iter().map(|&i| t[i as usize]).collect();
453
+ let ee: Vec<u8> = row.iter().map(|&i| e[i as usize]).collect();
454
+ let rr: Vec<f64> = row.iter().map(|&i| r[i as usize]).collect();
455
+ let ww: Vec<f64> = row.iter().map(|&i| w[i as usize]).collect();
456
+ survival::concordance(&tt, &ee, &rr, &ww, tol)
457
+ })
458
+ .collect()
459
+ }))
460
+ }
461
+
398
462
  /// Counts of each code `0..k` in every resample. `codes` is a uint32 view, `indices` an int64 view of
399
463
  /// `rows × n` indices. Returns uint64 bytes (`rows × k`).
400
464
  #[pyfunction]
@@ -1066,6 +1130,8 @@ fn _core(m: &Bound<'_, PyModule>) -> PyResult<()> {
1066
1130
  }
1067
1131
  }
1068
1132
  m.add("__version__", env!("CARGO_PKG_VERSION"))?;
1133
+ m.add_function(wrap_pyfunction!(concordance, m)?)?;
1134
+ m.add_function(wrap_pyfunction!(concordance_resamples, m)?)?;
1069
1135
  m.add_function(wrap_pyfunction!(bleu_stats, m)?)?;
1070
1136
  m.add_function(wrap_pyfunction!(self_bleu_stats, m)?)?;
1071
1137
  m.add_function(wrap_pyfunction!(ter_corpus, m)?)?;