evalsuite-python 0.6.1__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.
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/CHANGELOG.md +27 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/PKG-INFO +40 -38
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/README.md +39 -37
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/rust/Cargo.lock +2 -2
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/rust/Cargo.toml +1 -1
- evalsuite_python-0.7.0/rust/evalsuite-core/src/agreement.rs +38 -0
- evalsuite_python-0.7.0/rust/evalsuite-core/src/curve.rs +118 -0
- evalsuite_python-0.7.0/rust/evalsuite-core/src/groups.rs +101 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/rust/evalsuite-core/src/lib.rs +3 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/rust/evalsuite-py/src/lib.rs +106 -1
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/classification/metrics.py +76 -1
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/llmsys/_common.py +34 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/llmsys/longcontext.py +30 -11
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/llmsys/multilingual.py +17 -8
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/llmsys/robustness.py +23 -12
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/llmsys/safety.py +31 -6
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/text/factuality.py +10 -1
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/text/judge.py +18 -9
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/text/reasoning.py +21 -6
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/version.py +1 -1
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/test_native.py +135 -1
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/CONTRIBUTING.md +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/LICENSE +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/LICENSE-APACHE +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/pyproject.toml +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/rust/evalsuite-core/Cargo.toml +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/rust/evalsuite-core/README.md +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/rust/evalsuite-core/src/coco.rs +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/rust/evalsuite-core/src/hash.rs +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/rust/evalsuite-core/src/meteor.rs +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/rust/evalsuite-core/src/resample.rs +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/rust/evalsuite-core/src/ter.rs +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/rust/evalsuite-core/src/text.rs +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/rust/evalsuite-py/Cargo.toml +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/__init__.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/__main__.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/_bench_metrics.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/_lazy.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/_native.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/api.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/benchmarks.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/calibration.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/classification/__init__.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/classification/_common.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/cli/__init__.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/cli/main.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/clinical/__init__.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/clinical/metrics.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/clinical/report.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/core/__init__.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/core/context.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/core/exceptions.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/core/export.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/core/registry.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/core/result.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/core/types.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/core/validation.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/llmsys/__init__.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/llmsys/agents.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/llmsys/code.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/llmsys/efficiency.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/llmsys/uncertainty.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/plot.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/py.typed +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/regression/__init__.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/regression/metrics.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/reporting.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/stats/__init__.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/stats/_resolve.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/stats/compare.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/stats/effect.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/stats/hypothesis.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/stats/intervals.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/stats/paired.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/stats/results.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/text/__init__.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/text/_common.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/text/generation.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/text/qa.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/text/rag.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/text/report.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/text/retrieval.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/text/semantic.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/text/spice.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/text/structured.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/vision/__init__.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/vision/detection.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/src/evalsuite/vision/segmentation.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/__init__.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/classification/__init__.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/classification/test_against_sklearn.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/clinical/__init__.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/clinical/test_outputs.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/clinical/test_v020.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/conftest.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/integration/__init__.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/integration/test_qa.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/integration/test_readme_examples.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/integration/test_repo_hygiene.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/llmsys/__init__.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/llmsys/test_code_longcontext_efficiency.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/llmsys/test_edges.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/llmsys/test_fast_text.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/llmsys/test_hardening.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/llmsys/test_safety_robustness.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/llmsys/test_uncertainty_agents_multilingual.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/output/__init__.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/output/test_benchmarks.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/output/test_cli.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/output/test_plot.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/output/test_reporting.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/regression/__init__.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/regression/test_against_sklearn.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/stats/__init__.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/stats/test_branches.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/stats/test_compare.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/stats/test_fast_paths.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/stats/test_reference.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/text/__init__.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/text/test_against_references.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/text/test_text_edges.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/text/test_v040.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/unit/__init__.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/unit/test_core.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/unit/test_edges.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/vision/__init__.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/vision/test_detection.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/vision/test_edges.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/vision/test_outputs.py +0 -0
- {evalsuite_python-0.6.1 → evalsuite_python-0.7.0}/tests/vision/test_segmentation.py +0 -0
|
@@ -6,6 +6,33 @@ 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
|
+
|
|
9
36
|
## [0.6.1] - 2026-11-24
|
|
10
37
|
|
|
11
38
|
Finishes the Rust port. Results are unchanged (bit-identical to the Python reference) unless you opt in to
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: evalsuite-python
|
|
3
|
-
Version: 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,11 +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.
|
|
88
|
+
> **Status: stable (0.7.0).** Every item on the 0.1.0–0.5.0 roadmaps is implemented and verified, including SPICE.
|
|
89
89
|
> **0.6 adds a compiled Rust core**: same API and identical results, with text metrics, COCO evaluation and
|
|
90
90
|
> bootstrap resampling several times faster and multithreaded (prebuilt wheels for Linux, macOS and Windows).
|
|
91
|
-
> 0.
|
|
92
|
-
>
|
|
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.
|
|
93
93
|
> **LLM systems arrive in 0.5.0**: safety, robustness, calibration and uncertainty, agents and tool use,
|
|
94
94
|
> multilingual, code generation, long context and summarization, and inference efficiency and cost.
|
|
95
95
|
|
|
@@ -358,53 +358,55 @@ Input files can be CSV, TSV, Parquet or JSON. Output format follows `--format` o
|
|
|
358
358
|
|
|
359
359
|
## Performance
|
|
360
360
|
|
|
361
|
-
Benchmarked against reference implementations on the same data (fastest of 5 runs; EvalSuite 0.
|
|
361
|
+
Benchmarked against reference implementations on the same data (fastest of 5 runs; EvalSuite 0.7.0, Python 3.13,
|
|
362
362
|
NumPy 2.5, Linux x86_64). **Overall: 81 of 81 rows agree with the reference** (largest
|
|
363
|
-
difference 2.5e-14),
|
|
364
|
-
|
|
365
|
-
27 cases and three sizes is **4.
|
|
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
|
|
366
366
|
segmentation; 1,000 images for detection and 50 for Hausdorff; 10,000 examples for the LLM cases), in
|
|
367
367
|
alphabetical order:
|
|
368
368
|
|
|
369
369
|
| Case | Reference | EvalSuite (ms) | Reference (ms) | Speed-up |
|
|
370
370
|
| --- | --- | ---: | ---: | ---: |
|
|
371
|
-
| 10 classes: macro F1 | scikit-learn |
|
|
372
|
-
| agreement: Krippendorff's alpha, interval (4 raters × 10000 items) | krippendorff | 1.
|
|
373
|
-
| binary: 8 label metrics via evaluate() | scikit-learn | 9.
|
|
374
|
-
| binary: ROC AUC | scikit-learn |
|
|
375
|
-
| calibration: slope and intercept | statsmodels |
|
|
376
|
-
| clinical: diagnostic report (7 CIs) | statsmodels | 4.
|
|
377
|
-
| clinical: sensitivity, specificity, LR+, LR− | scikit-learn | 17.
|
|
378
|
-
| decision curve: 99 thresholds | NumPy loop |
|
|
379
|
-
| detection: COCO evaluation (1000 images) | pycocotools |
|
|
380
|
-
| multiple testing: Hochberg (n p-values) | statsmodels |
|
|
381
|
-
| regression: MAE, MSE, RMSE, R² via evaluate() | scikit-learn |
|
|
382
|
-
| retrieval: MRR, MAP@20, NDCG@10 (10000 queries) | ranx |
|
|
383
|
-
| segmentation: Dice and IoU per class (n = pixels) | scikit-learn |
|
|
384
|
-
| segmentation: Hausdorff distance (50 images) | SciPy | 7
|
|
385
|
-
| statistics: Cramér's V (5×5 table) | SciPy | 0.0 | 0.2 | **12.
|
|
386
|
-
| statistics: Mann–Whitney U | SciPy |
|
|
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×** |
|
|
385
|
+
| statistics: Cramér's V (5×5 table) | SciPy | 0.0 | 0.2 | **12.0×** |
|
|
386
|
+
| statistics: Mann–Whitney U | SciPy | 115.1 | 305.0 | **2.6×** |
|
|
387
387
|
| statistics: Welch t-test | SciPy | 4.9 | 7.2 | **1.5×** |
|
|
388
|
-
| structured: JSON Schema compliance (10000 documents) | jsonschema |
|
|
389
|
-
| systems: CodeBLEU n-gram terms (1000 programs) | codebleu |
|
|
390
|
-
| systems: confidence AUROC (n answers) | scikit-learn |
|
|
391
|
-
| systems: distribution-shift drop, Welch CI (n scores) | SciPy |
|
|
392
|
-
| systems: invalid tool calls vs JSON Schema (10000 tasks) | jsonschema | 109.
|
|
393
|
-
| systems: latency p50 / p95 / p99 (n requests) | NumPy |
|
|
394
|
-
| systems: maintainability index (1000 programs) | radon |
|
|
395
|
-
| text: corpus BLEU and chrF (10000 sentences) | sacreBLEU |
|
|
396
|
-
| text: METEOR, exact and stem matches (10000 sentences) | NLTK |
|
|
397
|
-
| text: ROUGE-1, ROUGE-2, ROUGE-L (10000 sentences) | rouge-score |
|
|
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×** |
|
|
398
398
|
|
|
399
399
|
**Every metric is benchmarked too** (`evalsuite benchmark --suite metrics`): all 225 registered metrics and
|
|
400
400
|
statistics functions at 10,000 and 100,000 samples. 86 are compared with a reference library, 118 with an
|
|
401
401
|
independent textbook formula and 21 (learned, judge-dependent or randomised) are timed alone; **all 204
|
|
402
|
-
comparisons agree**, and against the libraries the geometric-mean speed-up is **6.
|
|
402
|
+
comparisons agree**, and against the libraries the geometric-mean speed-up is **6.44×** (172 of 172
|
|
403
403
|
measurements faster). Per-metric table in BENCHMARKS.md.
|
|
404
404
|
|
|
405
|
-
**
|
|
406
|
-
CodeBLEU's n-gram terms, distinct-n), the whole COCO evaluation (IoU, score sort, matching, accumulation)
|
|
407
|
-
|
|
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
|
|
408
410
|
`compare()` evaluate confusion-matrix metrics from counts of each resample's (true, predicted) pairs instead of
|
|
409
411
|
copies of the data. `evaluate()` validates inputs once and builds the confusion
|
|
410
412
|
matrix once for all metrics, and integer labels are encoded without sorting. The rank tests rank the data once
|
|
@@ -10,11 +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.
|
|
13
|
+
> **Status: stable (0.7.0).** Every item on the 0.1.0–0.5.0 roadmaps is implemented and verified, including SPICE.
|
|
14
14
|
> **0.6 adds a compiled Rust core**: same API and identical results, with text metrics, COCO evaluation and
|
|
15
15
|
> bootstrap resampling several times faster and multithreaded (prebuilt wheels for Linux, macOS and Windows).
|
|
16
|
-
> 0.
|
|
17
|
-
>
|
|
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.
|
|
18
18
|
> **LLM systems arrive in 0.5.0**: safety, robustness, calibration and uncertainty, agents and tool use,
|
|
19
19
|
> multilingual, code generation, long context and summarization, and inference efficiency and cost.
|
|
20
20
|
|
|
@@ -283,53 +283,55 @@ Input files can be CSV, TSV, Parquet or JSON. Output format follows `--format` o
|
|
|
283
283
|
|
|
284
284
|
## Performance
|
|
285
285
|
|
|
286
|
-
Benchmarked against reference implementations on the same data (fastest of 5 runs; EvalSuite 0.
|
|
286
|
+
Benchmarked against reference implementations on the same data (fastest of 5 runs; EvalSuite 0.7.0, Python 3.13,
|
|
287
287
|
NumPy 2.5, Linux x86_64). **Overall: 81 of 81 rows agree with the reference** (largest
|
|
288
|
-
difference 2.5e-14),
|
|
289
|
-
|
|
290
|
-
27 cases and three sizes is **4.
|
|
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
|
|
291
291
|
segmentation; 1,000 images for detection and 50 for Hausdorff; 10,000 examples for the LLM cases), in
|
|
292
292
|
alphabetical order:
|
|
293
293
|
|
|
294
294
|
| Case | Reference | EvalSuite (ms) | Reference (ms) | Speed-up |
|
|
295
295
|
| --- | --- | ---: | ---: | ---: |
|
|
296
|
-
| 10 classes: macro F1 | scikit-learn |
|
|
297
|
-
| agreement: Krippendorff's alpha, interval (4 raters × 10000 items) | krippendorff | 1.
|
|
298
|
-
| binary: 8 label metrics via evaluate() | scikit-learn | 9.
|
|
299
|
-
| binary: ROC AUC | scikit-learn |
|
|
300
|
-
| calibration: slope and intercept | statsmodels |
|
|
301
|
-
| clinical: diagnostic report (7 CIs) | statsmodels | 4.
|
|
302
|
-
| clinical: sensitivity, specificity, LR+, LR− | scikit-learn | 17.
|
|
303
|
-
| decision curve: 99 thresholds | NumPy loop |
|
|
304
|
-
| detection: COCO evaluation (1000 images) | pycocotools |
|
|
305
|
-
| multiple testing: Hochberg (n p-values) | statsmodels |
|
|
306
|
-
| regression: MAE, MSE, RMSE, R² via evaluate() | scikit-learn |
|
|
307
|
-
| retrieval: MRR, MAP@20, NDCG@10 (10000 queries) | ranx |
|
|
308
|
-
| segmentation: Dice and IoU per class (n = pixels) | scikit-learn |
|
|
309
|
-
| segmentation: Hausdorff distance (50 images) | SciPy | 7
|
|
310
|
-
| statistics: Cramér's V (5×5 table) | SciPy | 0.0 | 0.2 | **12.
|
|
311
|
-
| statistics: Mann–Whitney U | SciPy |
|
|
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×** |
|
|
310
|
+
| statistics: Cramér's V (5×5 table) | SciPy | 0.0 | 0.2 | **12.0×** |
|
|
311
|
+
| statistics: Mann–Whitney U | SciPy | 115.1 | 305.0 | **2.6×** |
|
|
312
312
|
| statistics: Welch t-test | SciPy | 4.9 | 7.2 | **1.5×** |
|
|
313
|
-
| structured: JSON Schema compliance (10000 documents) | jsonschema |
|
|
314
|
-
| systems: CodeBLEU n-gram terms (1000 programs) | codebleu |
|
|
315
|
-
| systems: confidence AUROC (n answers) | scikit-learn |
|
|
316
|
-
| systems: distribution-shift drop, Welch CI (n scores) | SciPy |
|
|
317
|
-
| systems: invalid tool calls vs JSON Schema (10000 tasks) | jsonschema | 109.
|
|
318
|
-
| systems: latency p50 / p95 / p99 (n requests) | NumPy |
|
|
319
|
-
| systems: maintainability index (1000 programs) | radon |
|
|
320
|
-
| text: corpus BLEU and chrF (10000 sentences) | sacreBLEU |
|
|
321
|
-
| text: METEOR, exact and stem matches (10000 sentences) | NLTK |
|
|
322
|
-
| text: ROUGE-1, ROUGE-2, ROUGE-L (10000 sentences) | rouge-score |
|
|
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×** |
|
|
323
323
|
|
|
324
324
|
**Every metric is benchmarked too** (`evalsuite benchmark --suite metrics`): all 225 registered metrics and
|
|
325
325
|
statistics functions at 10,000 and 100,000 samples. 86 are compared with a reference library, 118 with an
|
|
326
326
|
independent textbook formula and 21 (learned, judge-dependent or randomised) are timed alone; **all 204
|
|
327
|
-
comparisons agree**, and against the libraries the geometric-mean speed-up is **6.
|
|
327
|
+
comparisons agree**, and against the libraries the geometric-mean speed-up is **6.44×** (172 of 172
|
|
328
328
|
measurements faster). Per-metric table in BENCHMARKS.md.
|
|
329
329
|
|
|
330
|
-
**
|
|
331
|
-
CodeBLEU's n-gram terms, distinct-n), the whole COCO evaluation (IoU, score sort, matching, accumulation)
|
|
332
|
-
|
|
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
|
|
333
335
|
`compare()` evaluate confusion-matrix metrics from counts of each resample's (true, predicted) pairs instead of
|
|
334
336
|
copies of the data. `evaluate()` validates inputs once and builds the confusion
|
|
335
337
|
matrix once for all metrics, and integer labels are encoded without sorting. The rank tests rank the data once
|
|
@@ -35,14 +35,14 @@ checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be"
|
|
|
35
35
|
|
|
36
36
|
[[package]]
|
|
37
37
|
name = "evalsuite-core"
|
|
38
|
-
version = "0.
|
|
38
|
+
version = "0.7.0"
|
|
39
39
|
dependencies = [
|
|
40
40
|
"rayon",
|
|
41
41
|
]
|
|
42
42
|
|
|
43
43
|
[[package]]
|
|
44
44
|
name = "evalsuite-py"
|
|
45
|
-
version = "0.
|
|
45
|
+
version = "0.7.0"
|
|
46
46
|
dependencies = [
|
|
47
47
|
"evalsuite-core",
|
|
48
48
|
"pyo3",
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
//! ROC AUC and average precision from one stable descending sort, bit for bit as EvalSuite's NumPy reference
|
|
2
|
+
//! (`_binary_curve`, `_binary_auc`, `_binary_ap` in `classification/metrics.py`).
|
|
3
|
+
|
|
4
|
+
/// NumPy's float64 `add.reduce` over a contiguous 1-D array: `pairwise_sum_DOUBLE` (8 accumulators per block
|
|
5
|
+
/// of up to 128, halves split on multiples of 8), added to the zero identity.
|
|
6
|
+
pub fn np_sum(a: &[f64]) -> f64 {
|
|
7
|
+
0.0 + pairwise(a)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
fn pairwise(a: &[f64]) -> f64 {
|
|
11
|
+
let n = a.len();
|
|
12
|
+
if n < 8 {
|
|
13
|
+
let mut res = -0.0f64;
|
|
14
|
+
for &x in a {
|
|
15
|
+
res += x;
|
|
16
|
+
}
|
|
17
|
+
res
|
|
18
|
+
} else if n <= 128 {
|
|
19
|
+
let mut r = [0.0f64; 8];
|
|
20
|
+
r.copy_from_slice(&a[..8]);
|
|
21
|
+
let mut i = 8;
|
|
22
|
+
while i < n - (n % 8) {
|
|
23
|
+
for j in 0..8 {
|
|
24
|
+
r[j] += a[i + j];
|
|
25
|
+
}
|
|
26
|
+
i += 8;
|
|
27
|
+
}
|
|
28
|
+
let mut res = ((r[0] + r[1]) + (r[2] + r[3])) + ((r[4] + r[5]) + (r[6] + r[7]));
|
|
29
|
+
while i < n {
|
|
30
|
+
res += a[i];
|
|
31
|
+
i += 1;
|
|
32
|
+
}
|
|
33
|
+
res
|
|
34
|
+
} else {
|
|
35
|
+
let mut n2 = n / 2;
|
|
36
|
+
n2 -= n2 % 8;
|
|
37
|
+
pairwise(&a[..n2]) + pairwise(&a[n2..])
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/// Summary of one binary curve: (ROC AUC, average precision, total positive weight, total negative weight).
|
|
42
|
+
/// AUC is NaN when either total is zero and AP when there is no positive weight (the caller raises).
|
|
43
|
+
pub fn curve_scores(y: &[f64], score: &[f64], w: &[f64]) -> (f64, f64, f64, f64) {
|
|
44
|
+
let n = score.len();
|
|
45
|
+
if n == 0 {
|
|
46
|
+
return (f64::NAN, f64::NAN, 0.0, 0.0);
|
|
47
|
+
}
|
|
48
|
+
// np.argsort(-score, kind="mergesort"): stable, descending; -0.0 and 0.0 compare equal.
|
|
49
|
+
let mut order: Vec<usize> = (0..n).collect();
|
|
50
|
+
order.sort_by(|&a, &b| {
|
|
51
|
+
(-score[a])
|
|
52
|
+
.partial_cmp(&-score[b])
|
|
53
|
+
.unwrap_or(std::cmp::Ordering::Equal)
|
|
54
|
+
});
|
|
55
|
+
let mut tps = Vec::new();
|
|
56
|
+
let mut fps = Vec::new();
|
|
57
|
+
let (mut tp, mut fp) = (0.0f64, 0.0f64);
|
|
58
|
+
for (pos, &i) in order.iter().enumerate() {
|
|
59
|
+
// y * w and (1 - y) * w, accumulated sequentially as np.cumsum.
|
|
60
|
+
tp += y[i] * w[i];
|
|
61
|
+
fp += (1.0 - y[i]) * w[i];
|
|
62
|
+
let last = pos + 1 == n;
|
|
63
|
+
if last || score[i] - score[order[pos + 1]] != 0.0 {
|
|
64
|
+
tps.push(tp);
|
|
65
|
+
fps.push(fp);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
let (tp_all, fp_all) = (*tps.last().unwrap(), *fps.last().unwrap());
|
|
69
|
+
let m = tps.len();
|
|
70
|
+
let auc = if tp_all == 0.0 || fp_all == 0.0 {
|
|
71
|
+
f64::NAN
|
|
72
|
+
} else {
|
|
73
|
+
// trapezoid(tpr, fpr) with fpr, tpr = r_[0, fps / fps[-1]], r_[0, tps / tps[-1]].
|
|
74
|
+
let mut terms = Vec::with_capacity(m);
|
|
75
|
+
let (mut x0, mut y0) = (0.0f64, 0.0f64);
|
|
76
|
+
for k in 0..m {
|
|
77
|
+
let (x1, y1) = (fps[k] / fp_all, tps[k] / tp_all);
|
|
78
|
+
terms.push((x1 - x0) * (y1 + y0) / 2.0);
|
|
79
|
+
x0 = x1;
|
|
80
|
+
y0 = y1;
|
|
81
|
+
}
|
|
82
|
+
np_sum(&terms)
|
|
83
|
+
};
|
|
84
|
+
let ap = if tp_all == 0.0 {
|
|
85
|
+
f64::NAN
|
|
86
|
+
} else {
|
|
87
|
+
// sum(diff(r_[0, rec]) * prec), rec = tps / tps[-1], prec = tps / (tps + fps).
|
|
88
|
+
let mut terms = Vec::with_capacity(m);
|
|
89
|
+
let mut r0 = 0.0f64;
|
|
90
|
+
for k in 0..m {
|
|
91
|
+
let r1 = tps[k] / tp_all;
|
|
92
|
+
terms.push((r1 - r0) * (tps[k] / (tps[k] + fps[k])));
|
|
93
|
+
r0 = r1;
|
|
94
|
+
}
|
|
95
|
+
np_sum(&terms)
|
|
96
|
+
};
|
|
97
|
+
(auc, ap, tp_all, fp_all)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
#[cfg(test)]
|
|
101
|
+
mod tests {
|
|
102
|
+
#[test]
|
|
103
|
+
fn perfect_and_reversed() {
|
|
104
|
+
let y = [1.0, 1.0, 0.0, 0.0];
|
|
105
|
+
let w = [1.0; 4];
|
|
106
|
+
let (auc, ap, tp, fp) = super::curve_scores(&y, &[0.9, 0.8, 0.2, 0.1], &w);
|
|
107
|
+
assert_eq!((auc, ap, tp, fp), (1.0, 1.0, 2.0, 2.0));
|
|
108
|
+
let (auc, _, _, _) = super::curve_scores(&y, &[0.1, 0.2, 0.8, 0.9], &w);
|
|
109
|
+
assert_eq!(auc, 0.0);
|
|
110
|
+
let (auc, _, _, _) = super::curve_scores(&y, &[0.5; 4], &w);
|
|
111
|
+
assert_eq!(auc, 0.5);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
#[test]
|
|
115
|
+
fn sum_small() {
|
|
116
|
+
assert_eq!(super::np_sum(&[1.0, 2.0, 3.0]), 6.0);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
//! Per-item agreement among a group of answers (encoded as integer ids) and per-row rank counts, for the
|
|
2
|
+
//! LLM-systems consistency metrics (paraphrase, cross-document, cross-lingual consistency, response stability,
|
|
3
|
+
//! majority vote) and memorisation exposure.
|
|
4
|
+
|
|
5
|
+
use crate::hash::FxMap;
|
|
6
|
+
|
|
7
|
+
/// Agreement within one group of answer ids.
|
|
8
|
+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
9
|
+
pub struct GroupStats {
|
|
10
|
+
/// Every answer equals the first.
|
|
11
|
+
pub unanimous: bool,
|
|
12
|
+
/// Equal unordered pairs, Σ c·(c−1)/2 over the answer counts c.
|
|
13
|
+
pub equal_pairs: u64,
|
|
14
|
+
/// All unordered pairs, m·(m−1)/2.
|
|
15
|
+
pub pairs: u64,
|
|
16
|
+
/// Count of the most common answer.
|
|
17
|
+
pub modal_count: u64,
|
|
18
|
+
/// The most common answer, the first seen among ties (as `Counter.most_common(1)`).
|
|
19
|
+
pub mode: u32,
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
pub fn group_stats(ids: &[u32]) -> GroupStats {
|
|
23
|
+
let m = ids.len() as u64;
|
|
24
|
+
let mut counts: FxMap<u32, u64> = FxMap::default();
|
|
25
|
+
let mut first_seen: Vec<u32> = Vec::new();
|
|
26
|
+
for &x in ids {
|
|
27
|
+
let c = counts.entry(x).or_insert(0);
|
|
28
|
+
if *c == 0 {
|
|
29
|
+
first_seen.push(x);
|
|
30
|
+
}
|
|
31
|
+
*c += 1;
|
|
32
|
+
}
|
|
33
|
+
let mut mode = ids.first().copied().unwrap_or(0);
|
|
34
|
+
let mut modal_count = 0;
|
|
35
|
+
let mut equal_pairs = 0;
|
|
36
|
+
for &x in &first_seen {
|
|
37
|
+
let c = counts[&x];
|
|
38
|
+
equal_pairs += c * (c - 1) / 2;
|
|
39
|
+
if c > modal_count {
|
|
40
|
+
modal_count = c;
|
|
41
|
+
mode = x;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
GroupStats {
|
|
45
|
+
unanimous: first_seen.len() <= 1,
|
|
46
|
+
equal_pairs,
|
|
47
|
+
pairs: m * m.saturating_sub(1) / 2,
|
|
48
|
+
modal_count,
|
|
49
|
+
mode,
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/// For each row, how many of its values are strictly below its threshold. `None` if a value or threshold is
|
|
54
|
+
/// NaN or infinite.
|
|
55
|
+
pub fn count_below(rows: &[Vec<f64>], thresholds: &[f64]) -> Option<Vec<u64>> {
|
|
56
|
+
if rows
|
|
57
|
+
.iter()
|
|
58
|
+
.flatten()
|
|
59
|
+
.chain(thresholds)
|
|
60
|
+
.any(|v| !v.is_finite())
|
|
61
|
+
{
|
|
62
|
+
return None;
|
|
63
|
+
}
|
|
64
|
+
Some(
|
|
65
|
+
rows.iter()
|
|
66
|
+
.zip(thresholds)
|
|
67
|
+
.map(|(r, &t)| r.iter().filter(|&&v| v < t).count() as u64)
|
|
68
|
+
.collect(),
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/// (NumPy `sum`, min, max, number of values > 0) of one row. An empty row gives (0, +inf, -inf, 0).
|
|
73
|
+
pub fn row_stats(row: &[f64]) -> (f64, f64, f64, u64) {
|
|
74
|
+
let (mut lo, mut hi, mut pos) = (f64::INFINITY, f64::NEG_INFINITY, 0u64);
|
|
75
|
+
for &v in row {
|
|
76
|
+
lo = lo.min(v);
|
|
77
|
+
hi = hi.max(v);
|
|
78
|
+
pos += u64::from(v > 0.0);
|
|
79
|
+
}
|
|
80
|
+
(crate::curve::np_sum(row), lo, hi, pos)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
#[cfg(test)]
|
|
84
|
+
mod tests {
|
|
85
|
+
use super::*;
|
|
86
|
+
|
|
87
|
+
#[test]
|
|
88
|
+
fn stats() {
|
|
89
|
+
let s = group_stats(&[3, 1, 1, 3, 2]);
|
|
90
|
+
assert_eq!(
|
|
91
|
+
(s.unanimous, s.equal_pairs, s.pairs, s.modal_count, s.mode),
|
|
92
|
+
(false, 2, 10, 2, 3)
|
|
93
|
+
);
|
|
94
|
+
assert!(group_stats(&[4, 4]).unanimous);
|
|
95
|
+
assert_eq!(
|
|
96
|
+
count_below(&[vec![1.0, 2.0, 3.0], vec![0.5]], &[2.5, 1.0]),
|
|
97
|
+
Some(vec![2, 1])
|
|
98
|
+
);
|
|
99
|
+
assert_eq!(row_stats(&[0.5, -1.0, 2.0]), (1.5, -1.0, 2.0, 2));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -5,7 +5,10 @@
|
|
|
5
5
|
//! the same operations in the same order. Words are passed as integer ids (the caller maps each distinct token
|
|
6
6
|
//! to an id), characters as Unicode code points.
|
|
7
7
|
|
|
8
|
+
pub mod agreement;
|
|
8
9
|
pub mod coco;
|
|
10
|
+
pub mod curve;
|
|
11
|
+
pub mod groups;
|
|
9
12
|
pub mod hash;
|
|
10
13
|
pub mod meteor;
|
|
11
14
|
pub mod resample;
|