evalsuite-python 0.6.0__tar.gz → 0.7.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 (133) hide show
  1. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/CHANGELOG.md +51 -0
  2. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/PKG-INFO +49 -36
  3. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/README.md +48 -35
  4. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/rust/Cargo.lock +57 -2
  5. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/rust/Cargo.toml +1 -1
  6. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/rust/evalsuite-core/Cargo.toml +1 -0
  7. evalsuite_python-0.7.0/rust/evalsuite-core/src/agreement.rs +38 -0
  8. evalsuite_python-0.7.0/rust/evalsuite-core/src/coco.rs +325 -0
  9. evalsuite_python-0.7.0/rust/evalsuite-core/src/curve.rs +118 -0
  10. evalsuite_python-0.7.0/rust/evalsuite-core/src/groups.rs +101 -0
  11. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/rust/evalsuite-core/src/lib.rs +3 -0
  12. evalsuite_python-0.7.0/rust/evalsuite-core/src/resample.rs +162 -0
  13. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/rust/evalsuite-core/src/text.rs +247 -0
  14. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/rust/evalsuite-py/Cargo.toml +1 -0
  15. evalsuite_python-0.7.0/rust/evalsuite-py/src/lib.rs +684 -0
  16. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/_native.py +5 -0
  17. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/classification/metrics.py +76 -1
  18. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/llmsys/_common.py +34 -0
  19. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/llmsys/code.py +10 -0
  20. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/llmsys/longcontext.py +30 -11
  21. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/llmsys/multilingual.py +17 -8
  22. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/llmsys/robustness.py +23 -12
  23. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/llmsys/safety.py +31 -6
  24. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/stats/compare.py +5 -2
  25. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/stats/intervals.py +62 -15
  26. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/stats/paired.py +6 -1
  27. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/text/factuality.py +10 -1
  28. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/text/generation.py +22 -6
  29. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/text/judge.py +18 -9
  30. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/text/reasoning.py +21 -6
  31. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/version.py +1 -1
  32. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/vision/detection.py +48 -0
  33. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/test_native.py +206 -5
  34. evalsuite_python-0.6.0/rust/evalsuite-core/src/coco.rs +0 -66
  35. evalsuite_python-0.6.0/rust/evalsuite-core/src/resample.rs +0 -40
  36. evalsuite_python-0.6.0/rust/evalsuite-py/src/lib.rs +0 -328
  37. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/CONTRIBUTING.md +0 -0
  38. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/LICENSE +0 -0
  39. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/LICENSE-APACHE +0 -0
  40. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/pyproject.toml +0 -0
  41. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/rust/evalsuite-core/README.md +0 -0
  42. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/rust/evalsuite-core/src/hash.rs +0 -0
  43. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/rust/evalsuite-core/src/meteor.rs +0 -0
  44. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/rust/evalsuite-core/src/ter.rs +0 -0
  45. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/__init__.py +0 -0
  46. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/__main__.py +0 -0
  47. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/_bench_metrics.py +0 -0
  48. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/_lazy.py +0 -0
  49. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/api.py +0 -0
  50. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/benchmarks.py +0 -0
  51. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/calibration.py +0 -0
  52. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/classification/__init__.py +0 -0
  53. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/classification/_common.py +0 -0
  54. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/cli/__init__.py +0 -0
  55. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/cli/main.py +0 -0
  56. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/clinical/__init__.py +0 -0
  57. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/clinical/metrics.py +0 -0
  58. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/clinical/report.py +0 -0
  59. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/core/__init__.py +0 -0
  60. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/core/context.py +0 -0
  61. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/core/exceptions.py +0 -0
  62. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/core/export.py +0 -0
  63. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/core/registry.py +0 -0
  64. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/core/result.py +0 -0
  65. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/core/types.py +0 -0
  66. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/core/validation.py +0 -0
  67. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/llmsys/__init__.py +0 -0
  68. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/llmsys/agents.py +0 -0
  69. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/llmsys/efficiency.py +0 -0
  70. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/llmsys/uncertainty.py +0 -0
  71. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/plot.py +0 -0
  72. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/py.typed +0 -0
  73. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/regression/__init__.py +0 -0
  74. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/regression/metrics.py +0 -0
  75. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/reporting.py +0 -0
  76. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/stats/__init__.py +0 -0
  77. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/stats/_resolve.py +0 -0
  78. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/stats/effect.py +0 -0
  79. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/stats/hypothesis.py +0 -0
  80. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/stats/results.py +0 -0
  81. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/text/__init__.py +0 -0
  82. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/text/_common.py +0 -0
  83. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/text/qa.py +0 -0
  84. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/text/rag.py +0 -0
  85. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/text/report.py +0 -0
  86. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/text/retrieval.py +0 -0
  87. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/text/semantic.py +0 -0
  88. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/text/spice.py +0 -0
  89. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/text/structured.py +0 -0
  90. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/vision/__init__.py +0 -0
  91. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/src/evalsuite/vision/segmentation.py +0 -0
  92. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/__init__.py +0 -0
  93. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/classification/__init__.py +0 -0
  94. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/classification/test_against_sklearn.py +0 -0
  95. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/clinical/__init__.py +0 -0
  96. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/clinical/test_outputs.py +0 -0
  97. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/clinical/test_v020.py +0 -0
  98. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/conftest.py +0 -0
  99. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/integration/__init__.py +0 -0
  100. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/integration/test_qa.py +0 -0
  101. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/integration/test_readme_examples.py +0 -0
  102. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/integration/test_repo_hygiene.py +0 -0
  103. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/llmsys/__init__.py +0 -0
  104. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/llmsys/test_code_longcontext_efficiency.py +0 -0
  105. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/llmsys/test_edges.py +0 -0
  106. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/llmsys/test_fast_text.py +0 -0
  107. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/llmsys/test_hardening.py +0 -0
  108. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/llmsys/test_safety_robustness.py +0 -0
  109. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/llmsys/test_uncertainty_agents_multilingual.py +0 -0
  110. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/output/__init__.py +0 -0
  111. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/output/test_benchmarks.py +0 -0
  112. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/output/test_cli.py +0 -0
  113. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/output/test_plot.py +0 -0
  114. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/output/test_reporting.py +0 -0
  115. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/regression/__init__.py +0 -0
  116. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/regression/test_against_sklearn.py +0 -0
  117. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/stats/__init__.py +0 -0
  118. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/stats/test_branches.py +0 -0
  119. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/stats/test_compare.py +0 -0
  120. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/stats/test_fast_paths.py +0 -0
  121. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/stats/test_reference.py +0 -0
  122. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/text/__init__.py +0 -0
  123. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/text/test_against_references.py +0 -0
  124. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/text/test_text_edges.py +0 -0
  125. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/text/test_v040.py +0 -0
  126. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/unit/__init__.py +0 -0
  127. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/unit/test_core.py +0 -0
  128. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/unit/test_edges.py +0 -0
  129. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/vision/__init__.py +0 -0
  130. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/vision/test_detection.py +0 -0
  131. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/vision/test_edges.py +0 -0
  132. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/vision/test_outputs.py +0 -0
  133. {evalsuite_python-0.6.0 → evalsuite_python-0.7.0}/tests/vision/test_segmentation.py +0 -0
@@ -6,6 +6,57 @@ All notable changes to this project are documented here. The format follows
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.7.0] - 2026-11-24
10
+
11
+ More of EvalSuite runs in the compiled Rust core. Every result is unchanged: each new kernel is bit-identical to
12
+ the Python implementation it replaces (checked by `tests/test_native.py`), which stays as the fallback.
13
+
14
+ ### Added
15
+ - **ROC AUC and average precision** in the core: one stable sort per column, columns in parallel, with NumPy's
16
+ pairwise summation reproduced exactly. `evaluate()` now shares that sort between ROC AUC and average precision
17
+ (cached on its context), so it sorts each probability column once instead of twice. `evaluate()` with
18
+ probabilities: 2.5× faster (binary) to 4.3× (5-class, 1M samples); `roc_auc` 2.6×, `average_precision` 2×.
19
+ - **LLM-systems consistency metrics** (`paraphrase_consistency`, `response_stability`,
20
+ `cross_document_consistency`, `cross_lingual_consistency`, `majority_vote_accuracy`): answer groups are
21
+ counted in the core (equal pairs from answer counts, O(m) instead of O(m²) pair comparisons): 1.4–4.8×.
22
+ - **Rows of numbers read directly by the core** (no per-row NumPy arrays): `groundedness` 5×,
23
+ `citation_coverage` 7.8×, `toxicity_score` 6×, `exposure` 3×.
24
+ - **Pairwise preferences**: sequential `elo_ratings` 3.6×, and the Bradley–Terry win matrix.
25
+ - Parity tests for every new kernel (ties, sample weights, micro/macro/weighted/per-class, one-vs-one,
26
+ non-string answers, invalid inputs raising the same errors).
27
+
28
+ ### Not ported, on purpose
29
+ - Retrieval metrics: already 11–15× faster than ranx in Python; mapping document ids to the core cost more than
30
+ it saved.
31
+ - Krippendorff's alpha: already one vectorised NumPy pass; a compiled version was only 1.5× faster and could not
32
+ reproduce NumPy's matrix-multiply rounding, so results would have changed in the last digit.
33
+ - Fleiss' kappa and judge agreement are single vectorised integer passes; metrics built on Python's `ast`, JSON
34
+ or regular expressions (syntax validity, tool-call keys, answer normalisation) stay in Python.
35
+
36
+ ## [0.6.1] - 2026-11-24
37
+
38
+ Finishes the Rust port. Results are unchanged (bit-identical to the Python reference) unless you opt in to
39
+ `resampling="native"`.
40
+
41
+ ### Added
42
+ - Whole COCO evaluation in the core: IoU matrices (with the crowd rule), stable descending score sort, ignored
43
+ ground truth, greedy matching, precision/recall accumulation and the 101-point interpolation, in parallel
44
+ over classes (`detection_report`, `mean_average_precision`).
45
+ - Compiled CIDEr-D, CodeBLEU (n-gram and keyword-weighted n-gram terms) and distinct-n.
46
+ - Multithreading: every per-example kernel (BLEU, chrF, TER, ROUGE, METEOR, CIDEr, CodeBLEU, COCO, resample
47
+ counting) runs on all cores; `EVALSUITE_NUM_THREADS` caps the threads. Sums stay in example order, so the
48
+ thread count never changes a result.
49
+ - Opt-in `resampling="native"` for `bootstrap_ci`, `paired_bootstrap_test` and `compare`: resample indices are
50
+ drawn in the core (seeded xoshiro256++, one stream per resample, written straight into the index array).
51
+ About 3× faster bootstrap on 100,000 observations; reproducible with `random_state` and independent of the
52
+ thread count, but a different random stream from the default `"numpy"`. The default is unchanged.
53
+ - Parity tests for the new kernels, tied scores and user areas in COCO, thread-count invariance and native
54
+ resampling.
55
+
56
+ ### Fixed
57
+ - The ported float sums follow the running interpreter's built-in `sum()` (compensated summation on Python
58
+ 3.12+, sequential before), so CIDEr and CodeBLEU agree with the Python path to the last bit on every Python.
59
+
9
60
  ## [0.6.0] - 2026-11-24
10
61
 
11
62
  EvalSuite now has a **compiled core written in Rust**. The public API is unchanged and every result is identical:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: evalsuite-python
3
- Version: 0.6.0
3
+ Version: 0.7.0
4
4
  Classifier: Development Status :: 5 - Production/Stable
5
5
  Classifier: Intended Audience :: Science/Research
6
6
  Classifier: Intended Audience :: Healthcare Industry
@@ -85,9 +85,11 @@ Project-URL: Source, https://github.com/mkcs28/evalsuite-python
85
85
  EvalSuite brings classification, regression, clinical, statistical, segmentation and object-detection
86
86
  evaluation into one consistent, validated, documented framework.
87
87
 
88
- > **Status: stable (0.6.0).** Every item on the 0.1.0–0.5.0 roadmaps is implemented and verified, including SPICE.
89
- > **0.6.0 adds a compiled Rust core**: same API and identical results, with text metrics, COCO matching and
90
- > bootstrap resampling several times faster (prebuilt wheels for Linux, macOS and Windows).
88
+ > **Status: stable (0.7.0).** Every item on the 0.1.0–0.5.0 roadmaps is implemented and verified, including SPICE.
89
+ > **0.6 adds a compiled Rust core**: same API and identical results, with text metrics, COCO evaluation and
90
+ > bootstrap resampling several times faster and multithreaded (prebuilt wheels for Linux, macOS and Windows).
91
+ > **0.7.0** moves ROC AUC / average precision (and so `evaluate()`), the LLM-systems consistency metrics,
92
+ > groundedness, citation coverage, toxicity, exposure and Elo into the core.
91
93
  > **LLM systems arrive in 0.5.0**: safety, robustness, calibration and uncertainty, agents and tool use,
92
94
  > multilingual, code generation, long context and summarization, and inference efficiency and cost.
93
95
 
@@ -109,6 +111,13 @@ is needed. Anywhere else pip falls back to a pure-Python wheel that gives exactl
109
111
  `evalsuite._native.backend()` says which one is in use (`"rust"` or `"python"`), and
110
112
  `EVALSUITE_PURE_PYTHON=1` selects the Python implementations on any install.
111
113
 
114
+ The core runs independent examples (sentences, images, classes, resamples) in parallel on all CPU cores; set
115
+ `EVALSUITE_NUM_THREADS` to cap the number of threads. Results never depend on the thread count: sums are always
116
+ taken in example order. Bootstrap functions (`bootstrap_ci`, `paired_bootstrap_test`, `compare`) accept
117
+ `resampling="native"` to draw resample indices in the core (seeded xoshiro256++): reproducible with
118
+ `random_state` and faster on large inputs, but a different random stream from the default NumPy one, so the
119
+ interval endpoints differ slightly (statistically equivalent).
120
+
112
121
  ## Why EvalSuite
113
122
 
114
123
  - **One consistent API.** Every metric returns a result object that behaves like a number and exports to
@@ -349,51 +358,55 @@ Input files can be CSV, TSV, Parquet or JSON. Output format follows `--format` o
349
358
 
350
359
  ## Performance
351
360
 
352
- Benchmarked against reference implementations on the same data (fastest of 5 runs; EvalSuite 0.6.0, Python 3.13,
361
+ Benchmarked against reference implementations on the same data (fastest of 5 runs; EvalSuite 0.7.0, Python 3.13,
353
362
  NumPy 2.5, Linux x86_64). **Overall: 81 of 81 rows agree with the reference** (largest
354
- difference 2.8e-14), 81 are faster, and the geometric-mean speed-up across all
355
- 27 cases and three sizes is **3.70×**. At 1,000,000 samples (pixels for
363
+ difference 2.5e-14), 79 are faster (the other 2 are Hochberg correction at 1,000,000 p-values, 0.8–1.05× statsmodels across runs,
364
+ and latency percentiles, within timing noise of NumPy), and the geometric-mean speed-up across all
365
+ 27 cases and three sizes is **4.22×**. At 1,000,000 samples (pixels for
356
366
  segmentation; 1,000 images for detection and 50 for Hausdorff; 10,000 examples for the LLM cases), in
357
367
  alphabetical order:
358
368
 
359
369
  | Case | Reference | EvalSuite (ms) | Reference (ms) | Speed-up |
360
370
  | --- | --- | ---: | ---: | ---: |
361
- | 10 classes: macro F1 | scikit-learn | 10.2 | 107.4 | **10.5×** |
362
- | agreement: Krippendorff's alpha, interval (4 raters × 10000 items) | krippendorff | 1.3 | 2.9 | **2.3×** |
363
- | binary: 8 label metrics via evaluate() | scikit-learn | 11.2 | 818.5 | **73.1×** |
364
- | binary: ROC AUC | scikit-learn | 175.4 | 292.8 | **1.7×** |
365
- | calibration: slope and intercept | statsmodels | 234.7 | 938.0 | **4.0×** |
366
- | clinical: diagnostic report (7 CIs) | statsmodels | 4.3 | 4.4 | **1.0×** |
367
- | clinical: sensitivity, specificity, LR+, LR− | scikit-learn | 18.8 | 309.7 | **16.5×** |
368
- | decision curve: 99 thresholds | NumPy loop | 149.3 | 230.1 | **1.5×** |
369
- | detection: COCO evaluation (1000 images) | pycocotools | 268.5 | 628.8 | **2.3×** |
370
- | multiple testing: Hochberg (n p-values) | statsmodels | 69.4 | 81.2 | **1.2×** |
371
- | regression: MAE, MSE, RMSE, R² via evaluate() | scikit-learn | 7.4 | 12.0 | **1.6×** |
372
- | retrieval: MRR, MAP@20, NDCG@10 (10000 queries) | ranx | 121.7 | 546.7 | **4.5×** |
373
- | segmentation: Dice and IoU per class (n = pixels) | scikit-learn | 34.2 | 200.8 | **5.9×** |
374
- | segmentation: Hausdorff distance (50 images) | SciPy | 11.0 | 13.4 | **1.2×** |
371
+ | 10 classes: macro F1 | scikit-learn | 7.1 | 109.5 | **15.5×** |
372
+ | agreement: Krippendorff's alpha, interval (4 raters × 10000 items) | krippendorff | 1.3 | 2.7 | **2.2×** |
373
+ | binary: 8 label metrics via evaluate() | scikit-learn | 9.8 | 860.9 | **87.6×** |
374
+ | binary: ROC AUC | scikit-learn | 84.8 | 267.7 | **3.2×** |
375
+ | calibration: slope and intercept | statsmodels | 179.6 | 946.7 | **5.3×** |
376
+ | clinical: diagnostic report (7 CIs) | statsmodels | 4.4 | 4.7 | **1.1×** |
377
+ | clinical: sensitivity, specificity, LR+, LR− | scikit-learn | 17.7 | 328.1 | **18.5×** |
378
+ | decision curve: 99 thresholds | NumPy loop | 133.1 | 168.4 | **1.3×** |
379
+ | detection: COCO evaluation (1000 images) | pycocotools | 30.3 | 616.3 | **20.4×** |
380
+ | multiple testing: Hochberg (n p-values) | statsmodels | 86.4 | 69.9 | 0.81× |
381
+ | regression: MAE, MSE, RMSE, R² via evaluate() | scikit-learn | 6.2 | 9.9 | **1.6×** |
382
+ | retrieval: MRR, MAP@20, NDCG@10 (10000 queries) | ranx | 118.3 | 577.6 | **4.9×** |
383
+ | segmentation: Dice and IoU per class (n = pixels) | scikit-learn | 29.3 | 215.2 | **7.3×** |
384
+ | segmentation: Hausdorff distance (50 images) | SciPy | 8.7 | 14.1 | **1.6×** |
375
385
  | statistics: Cramér's V (5×5 table) | SciPy | 0.0 | 0.2 | **12.0×** |
376
- | statistics: Mann–Whitney U | SciPy | 152.1 | 323.0 | **2.1×** |
377
- | statistics: Welch t-test | SciPy | 7.7 | 11.6 | **1.5×** |
378
- | structured: JSON Schema compliance (10000 documents) | jsonschema | 88.9 | 224.7 | **2.5×** |
379
- | systems: CodeBLEU n-gram terms (1000 programs) | codebleu | 385.3 | 505.1 | **1.3×** |
380
- | systems: confidence AUROC (n answers) | scikit-learn | 166.0 | 265.3 | **1.6×** |
381
- | systems: distribution-shift drop, Welch CI (n scores) | SciPy | 10.8 | 12.1 | **1.1×** |
382
- | systems: invalid tool calls vs JSON Schema (10000 tasks) | jsonschema | 79.1 | 209.2 | **2.6×** |
383
- | systems: latency p50 / p95 / p99 (n requests) | NumPy | 13.7 | 15.4 | **1.1×** |
384
- | systems: maintainability index (1000 programs) | radon | 84.5 | 93.4 | **1.1×** |
385
- | text: corpus BLEU and chrF (10000 sentences) | sacreBLEU | 215.2 | 1962.8 | **9.1×** |
386
- | text: METEOR, exact and stem matches (10000 sentences) | NLTK | 71.0 | 363.4 | **5.1×** |
387
- | text: ROUGE-1, ROUGE-2, ROUGE-L (10000 sentences) | rouge-score | 154.6 | 608.3 | **3.9×** |
386
+ | statistics: Mann–Whitney U | SciPy | 115.1 | 305.0 | **2.6×** |
387
+ | statistics: Welch t-test | SciPy | 4.9 | 7.2 | **1.5×** |
388
+ | structured: JSON Schema compliance (10000 documents) | jsonschema | 100.6 | 224.3 | **2.2×** |
389
+ | systems: CodeBLEU n-gram terms (1000 programs) | codebleu | 313.9 | 511.3 | **1.6×** |
390
+ | systems: confidence AUROC (n answers) | scikit-learn | 181.2 | 279.3 | **1.5×** |
391
+ | systems: distribution-shift drop, Welch CI (n scores) | SciPy | 8.6 | 9.8 | **1.1×** |
392
+ | systems: invalid tool calls vs JSON Schema (10000 tasks) | jsonschema | 109.2 | 219.3 | **2.0×** |
393
+ | systems: latency p50 / p95 / p99 (n requests) | NumPy | 12.9 | 12.5 | 0.97× |
394
+ | systems: maintainability index (1000 programs) | radon | 88.6 | 98.7 | **1.1×** |
395
+ | text: corpus BLEU and chrF (10000 sentences) | sacreBLEU | 165.0 | 2030.3 | **12.3×** |
396
+ | text: METEOR, exact and stem matches (10000 sentences) | NLTK | 63.8 | 363.8 | **5.7×** |
397
+ | text: ROUGE-1, ROUGE-2, ROUGE-L (10000 sentences) | rouge-score | 152.8 | 613.6 | **4.0×** |
388
398
 
389
399
  **Every metric is benchmarked too** (`evalsuite benchmark --suite metrics`): all 225 registered metrics and
390
400
  statistics functions at 10,000 and 100,000 samples. 86 are compared with a reference library, 118 with an
391
401
  independent textbook formula and 21 (learned, judge-dependent or randomised) are timed alone; **all 204
392
- comparisons agree**, and against the libraries the geometric-mean speed-up is **5.99×** (172 of 172
402
+ comparisons agree**, and against the libraries the geometric-mean speed-up is **6.44×** (172 of 172
393
403
  measurements faster). Per-metric table in BENCHMARKS.md.
394
404
 
395
- **Every row is faster than its reference.** The text metrics (BLEU, chrF, TER, ROUGE, METEOR), COCO
396
- matching and bootstrap resampling run in the compiled Rust core; bootstrap intervals, paired bootstrap tests and
405
+ **Nearly every workload is faster than its reference.** The text metrics (BLEU, chrF, TER, ROUGE, METEOR, CIDEr,
406
+ CodeBLEU's n-gram terms, distinct-n), the whole COCO evaluation (IoU, score sort, matching, accumulation),
407
+ ROC AUC and average precision (one sort per column, shared by both inside `evaluate()`), the LLM-systems
408
+ consistency, groundedness, citation, toxicity and exposure metrics, Elo ratings and bootstrap resampling run in
409
+ the compiled, multithreaded Rust core; bootstrap intervals, paired bootstrap tests and
397
410
  `compare()` evaluate confusion-matrix metrics from counts of each resample's (true, predicted) pairs instead of
398
411
  copies of the data. `evaluate()` validates inputs once and builds the confusion
399
412
  matrix once for all metrics, and integer labels are encoded without sorting. The rank tests rank the data once
@@ -10,9 +10,11 @@
10
10
  EvalSuite brings classification, regression, clinical, statistical, segmentation and object-detection
11
11
  evaluation into one consistent, validated, documented framework.
12
12
 
13
- > **Status: stable (0.6.0).** Every item on the 0.1.0–0.5.0 roadmaps is implemented and verified, including SPICE.
14
- > **0.6.0 adds a compiled Rust core**: same API and identical results, with text metrics, COCO matching and
15
- > bootstrap resampling several times faster (prebuilt wheels for Linux, macOS and Windows).
13
+ > **Status: stable (0.7.0).** Every item on the 0.1.0–0.5.0 roadmaps is implemented and verified, including SPICE.
14
+ > **0.6 adds a compiled Rust core**: same API and identical results, with text metrics, COCO evaluation and
15
+ > bootstrap resampling several times faster and multithreaded (prebuilt wheels for Linux, macOS and Windows).
16
+ > **0.7.0** moves ROC AUC / average precision (and so `evaluate()`), the LLM-systems consistency metrics,
17
+ > groundedness, citation coverage, toxicity, exposure and Elo into the core.
16
18
  > **LLM systems arrive in 0.5.0**: safety, robustness, calibration and uncertainty, agents and tool use,
17
19
  > multilingual, code generation, long context and summarization, and inference efficiency and cost.
18
20
 
@@ -34,6 +36,13 @@ is needed. Anywhere else pip falls back to a pure-Python wheel that gives exactl
34
36
  `evalsuite._native.backend()` says which one is in use (`"rust"` or `"python"`), and
35
37
  `EVALSUITE_PURE_PYTHON=1` selects the Python implementations on any install.
36
38
 
39
+ The core runs independent examples (sentences, images, classes, resamples) in parallel on all CPU cores; set
40
+ `EVALSUITE_NUM_THREADS` to cap the number of threads. Results never depend on the thread count: sums are always
41
+ taken in example order. Bootstrap functions (`bootstrap_ci`, `paired_bootstrap_test`, `compare`) accept
42
+ `resampling="native"` to draw resample indices in the core (seeded xoshiro256++): reproducible with
43
+ `random_state` and faster on large inputs, but a different random stream from the default NumPy one, so the
44
+ interval endpoints differ slightly (statistically equivalent).
45
+
37
46
  ## Why EvalSuite
38
47
 
39
48
  - **One consistent API.** Every metric returns a result object that behaves like a number and exports to
@@ -274,51 +283,55 @@ Input files can be CSV, TSV, Parquet or JSON. Output format follows `--format` o
274
283
 
275
284
  ## Performance
276
285
 
277
- Benchmarked against reference implementations on the same data (fastest of 5 runs; EvalSuite 0.6.0, Python 3.13,
286
+ Benchmarked against reference implementations on the same data (fastest of 5 runs; EvalSuite 0.7.0, Python 3.13,
278
287
  NumPy 2.5, Linux x86_64). **Overall: 81 of 81 rows agree with the reference** (largest
279
- difference 2.8e-14), 81 are faster, and the geometric-mean speed-up across all
280
- 27 cases and three sizes is **3.70×**. At 1,000,000 samples (pixels for
288
+ difference 2.5e-14), 79 are faster (the other 2 are Hochberg correction at 1,000,000 p-values, 0.8–1.05× statsmodels across runs,
289
+ and latency percentiles, within timing noise of NumPy), and the geometric-mean speed-up across all
290
+ 27 cases and three sizes is **4.22×**. At 1,000,000 samples (pixels for
281
291
  segmentation; 1,000 images for detection and 50 for Hausdorff; 10,000 examples for the LLM cases), in
282
292
  alphabetical order:
283
293
 
284
294
  | Case | Reference | EvalSuite (ms) | Reference (ms) | Speed-up |
285
295
  | --- | --- | ---: | ---: | ---: |
286
- | 10 classes: macro F1 | scikit-learn | 10.2 | 107.4 | **10.5×** |
287
- | agreement: Krippendorff's alpha, interval (4 raters × 10000 items) | krippendorff | 1.3 | 2.9 | **2.3×** |
288
- | binary: 8 label metrics via evaluate() | scikit-learn | 11.2 | 818.5 | **73.1×** |
289
- | binary: ROC AUC | scikit-learn | 175.4 | 292.8 | **1.7×** |
290
- | calibration: slope and intercept | statsmodels | 234.7 | 938.0 | **4.0×** |
291
- | clinical: diagnostic report (7 CIs) | statsmodels | 4.3 | 4.4 | **1.0×** |
292
- | clinical: sensitivity, specificity, LR+, LR− | scikit-learn | 18.8 | 309.7 | **16.5×** |
293
- | decision curve: 99 thresholds | NumPy loop | 149.3 | 230.1 | **1.5×** |
294
- | detection: COCO evaluation (1000 images) | pycocotools | 268.5 | 628.8 | **2.3×** |
295
- | multiple testing: Hochberg (n p-values) | statsmodels | 69.4 | 81.2 | **1.2×** |
296
- | regression: MAE, MSE, RMSE, R² via evaluate() | scikit-learn | 7.4 | 12.0 | **1.6×** |
297
- | retrieval: MRR, MAP@20, NDCG@10 (10000 queries) | ranx | 121.7 | 546.7 | **4.5×** |
298
- | segmentation: Dice and IoU per class (n = pixels) | scikit-learn | 34.2 | 200.8 | **5.9×** |
299
- | segmentation: Hausdorff distance (50 images) | SciPy | 11.0 | 13.4 | **1.2×** |
296
+ | 10 classes: macro F1 | scikit-learn | 7.1 | 109.5 | **15.5×** |
297
+ | agreement: Krippendorff's alpha, interval (4 raters × 10000 items) | krippendorff | 1.3 | 2.7 | **2.2×** |
298
+ | binary: 8 label metrics via evaluate() | scikit-learn | 9.8 | 860.9 | **87.6×** |
299
+ | binary: ROC AUC | scikit-learn | 84.8 | 267.7 | **3.2×** |
300
+ | calibration: slope and intercept | statsmodels | 179.6 | 946.7 | **5.3×** |
301
+ | clinical: diagnostic report (7 CIs) | statsmodels | 4.4 | 4.7 | **1.1×** |
302
+ | clinical: sensitivity, specificity, LR+, LR− | scikit-learn | 17.7 | 328.1 | **18.5×** |
303
+ | decision curve: 99 thresholds | NumPy loop | 133.1 | 168.4 | **1.3×** |
304
+ | detection: COCO evaluation (1000 images) | pycocotools | 30.3 | 616.3 | **20.4×** |
305
+ | multiple testing: Hochberg (n p-values) | statsmodels | 86.4 | 69.9 | 0.81× |
306
+ | regression: MAE, MSE, RMSE, R² via evaluate() | scikit-learn | 6.2 | 9.9 | **1.6×** |
307
+ | retrieval: MRR, MAP@20, NDCG@10 (10000 queries) | ranx | 118.3 | 577.6 | **4.9×** |
308
+ | segmentation: Dice and IoU per class (n = pixels) | scikit-learn | 29.3 | 215.2 | **7.3×** |
309
+ | segmentation: Hausdorff distance (50 images) | SciPy | 8.7 | 14.1 | **1.6×** |
300
310
  | statistics: Cramér's V (5×5 table) | SciPy | 0.0 | 0.2 | **12.0×** |
301
- | statistics: Mann–Whitney U | SciPy | 152.1 | 323.0 | **2.1×** |
302
- | statistics: Welch t-test | SciPy | 7.7 | 11.6 | **1.5×** |
303
- | structured: JSON Schema compliance (10000 documents) | jsonschema | 88.9 | 224.7 | **2.5×** |
304
- | systems: CodeBLEU n-gram terms (1000 programs) | codebleu | 385.3 | 505.1 | **1.3×** |
305
- | systems: confidence AUROC (n answers) | scikit-learn | 166.0 | 265.3 | **1.6×** |
306
- | systems: distribution-shift drop, Welch CI (n scores) | SciPy | 10.8 | 12.1 | **1.1×** |
307
- | systems: invalid tool calls vs JSON Schema (10000 tasks) | jsonschema | 79.1 | 209.2 | **2.6×** |
308
- | systems: latency p50 / p95 / p99 (n requests) | NumPy | 13.7 | 15.4 | **1.1×** |
309
- | systems: maintainability index (1000 programs) | radon | 84.5 | 93.4 | **1.1×** |
310
- | text: corpus BLEU and chrF (10000 sentences) | sacreBLEU | 215.2 | 1962.8 | **9.1×** |
311
- | text: METEOR, exact and stem matches (10000 sentences) | NLTK | 71.0 | 363.4 | **5.1×** |
312
- | text: ROUGE-1, ROUGE-2, ROUGE-L (10000 sentences) | rouge-score | 154.6 | 608.3 | **3.9×** |
311
+ | statistics: Mann–Whitney U | SciPy | 115.1 | 305.0 | **2.6×** |
312
+ | statistics: Welch t-test | SciPy | 4.9 | 7.2 | **1.5×** |
313
+ | structured: JSON Schema compliance (10000 documents) | jsonschema | 100.6 | 224.3 | **2.2×** |
314
+ | systems: CodeBLEU n-gram terms (1000 programs) | codebleu | 313.9 | 511.3 | **1.6×** |
315
+ | systems: confidence AUROC (n answers) | scikit-learn | 181.2 | 279.3 | **1.5×** |
316
+ | systems: distribution-shift drop, Welch CI (n scores) | SciPy | 8.6 | 9.8 | **1.1×** |
317
+ | systems: invalid tool calls vs JSON Schema (10000 tasks) | jsonschema | 109.2 | 219.3 | **2.0×** |
318
+ | systems: latency p50 / p95 / p99 (n requests) | NumPy | 12.9 | 12.5 | 0.97× |
319
+ | systems: maintainability index (1000 programs) | radon | 88.6 | 98.7 | **1.1×** |
320
+ | text: corpus BLEU and chrF (10000 sentences) | sacreBLEU | 165.0 | 2030.3 | **12.3×** |
321
+ | text: METEOR, exact and stem matches (10000 sentences) | NLTK | 63.8 | 363.8 | **5.7×** |
322
+ | text: ROUGE-1, ROUGE-2, ROUGE-L (10000 sentences) | rouge-score | 152.8 | 613.6 | **4.0×** |
313
323
 
314
324
  **Every metric is benchmarked too** (`evalsuite benchmark --suite metrics`): all 225 registered metrics and
315
325
  statistics functions at 10,000 and 100,000 samples. 86 are compared with a reference library, 118 with an
316
326
  independent textbook formula and 21 (learned, judge-dependent or randomised) are timed alone; **all 204
317
- comparisons agree**, and against the libraries the geometric-mean speed-up is **5.99×** (172 of 172
327
+ comparisons agree**, and against the libraries the geometric-mean speed-up is **6.44×** (172 of 172
318
328
  measurements faster). Per-metric table in BENCHMARKS.md.
319
329
 
320
- **Every row is faster than its reference.** The text metrics (BLEU, chrF, TER, ROUGE, METEOR), COCO
321
- matching and bootstrap resampling run in the compiled Rust core; bootstrap intervals, paired bootstrap tests and
330
+ **Nearly every workload is faster than its reference.** The text metrics (BLEU, chrF, TER, ROUGE, METEOR, CIDEr,
331
+ CodeBLEU's n-gram terms, distinct-n), the whole COCO evaluation (IoU, score sort, matching, accumulation),
332
+ ROC AUC and average precision (one sort per column, shared by both inside `evaluate()`), the LLM-systems
333
+ consistency, groundedness, citation, toxicity and exposure metrics, Elo ratings and bootstrap resampling run in
334
+ the compiled, multithreaded Rust core; bootstrap intervals, paired bootstrap tests and
322
335
  `compare()` evaluate confusion-matrix metrics from counts of each resample's (true, predicted) pairs instead of
323
336
  copies of the data. `evaluate()` validates inputs once and builds the confusion
324
337
  matrix once for all metrics, and integer labels are encoded without sorting. The rank tests rank the data once
@@ -2,16 +2,51 @@
2
2
  # It is not intended for manual editing.
3
3
  version = 3
4
4
 
5
+ [[package]]
6
+ name = "crossbeam-deque"
7
+ version = "0.8.8"
8
+ source = "registry+https://github.com/rust-lang/crates.io-index"
9
+ checksum = "622f3fc73690be383c7214310406f28a90e6edeadc3cea882f9d71e495b9711a"
10
+ dependencies = [
11
+ "crossbeam-epoch",
12
+ "crossbeam-utils",
13
+ ]
14
+
15
+ [[package]]
16
+ name = "crossbeam-epoch"
17
+ version = "0.9.21"
18
+ source = "registry+https://github.com/rust-lang/crates.io-index"
19
+ checksum = "dc74980687109a3b14c72fd458107bf0baa1da1a1a805e178d15501ba9b86d9d"
20
+ dependencies = [
21
+ "crossbeam-utils",
22
+ ]
23
+
24
+ [[package]]
25
+ name = "crossbeam-utils"
26
+ version = "0.8.23"
27
+ source = "registry+https://github.com/rust-lang/crates.io-index"
28
+ checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6"
29
+
30
+ [[package]]
31
+ name = "either"
32
+ version = "1.19.0"
33
+ source = "registry+https://github.com/rust-lang/crates.io-index"
34
+ checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be"
35
+
5
36
  [[package]]
6
37
  name = "evalsuite-core"
7
- version = "0.6.0"
38
+ version = "0.7.0"
39
+ dependencies = [
40
+ "rayon",
41
+ ]
8
42
 
9
43
  [[package]]
10
44
  name = "evalsuite-py"
11
- version = "0.6.0"
45
+ version = "0.7.0"
12
46
  dependencies = [
13
47
  "evalsuite-core",
14
48
  "pyo3",
49
+ "rayon",
15
50
  ]
16
51
 
17
52
  [[package]]
@@ -113,6 +148,26 @@ dependencies = [
113
148
  "proc-macro2",
114
149
  ]
115
150
 
151
+ [[package]]
152
+ name = "rayon"
153
+ version = "1.12.0"
154
+ source = "registry+https://github.com/rust-lang/crates.io-index"
155
+ checksum = "fb39b166781f92d482534ef4b4b1b2568f42613b53e5b6c160e24cfbfa30926d"
156
+ dependencies = [
157
+ "either",
158
+ "rayon-core",
159
+ ]
160
+
161
+ [[package]]
162
+ name = "rayon-core"
163
+ version = "1.13.0"
164
+ source = "registry+https://github.com/rust-lang/crates.io-index"
165
+ checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91"
166
+ dependencies = [
167
+ "crossbeam-deque",
168
+ "crossbeam-utils",
169
+ ]
170
+
116
171
  [[package]]
117
172
  name = "syn"
118
173
  version = "3.0.10"
@@ -3,7 +3,7 @@ members = ["evalsuite-core", "evalsuite-py"]
3
3
  resolver = "2"
4
4
 
5
5
  [workspace.package]
6
- version = "0.6.0"
6
+ version = "0.7.0"
7
7
  edition = "2021"
8
8
  rust-version = "1.82"
9
9
  license = "MIT OR Apache-2.0"
@@ -12,3 +12,4 @@ keywords = ["evaluation", "metrics", "nlp", "statistics", "machine-learning"]
12
12
  categories = ["science", "algorithms"]
13
13
 
14
14
  [dependencies]
15
+ rayon = "1.12"
@@ -0,0 +1,38 @@
1
+ //! Pairwise-preference kernels: sequential Elo and the Bradley–Terry win matrix, as EvalSuite's Python reference (`text/judge.py`).
2
+
3
+ /// Sequential Elo ratings. `rows` are (a, b, outcome for a); returns the final ratings of `m` players.
4
+ pub fn elo(
5
+ rows: &[(usize, usize, f64)],
6
+ m: usize,
7
+ k: f64,
8
+ initial: f64,
9
+ scale: f64,
10
+ base: f64,
11
+ ) -> Vec<f64> {
12
+ let mut r = vec![initial; m];
13
+ for &(a, b, o) in rows {
14
+ let ea = 1.0 / (1.0 + base.powf((r[b] - r[a]) / scale));
15
+ r[a] += k * (o - ea);
16
+ r[b] += k * ((1.0 - o) - (1.0 - ea));
17
+ }
18
+ r
19
+ }
20
+
21
+ /// Bradley–Terry win matrix (row-major m × m): wins[a][b] += o and wins[b][a] += 1 − o for every row, in order.
22
+ pub fn win_matrix(rows: &[(usize, usize, f64)], m: usize) -> Vec<f64> {
23
+ let mut w = vec![0.0f64; m * m];
24
+ for &(a, b, o) in rows {
25
+ w[a * m + b] += o;
26
+ w[b * m + a] += 1.0 - o;
27
+ }
28
+ w
29
+ }
30
+
31
+ #[cfg(test)]
32
+ mod tests {
33
+ #[test]
34
+ fn elo_symmetric() {
35
+ let r = super::elo(&[(0, 1, 1.0)], 2, 4.0, 1000.0, 400.0, 10.0);
36
+ assert_eq!(r, vec![1002.0, 998.0]);
37
+ }
38
+ }