evalsuite-python 0.6.0__py3-none-any.whl → 0.6.1__py3-none-any.whl

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/_native.py CHANGED
@@ -8,6 +8,7 @@ or when ``EVALSUITE_PURE_PYTHON=1`` is set. Both give identical results.
8
8
  from __future__ import annotations
9
9
 
10
10
  import os
11
+ import sys
11
12
  from typing import Any, Optional
12
13
 
13
14
  core: Optional[Any]
@@ -21,6 +22,10 @@ else:
21
22
 
22
23
  HAVE_NATIVE = core is not None
23
24
 
25
+ # Python >= 3.12 sums floats with compensated (Neumaier) summation in the built-in sum(); kernels that port code
26
+ # using sum() over floats take this flag so their results match the running interpreter bit for bit.
27
+ PY_SUM_COMPENSATED = sys.version_info >= (3, 12)
28
+
24
29
 
25
30
  def backend() -> str:
26
31
  """``"rust"`` when the compiled core is in use, ``"python"`` otherwise."""
evalsuite/llmsys/code.py CHANGED
@@ -19,6 +19,7 @@ from typing import Any, Callable, Optional
19
19
 
20
20
  import numpy as np
21
21
 
22
+ from .._native import PY_SUM_COMPENSATED, Vocab, core
22
23
  from ..core.exceptions import InputValidationError
23
24
  from ..core.registry import register
24
25
  from ..core.result import MetricResult
@@ -671,6 +672,15 @@ def _corpus_bleu(refs: list[list[list[str]]], hyps: list[list[str]], weighted: O
671
672
  num: dict[int, float] = {n: 0.0 for n in range(1, 5)}
672
673
  den: dict[int, float] = {n: 0.0 for n in range(1, 5)}
673
674
  hyp_len = ref_len = 0
675
+ if core is not None:
676
+ v = Vocab()
677
+ h_ids = [v.encode(h) for h in hyps]
678
+ r_ids = [[v.encode(r) for r in rs] for rs in refs]
679
+ kw = None if weighted is None else [t in weighted for t in v.ids]
680
+ nums, dens, hyp_len, ref_len = core.codebleu_stats(h_ids, r_ids, kw, PY_SUM_COMPENSATED)
681
+ num = {n: nums[n - 1] for n in range(1, 5)}
682
+ den = {n: dens[n - 1] for n in range(1, 5)}
683
+ refs, hyps = [], [] # already counted
674
684
  for rs, h in zip(refs, hyps):
675
685
  for n in range(1, 5):
676
686
  hc = _ngrams(h, n)
@@ -17,7 +17,7 @@ from ..core.result import _json_safe, _latex_escape, _latex_table
17
17
  from ..core.types import ArrayLike
18
18
  from ._resolve import MetricCall, as_items, as_observations, is_categorical, resolve_metric
19
19
  from .effect import adjust_pvalues
20
- from .intervals import _check_level, _check_resamples, bootstrap_distribution, resample_indices
20
+ from .intervals import _check_level, _check_resamples, bootstrap_distribution, check_resampling, resample_indices
21
21
  from .paired import delong_test, mcnemar_test
22
22
 
23
23
  if TYPE_CHECKING:
@@ -271,6 +271,7 @@ def compare(
271
271
  stratify: Optional[bool] = None,
272
272
  sample_weight: Optional[ArrayLike] = None,
273
273
  metric_kwargs: Optional[Mapping[str, Mapping[str, Any]]] = None,
274
+ resampling: str = "numpy",
274
275
  ) -> ComparisonResult:
275
276
  """Compare models evaluated on the same test set.
276
277
 
@@ -285,9 +286,11 @@ def compare(
285
286
  Pairs are every model against ``baseline`` if given, otherwise all pairs. p-values are adjusted within
286
287
  each metric (``correction``: "holm", "bonferroni", "hochberg", "bh", "by"); ``significant`` uses the adjusted
287
288
  p-value and ``alpha``. ``metric_kwargs`` passes options per metric, e.g. ``{"f1": {"average": "macro"}}``.
289
+ ``resampling="native"`` (opt-in) draws the bootstrap indices in the compiled core; see :func:`bootstrap_ci`.
288
290
  """
289
291
  level = _check_level(level)
290
292
  n_resamples = _check_resamples(n_resamples)
293
+ resampling = check_resampling(resampling)
291
294
  predictions = dict(predictions or {})
292
295
  probabilities = dict(probabilities or {})
293
296
  names = list(dict.fromkeys([*predictions, *probabilities]))
@@ -343,7 +346,7 @@ def compare(
343
346
 
344
347
  rng = np.random.default_rng(random_state)
345
348
  use_strata = categorical if stratify is None else bool(stratify)
346
- idx = resample_indices(yt.shape[0], n_resamples, rng, yt if use_strata else None)
349
+ idx = resample_indices(yt.shape[0], n_resamples, rng, yt if use_strata else None, resampling)
347
350
  a = (1 - level) / 2
348
351
  boot: dict[tuple[str, str], np.ndarray] = {}
349
352
  estimates: list[dict[str, Any]] = []
@@ -17,6 +17,7 @@ else:
17
17
  special = lazy_module("scipy.special")
18
18
  stats = lazy_module("scipy.stats")
19
19
 
20
+ from .._native import array_view, core
20
21
  from ..core.exceptions import EvalSuiteError, InputValidationError, StatisticalTestError
21
22
  from ..core.types import ArrayLike
22
23
  from ..core.validation import to_numpy
@@ -41,16 +42,57 @@ def _check_resamples(n_resamples: int) -> int:
41
42
  return int(n_resamples)
42
43
 
43
44
 
45
+ RESAMPLING = ("numpy", "native")
46
+
47
+
48
+ def check_resampling(resampling: str) -> str:
49
+ if resampling not in RESAMPLING:
50
+ raise InputValidationError("resampling must be 'numpy' or 'native'.")
51
+ if resampling == "native" and core is None:
52
+ raise InputValidationError(
53
+ "resampling='native' needs the compiled core, which is not available (pure-Python install or "
54
+ "EVALSUITE_PURE_PYTHON=1)."
55
+ )
56
+ return resampling
57
+
58
+
59
+ def _strata_groups(n: int, strata: NDArray[Any]) -> list[NDArray[np.intp]]:
60
+ values = np.unique(strata, axis=0) if strata.ndim > 1 else np.unique(strata)
61
+ return [
62
+ np.flatnonzero(np.all(strata == value, axis=1) if strata.ndim > 1 else strata == value) for value in values
63
+ ]
64
+
65
+
44
66
  def resample_indices(
45
- n: int, n_resamples: int, rng: np.random.Generator, strata: Optional[NDArray[Any]] = None
67
+ n: int,
68
+ n_resamples: int,
69
+ rng: np.random.Generator,
70
+ strata: Optional[NDArray[Any]] = None,
71
+ resampling: str = "numpy",
46
72
  ) -> NDArray[np.int64]:
47
- """(n_resamples, n) indices drawn with replacement, optionally within strata (keeps class balance)."""
73
+ """(n_resamples, n) indices drawn with replacement, optionally within strata (keeps class balance).
74
+
75
+ ``resampling="native"`` draws them in the compiled core (xoshiro256++, in parallel) from one seed taken from
76
+ ``rng``: reproducible for a given ``random_state`` and thread count–independent, but a different stream from
77
+ NumPy's, so intervals differ (statistically equivalently) from the default."""
78
+ if resampling == "native":
79
+ c = core
80
+ if c is None: # pragma: no cover - checked by check_resampling
81
+ raise InputValidationError("resampling='native' needs the compiled core.")
82
+ seed = int(rng.integers(0, 2**63))
83
+ groups = None
84
+ if strata is not None:
85
+ parts = _strata_groups(n, strata)
86
+ members, view = array_view(np.concatenate(parts), np.int64)
87
+ groups = (view, [0, *np.cumsum([p.shape[0] for p in parts]).tolist()])
88
+ out = np.empty((n_resamples, n), dtype=np.int64)
89
+ c.bootstrap_indices((int(out.ctypes.data), int(out.size)), n, seed, groups)
90
+ return out
48
91
  if strata is None:
49
92
  return rng.integers(0, n, size=(n_resamples, n))
50
93
  out = np.empty((n_resamples, n), dtype=np.int64)
51
94
  pos = 0
52
- for value in np.unique(strata, axis=0) if strata.ndim > 1 else np.unique(strata):
53
- members = np.flatnonzero(np.all(strata == value, axis=1) if strata.ndim > 1 else strata == value)
95
+ for members in _strata_groups(n, strata):
54
96
  k = members.shape[0]
55
97
  out[:, pos : pos + k] = members[rng.integers(0, k, size=(n_resamples, k))]
56
98
  pos += k
@@ -110,25 +152,29 @@ def bootstrap_ci(
110
152
  random_state: Optional[int] = None,
111
153
  stratify: Optional[bool] = None,
112
154
  jackknife_groups: int = 1000,
155
+ resampling: str = "numpy",
113
156
  **metric_kwargs: Any,
114
157
  ) -> ConfidenceInterval:
115
158
  """Bootstrap confidence interval for any metric.
116
159
 
117
- ``metric`` is a metric function (``es.f1``) or its name (``"f1"``). Pass ``y_pred`` for label/value
118
- metrics or ``y_prob`` for probability metrics; extra keyword arguments go to the metric (for example
119
- ``average="macro"``). Resampling is stratified by class for classification targets unless
120
- ``stratify=False``, so every resample contains every class. For classification metrics that accept
121
- ``labels``, the full label set is fixed across resamples.
160
+ ``metric`` is a metric function (``es.f1``) or its name (``"f1"``). Pass ``y_pred`` for label/value
161
+ metrics or ``y_prob`` for probability metrics; extra keyword arguments go to the metric (for example
162
+ ``average="macro"``). Resampling is stratified by class for classification targets unless
163
+ ``stratify=False``, so every resample contains every class. For classification metrics that accept
164
+ ``labels``, the full label set is fixed across resamples.
122
165
 
123
- ``method``: ``"bca"`` (bias-corrected and accelerated; default, Efron 1987), ``"percentile"`` or
124
- ``"basic"``. Set ``random_state`` for reproducible intervals. Resamples on which the metric is undefined
125
- are counted in ``params["failed_resamples"]``; more than 10% raises :class:`StatisticalTestError`.
166
+ ``method``: ``"bca"`` (bias-corrected and accelerated; default, Efron 1987), ``"percentile"`` or
167
+ ``"basic"``. Set ``random_state`` for reproducible intervals. Resamples on which the metric is undefined
168
+ are counted in ``params["failed_resamples"]``; more than 10% raises :class:`StatisticalTestError`.
169
+ ``resampling="native"`` (opt-in) draws the resample indices in the compiled core instead of NumPy: faster on
170
+ large inputs and still reproducible with ``random_state``, but a different random stream from the default.
126
171
 
127
- References: Efron B. Better bootstrap confidence intervals. JASA. 1987;82(397):171-185.
128
- Efron B, Tibshirani RJ. An Introduction to the Bootstrap. Chapman & Hall; 1993.
172
+ References: Efron B. Better bootstrap confidence intervals. JASA. 1987;82(397):171-185.
173
+ Efron B, Tibshirani RJ. An Introduction to the Bootstrap. Chapman & Hall; 1993.
129
174
  """
130
175
  level = _check_level(level)
131
176
  n_resamples = _check_resamples(n_resamples)
177
+ resampling = check_resampling(resampling)
132
178
  if method not in ("percentile", "basic", "bca"):
133
179
  raise InputValidationError("method must be 'bca', 'percentile' or 'basic'.")
134
180
  fn, name = resolve_metric(metric)
@@ -136,7 +182,7 @@ def bootstrap_ci(
136
182
  estimate = call()
137
183
  rng = np.random.default_rng(random_state)
138
184
  use_strata = call.categorical if stratify is None else bool(stratify)
139
- idx = resample_indices(call.n, n_resamples, rng, call.y_true if use_strata else None)
185
+ idx = resample_indices(call.n, n_resamples, rng, call.y_true if use_strata else None, resampling)
140
186
  boot, failed = bootstrap_distribution(call, idx)
141
187
  if failed > MAX_FAILED_FRACTION * n_resamples:
142
188
  raise StatisticalTestError(
@@ -150,6 +196,7 @@ def bootstrap_ci(
150
196
  "random_state": random_state,
151
197
  "stratified": use_strata,
152
198
  "failed_resamples": failed,
199
+ "resampling": resampling,
153
200
  **{k: v for k, v in metric_kwargs.items()},
154
201
  }
155
202
  if method == "percentile":
evalsuite/stats/paired.py CHANGED
@@ -23,6 +23,7 @@ from .intervals import (
23
23
  _check_resamples,
24
24
  binary_scores,
25
25
  bootstrap_distribution,
26
+ check_resampling,
26
27
  delong_covariance,
27
28
  delong_placements,
28
29
  resample_indices,
@@ -138,6 +139,7 @@ def paired_bootstrap_test(
138
139
  random_state: Optional[int] = None,
139
140
  stratify: Optional[bool] = None,
140
141
  alternative: Literal["two-sided", "greater", "less"] = "two-sided",
142
+ resampling: str = "numpy",
141
143
  **metric_kwargs: Any,
142
144
  ) -> TestResult:
143
145
  """Paired bootstrap test for any metric: is metric(A) − metric(B) different from 0?
@@ -146,10 +148,13 @@ def paired_bootstrap_test(
146
148
  distribution (difference re-centred on 0 under the null), with the +1 correction so it is never 0:
147
149
  p = (1 + #{|δ* − δ̂| ≥ |δ̂|}) / (B + 1) for a two-sided test. ``ci`` is the percentile interval of δ*.
148
150
 
151
+ ``resampling="native"`` (opt-in) draws the resample indices in the compiled core; see :func:`bootstrap_ci`.
152
+
149
153
  Reference: Efron B, Tibshirani RJ. An Introduction to the Bootstrap. Chapman & Hall; 1993, ch. 16.
150
154
  """
151
155
  level = _check_level(level)
152
156
  n_resamples = _check_resamples(n_resamples)
157
+ resampling = check_resampling(resampling)
153
158
  if alternative not in ("two-sided", "greater", "less"):
154
159
  raise InputValidationError("alternative must be 'two-sided', 'greater' or 'less'.")
155
160
  fn, name = resolve_metric(metric)
@@ -170,7 +175,7 @@ def paired_bootstrap_test(
170
175
  observed = call_a() - call_b()
171
176
  rng = np.random.default_rng(random_state)
172
177
  use_strata = call_a.categorical if stratify is None else bool(stratify)
173
- idx = resample_indices(call_a.n, n_resamples, rng, call_a.y_true if use_strata else None)
178
+ idx = resample_indices(call_a.n, n_resamples, rng, call_a.y_true if use_strata else None, resampling)
174
179
  da, fa = bootstrap_distribution(call_a, idx)
175
180
  db, fb = bootstrap_distribution(call_b, idx)
176
181
  diff = da - db
@@ -17,7 +17,7 @@ from typing import Any, Callable, Literal, Optional
17
17
 
18
18
  import numpy as np
19
19
 
20
- from .._native import Vocab, core
20
+ from .._native import PY_SUM_COMPENSATED, Vocab, core
21
21
  from ..core.exceptions import InputValidationError
22
22
  from ..core.registry import register
23
23
  from ..core.result import MetricResult
@@ -968,13 +968,17 @@ def distinct_n(predictions: Any, *, n: int = 1, lowercase: bool = False) -> Metr
968
968
  """Distinct-n over the whole set of predictions (``n=1`` Distinct-1, ``n=2`` Distinct-2)."""
969
969
  preds = as_texts(predictions, "predictions")
970
970
  n = check_positive_int(n, "n")
971
- counts: Counter[tuple[str, ...]] = Counter()
972
- for p in preds:
973
- counts.update(word_ngrams((p.lower() if lowercase else p).split(), n))
974
- total = sum(counts.values())
971
+ if core is not None:
972
+ v = Vocab()
973
+ unique, total = core.distinct_ngrams([v.encode((p.lower() if lowercase else p).split()) for p in preds], n)
974
+ else:
975
+ counts: Counter[tuple[str, ...]] = Counter()
976
+ for p in preds:
977
+ counts.update(word_ngrams((p.lower() if lowercase else p).split(), n))
978
+ unique, total = len(counts), sum(counts.values())
975
979
  if total == 0:
976
980
  raise InputValidationError(f"The predictions contain no {n}-grams.")
977
- return MetricResult("distinct_n", f"Distinct-{n}", len(counts) / total, {"n": n, "total_ngrams": total})
981
+ return MetricResult("distinct_n", f"Distinct-{n}", unique / total, {"n": n, "total_ngrams": total})
978
982
 
979
983
 
980
984
  @register(
@@ -1308,6 +1312,18 @@ def cider(
1308
1312
  def words(s: str) -> list[str]:
1309
1313
  return tok(s.lower() if lowercase else s)
1310
1314
 
1315
+ if core is not None:
1316
+ v = Vocab()
1317
+ totals = core.cider_totals(
1318
+ [v.encode(words(p)) for p in preds],
1319
+ [[v.encode(words(r)) for r in rs] for rs in refs],
1320
+ n,
1321
+ float(sigma),
1322
+ PY_SUM_COMPENSATED,
1323
+ )
1324
+ arr = np.array([float(np.mean(np.array(t))) / len(rs) * 10.0 for t, rs in zip(totals, refs)])
1325
+ value_n: Any = arr if average is None else float(arr.mean())
1326
+ return MetricResult("cider", "CIDEr-D", value_n, {"max_order": n, "sigma": sigma})
1311
1327
  ctest = [_cider_counts(words(p), n) for p in preds]
1312
1328
  crefs = [[_cider_counts(words(r), n) for r in rs] for rs in refs]
1313
1329
  df: Counter[tuple[str, ...]] = Counter()
evalsuite/version.py CHANGED
@@ -1,3 +1,3 @@
1
1
  """Package version (single source of truth, read by the build backend)."""
2
2
 
3
- __version__ = "0.6.0"
3
+ __version__ = "0.6.1"
@@ -310,6 +310,8 @@ def _coco_eval(
310
310
  areas: Sequence[str],
311
311
  ) -> tuple[list[int], NDArray[np.float64], NDArray[np.float64]]:
312
312
  """precision (T, R, K, A, M) and recall (T, K, A, M); -1 where undefined (no ground truth)."""
313
+ if core is not None:
314
+ return _coco_eval_native(images, iou_thrs, max_dets, areas)
313
315
  top = max(max_dets)
314
316
  cats, pairs = _prepare(images, top)
315
317
  t_n, r_n, k_n, a_n, m_n = len(iou_thrs), _REC_THRS.size, len(cats), len(areas), len(max_dets)
@@ -348,6 +350,52 @@ def _coco_eval(
348
350
  return cats, precision, recall
349
351
 
350
352
 
353
+ def _coco_eval_native(
354
+ images: list[_Image],
355
+ iou_thrs: NDArray[np.float64],
356
+ max_dets: Sequence[int],
357
+ areas: Sequence[str],
358
+ ) -> tuple[list[int], NDArray[np.float64], NDArray[np.float64]]:
359
+ """:func:`_coco_eval` in the compiled core: preparation, matching and accumulation, parallel over classes."""
360
+ c = core
361
+ if c is None: # pragma: no cover - only called with the core
362
+ raise RuntimeError("compiled core not available")
363
+
364
+ def cat(parts: list[NDArray[Any]], dtype: Any, shape: tuple[int, ...]) -> NDArray[Any]:
365
+ return np.concatenate(parts).astype(dtype, copy=False) if parts else np.zeros(shape, dtype=dtype)
366
+
367
+ gt_off = np.cumsum([0] + [im.gt_boxes.shape[0] for im in images]).astype(np.int64)
368
+ dt_off = np.cumsum([0] + [im.dt_boxes.shape[0] for im in images]).astype(np.int64)
369
+ arrays = [
370
+ (cat([im.gt_boxes.reshape(-1, 4) for im in images], np.float64, (0, 4)), np.float64),
371
+ (cat([im.gt_labels for im in images], np.int64, (0,)), np.int64),
372
+ (cat([im.gt_crowd for im in images], np.bool_, (0,)), np.bool_),
373
+ (cat([im.gt_area for im in images], np.float64, (0,)), np.float64),
374
+ (gt_off, np.int64),
375
+ (cat([im.dt_boxes.reshape(-1, 4) for im in images], np.float64, (0, 4)), np.float64),
376
+ (cat([im.dt_labels for im in images], np.int64, (0,)), np.int64),
377
+ (cat([im.dt_scores for im in images], np.float64, (0,)), np.float64),
378
+ (dt_off, np.int64),
379
+ ]
380
+ held, views = [], []
381
+ for arr, dtype in arrays:
382
+ a, v = array_view(arr, dtype)
383
+ held.append(a)
384
+ views.append(v)
385
+ cats, raw_p, raw_r = c.coco_evaluate(
386
+ *views,
387
+ [float(t) for t in iou_thrs],
388
+ [int(m) for m in max_dets],
389
+ [_AREAS[a] for a in areas],
390
+ [float(r) for r in _REC_THRS],
391
+ )
392
+ del held
393
+ t_n, r_n, k_n, a_n, m_n = len(iou_thrs), _REC_THRS.size, len(cats), len(areas), len(max_dets)
394
+ precision = np.frombuffer(raw_p, dtype=np.float64).reshape(t_n, r_n, k_n, a_n, m_n).copy()
395
+ recall = np.frombuffer(raw_r, dtype=np.float64).reshape(t_n, k_n, a_n, m_n).copy()
396
+ return [int(k) for k in cats], precision, recall
397
+
398
+
351
399
  def _mean_valid(x: NDArray[np.float64]) -> float:
352
400
  v = x[x > -1]
353
401
  return float(np.mean(v)) if v.size else math.nan
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: evalsuite-python
3
- Version: 0.6.0
3
+ Version: 0.6.1
4
4
  Summary: A unified Python framework for machine-learning, clinical, statistical, segmentation, object-detection, uncertainty, and model evaluation.
5
5
  Project-URL: Homepage, https://evalsuite-nine.vercel.app
6
6
  Project-URL: Documentation, https://evalsuite-nine.vercel.app/docs
@@ -85,9 +85,11 @@ Description-Content-Type: text/markdown
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.6.1).** 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.6.1 moves the whole COCO evaluation, CIDEr, CodeBLEU and distinct-n into the core and adds opt-in
92
+ > `resampling="native"` bootstrap draws.
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,53 @@ 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.6.1, 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), 77 are faster (the other 4 are sub-millisecond or few-millisecond cases within timing noise,
364
+ 0.89–0.99×), and the geometric-mean speed-up across all
365
+ 27 cases and three sizes is **4.08×**. 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×** |
375
- | 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×** |
371
+ | 10 classes: macro F1 | scikit-learn | 6.9 | 102.4 | **14.7×** |
372
+ | agreement: Krippendorff's alpha, interval (4 raters × 10000 items) | krippendorff | 1.4 | 3.3 | **2.4×** |
373
+ | binary: 8 label metrics via evaluate() | scikit-learn | 9.1 | 815.4 | **90.0×** |
374
+ | binary: ROC AUC | scikit-learn | 144.4 | 253.0 | **1.8×** |
375
+ | calibration: slope and intercept | statsmodels | 163.2 | 921.9 | **5.6×** |
376
+ | clinical: diagnostic report (7 CIs) | statsmodels | 4.3 | 4.5 | **1.0×** |
377
+ | clinical: sensitivity, specificity, LR+, LR− | scikit-learn | 17.1 | 312.0 | **18.2×** |
378
+ | decision curve: 99 thresholds | NumPy loop | 129.9 | 169.5 | **1.3×** |
379
+ | detection: COCO evaluation (1000 images) | pycocotools | 27.3 | 616.0 | **22.5×** |
380
+ | multiple testing: Hochberg (n p-values) | statsmodels | 85.8 | 82.8 | 0.97× |
381
+ | regression: MAE, MSE, RMSE, R² via evaluate() | scikit-learn | 5.6 | 9.3 | **1.7×** |
382
+ | retrieval: MRR, MAP@20, NDCG@10 (10000 queries) | ranx | 122.2 | 587.7 | **4.8×** |
383
+ | segmentation: Dice and IoU per class (n = pixels) | scikit-learn | 28.9 | 204.9 | **7.1×** |
384
+ | segmentation: Hausdorff distance (50 images) | SciPy | 7.0 | 13.5 | **1.9×** |
385
+ | statistics: Cramér's V (5×5 table) | SciPy | 0.0 | 0.2 | **12.1×** |
386
+ | statistics: Mann–Whitney U | SciPy | 109.9 | 331.5 | **3.0×** |
387
+ | statistics: Welch t-test | SciPy | 4.9 | 7.2 | **1.5×** |
388
+ | structured: JSON Schema compliance (10000 documents) | jsonschema | 95.3 | 224.5 | **2.4×** |
389
+ | systems: CodeBLEU n-gram terms (1000 programs) | codebleu | 324.0 | 521.4 | **1.6×** |
390
+ | systems: confidence AUROC (n answers) | scikit-learn | 168.4 | 278.7 | **1.7×** |
391
+ | systems: distribution-shift drop, Welch CI (n scores) | SciPy | 11.5 | 12.4 | **1.1×** |
392
+ | systems: invalid tool calls vs JSON Schema (10000 tasks) | jsonschema | 109.0 | 209.2 | **1.9×** |
393
+ | systems: latency p50 / p95 / p99 (n requests) | NumPy | 14.9 | 13.3 | 0.89× |
394
+ | systems: maintainability index (1000 programs) | radon | 89.8 | 97.2 | **1.1×** |
395
+ | text: corpus BLEU and chrF (10000 sentences) | sacreBLEU | 175.8 | 1965.7 | **11.2×** |
396
+ | text: METEOR, exact and stem matches (10000 sentences) | NLTK | 61.5 | 369.6 | **6.0×** |
397
+ | text: ROUGE-1, ROUGE-2, ROUGE-L (10000 sentences) | rouge-score | 153.9 | 617.2 | **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.32×** (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
+ **Every substantial 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) and
407
+ bootstrap resampling run in the compiled, multithreaded Rust core; bootstrap intervals, paired bootstrap tests and
397
408
  `compare()` evaluate confusion-matrix metrics from counts of each resample's (true, predicted) pairs instead of
398
409
  copies of the data. `evaluate()` validates inputs once and builds the confusion
399
410
  matrix once for all metrics, and integer labels are encoded without sorting. The rank tests rank the data once
@@ -2,14 +2,14 @@ evalsuite/__init__.py,sha256=nMwLJq_Ni8plZZmq1olG5HwDlBppn0pW-RJyFBzPF7o,5630
2
2
  evalsuite/__main__.py,sha256=Nq90_8VlUN1mif-AVgX-kZRL63bd94F5-F7F9UkVZD4,117
3
3
  evalsuite/_bench_metrics.py,sha256=GLLa9OhCNmu6IyWkxC0AcNf7p-CTpoOwWUS99C1o2o8,75792
4
4
  evalsuite/_lazy.py,sha256=Ddq0uWuiyxtsT0jBtCSITQPvttiQ7znXAbjkMIOVefk,901
5
- evalsuite/_native.py,sha256=DiJNSz1oCuDd3rZSSsTQOii2jYp3sZtVePxWtRhcAik,2076
5
+ evalsuite/_native.py,sha256=haMBiKqPDmHGoGbq4Cn8iFmm1Vt-tFYYsyRQ3XLyueE,2351
6
6
  evalsuite/api.py,sha256=DzWwmCgyEiqO2HvPrNg2RIDzqwap4e_UvbxA7PkJ3fE,10227
7
7
  evalsuite/benchmarks.py,sha256=TWXIhdYPbdDPanCOFL1lRCo3ppRYaDF58PB-o3ZZyTA,37846
8
8
  evalsuite/calibration.py,sha256=jhCPOmCFGEkUkcx-hSAIb-JCMq9oF6JZt4uDGvg5NaU,15083
9
9
  evalsuite/plot.py,sha256=7eOyzoRbg6Aad6OhtIQG3laIioQ8fs2K0YzodjG5rHA,26049
10
10
  evalsuite/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
11
  evalsuite/reporting.py,sha256=-LISv9vvEnltT26GtzLjVlxOCcAwmjv4-HyB8_1UF5o,9615
12
- evalsuite/version.py,sha256=WXIiUQKq6Bg6972-sqjn2TWeu8-Z3B72WfcDxJHyJ3c,98
12
+ evalsuite/version.py,sha256=p3Fe2L1wp0T3qdA8A55WJIZNiR8w9njp8yc2Ul8I9bg,98
13
13
  evalsuite/classification/__init__.py,sha256=ErBIXbBGnhfW6v-1Cn5SegiERoyxNlmO1tEKcLM15mA,833
14
14
  evalsuite/classification/_common.py,sha256=3ANV33ix_mnOzvOAG8glyJO-iYVhhTGO0S3YG0ZddB8,4543
15
15
  evalsuite/classification/metrics.py,sha256=h-DYF2wwdN8LA1bPbyIgkfuG4ovwBBgtGZFObEmiHzE,37044
@@ -29,7 +29,7 @@ evalsuite/core/validation.py,sha256=nZRWSuShdFBDYgXMnRmspSQ4AJPRO3Zy5M8wTFfkg2E,
29
29
  evalsuite/llmsys/__init__.py,sha256=NA-kVMc3hdmBSW-ufPKrgfd2NHI15wCXJRn3ZhIVFsE,4653
30
30
  evalsuite/llmsys/_common.py,sha256=Hp9yuO8ItEqr5v1B5fU6-ZVSB3EkvHavnspiPGVmsLM,8713
31
31
  evalsuite/llmsys/agents.py,sha256=giiHv3c179fFR6aFUp4VbBjzbdNotS941tZVG7W0UFE,15355
32
- evalsuite/llmsys/code.py,sha256=6Im0Km5qPHLFTF4S4dnN05OucFFNRixRchDSGHqtJaQ,37004
32
+ evalsuite/llmsys/code.py,sha256=OIyH3aKbuzmH3131wfkj98k5QrrvPwQ1dvCCY4WXD4Y,37528
33
33
  evalsuite/llmsys/efficiency.py,sha256=GlUSWNnzRaeuebv-SZYsB28StwIPYb8AIyMwM057g_A,13895
34
34
  evalsuite/llmsys/longcontext.py,sha256=koX58FMot3ZwUTPPiv9tM8fGvBY2ijYg0npA8pG278A,15145
35
35
  evalsuite/llmsys/multilingual.py,sha256=utAlQfQ2hPgav9-3IzY1yhgwyncaTZ-zFp_0koBEBzE,14241
@@ -40,16 +40,16 @@ evalsuite/regression/__init__.py,sha256=t2XEHUw6e5tyWBHcEeiog2WWd-wwaxf4m5AIX8dJ
40
40
  evalsuite/regression/metrics.py,sha256=Qv5hFswxfzE-8wOKysERqsEJT-3kvTXPrkLoZ7s9jbQ,23487
41
41
  evalsuite/stats/__init__.py,sha256=mtnEqpvlvscQ3C6ceRr8xLKoSHPQWsWB24pEVlvp6fs,1187
42
42
  evalsuite/stats/_resolve.py,sha256=T5EUqTbiGM0oor59Nzm18GUr7oLWcpgj1l8gCU56ACc,10276
43
- evalsuite/stats/compare.py,sha256=TzBYHDbfHU1Uz2FtgXbMATTnmHuaDGUbrV9Eq4IphZY,18311
43
+ evalsuite/stats/compare.py,sha256=ooO5STzocKrqNsxKvm_C4Bl1c36_7fziCJc-d2cJASA,18531
44
44
  evalsuite/stats/effect.py,sha256=bgnhdCI4vU_Wnv5q7G2ncmtN3n7N1GWiYO4iO3FDI0w,7286
45
45
  evalsuite/stats/hypothesis.py,sha256=RCu8yPTOhtetFQ5TlZQWaFu2t-aq56ffaNlEqC-lJbg,24546
46
- evalsuite/stats/intervals.py,sha256=KyExUlrZiJiMkCRaDNUQoDY30hSrv3SNRQzR8oJucqU,14660
47
- evalsuite/stats/paired.py,sha256=PZV0XED3HnjOD675Tj6z1ILGxUaesBpxXQgC0goi6o4,8439
46
+ evalsuite/stats/intervals.py,sha256=6v7JG_lY4DWrAdcBqiwKsxvBMLgu1RKjdcXaIiqeYqc,16712
47
+ evalsuite/stats/paired.py,sha256=guPwpss0XQWRzL4hWL9xE4mgF6bUQQ2FbkNMkyhxrlc,8663
48
48
  evalsuite/stats/results.py,sha256=nqXHUiW8l0fQJkbMiunU6Gz-2be1NApZ6Fif2B1K_Yw,4407
49
49
  evalsuite/text/__init__.py,sha256=_r0Qi6X7cBcaYMAPRyC15CsTj9Tv8VcqMCtLiSJPogY,3632
50
50
  evalsuite/text/_common.py,sha256=acjAoPbXlPtd4DC4YbvOv1frIUjvFa1UtbdA5-6YDsU,3790
51
51
  evalsuite/text/factuality.py,sha256=Id8LnGjqvaVDYC5qMn4H0UJdjrwp1VrZ_zr_0jct8SM,20772
52
- evalsuite/text/generation.py,sha256=3Fm-VpzLEQMUfz59j4QVUbEBorq2-oTzLtJ4YaxzoYI,51659
52
+ evalsuite/text/generation.py,sha256=qrpOvt2T_Fom2M_6YquEEnJbMCr_KwR1kEqtUH6N0tc,52420
53
53
  evalsuite/text/judge.py,sha256=Ug5UnXBHzPkhtJ-vBxge3ZbkQxCoA4T_zcVxVU8chxQ,23566
54
54
  evalsuite/text/qa.py,sha256=rU0ya8TzV5mp7UiWq7w9IqSN9B0tDv8xymSaRzzbzMw,4097
55
55
  evalsuite/text/rag.py,sha256=GF8GUp6Vnt9peBCIcdvFUapLUL36_NDApZisYG_rcqg,9641
@@ -60,11 +60,11 @@ evalsuite/text/semantic.py,sha256=TgBBDcRll7vMzQVYStgt1SS9G7e6FTf7SuZDcPL32_g,23
60
60
  evalsuite/text/spice.py,sha256=rdPCeilqKkXLMiSAE-rYOn0Zt2nKFum5Tf1oJdE6k-U,6847
61
61
  evalsuite/text/structured.py,sha256=x08yYf2rdlmiA_D_dI1L-fc9quHiBPMKgAGQbG3kJr8,31981
62
62
  evalsuite/vision/__init__.py,sha256=9gpOBTPveM_srE6BM-SgCssdQurya2LPHhoMLGOh2A0,991
63
- evalsuite/vision/detection.py,sha256=nkTisC02xOupKNfXiJyk-oaFlYYLJZU7VXkR1fu2Ph4,29747
63
+ evalsuite/vision/detection.py,sha256=Cjr-Y5-pV0wiQk1JiHLYvDdKzMlCEvVQarzY7fqGWw4,32010
64
64
  evalsuite/vision/segmentation.py,sha256=f41Q8iOELCj8jmAJ3pN5OFr3h3-6QtjnluW8rfkg0V0,41132
65
- evalsuite_python-0.6.0.dist-info/METADATA,sha256=QDTBE4eRquf4uCJn3IivEmyQn2drPgSwIBDIzV7euL8,27606
66
- evalsuite_python-0.6.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
67
- evalsuite_python-0.6.0.dist-info/entry_points.txt,sha256=YYIwisn4L4sQt3ntzbM0_Z4yZE2KCu3GJ6KfWL1kIwc,54
68
- evalsuite_python-0.6.0.dist-info/licenses/LICENSE,sha256=cRRQ6Kk8w2qCqtDSSUJQGy-0rqjmjJG09cZ6iIiMvdc,1095
69
- evalsuite_python-0.6.0.dist-info/licenses/LICENSE-APACHE,sha256=K4pWYv3dt61u1BuIxjOGBxhgRkpsH4X_dzeIbOILXw0,10784
70
- evalsuite_python-0.6.0.dist-info/RECORD,,
65
+ evalsuite_python-0.6.1.dist-info/METADATA,sha256=Q407ezIaq42FBsXpbi8kqfbTKwUp3Yn74i5jMjn_P4Q,28579
66
+ evalsuite_python-0.6.1.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
67
+ evalsuite_python-0.6.1.dist-info/entry_points.txt,sha256=YYIwisn4L4sQt3ntzbM0_Z4yZE2KCu3GJ6KfWL1kIwc,54
68
+ evalsuite_python-0.6.1.dist-info/licenses/LICENSE,sha256=cRRQ6Kk8w2qCqtDSSUJQGy-0rqjmjJG09cZ6iIiMvdc,1095
69
+ evalsuite_python-0.6.1.dist-info/licenses/LICENSE-APACHE,sha256=K4pWYv3dt61u1BuIxjOGBxhgRkpsH4X_dzeIbOILXw0,10784
70
+ evalsuite_python-0.6.1.dist-info/RECORD,,