evalsuite-python 1.1.1__py3-none-any.whl → 1.1.2__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/__init__.py +13 -0
- evalsuite/_evalci.py +30 -12
- evalsuite/_update.py +170 -0
- evalsuite/cli/main.py +43 -0
- evalsuite/version.py +1 -1
- {evalsuite_python-1.1.1.dist-info → evalsuite_python-1.1.2.dist-info}/METADATA +150 -56
- {evalsuite_python-1.1.1.dist-info → evalsuite_python-1.1.2.dist-info}/RECORD +11 -10
- {evalsuite_python-1.1.1.dist-info → evalsuite_python-1.1.2.dist-info}/WHEEL +0 -0
- {evalsuite_python-1.1.1.dist-info → evalsuite_python-1.1.2.dist-info}/entry_points.txt +0 -0
- {evalsuite_python-1.1.1.dist-info → evalsuite_python-1.1.2.dist-info}/licenses/LICENSE +0 -0
- {evalsuite_python-1.1.1.dist-info → evalsuite_python-1.1.2.dist-info}/licenses/LICENSE-APACHE +0 -0
evalsuite/__init__.py
CHANGED
|
@@ -277,3 +277,16 @@ __all__ = [
|
|
|
277
277
|
]
|
|
278
278
|
__all__ += list(_text_all)
|
|
279
279
|
__all__ += list(_llmsys_all)
|
|
280
|
+
|
|
281
|
+
import contextlib as _contextlib # noqa: E402
|
|
282
|
+
|
|
283
|
+
from ._update import UpdateInfo, check_for_update, upgrade # noqa: E402
|
|
284
|
+
|
|
285
|
+
__all__ += ["UpdateInfo", "check_for_update", "upgrade"]
|
|
286
|
+
|
|
287
|
+
# A cached, once-a-day notice; the PyPI lookup runs in a background thread (see evalsuite._update). It must
|
|
288
|
+
# never affect importing EvalSuite.
|
|
289
|
+
with _contextlib.suppress(Exception):
|
|
290
|
+
from ._update import notify_on_import as _notify
|
|
291
|
+
|
|
292
|
+
_notify()
|
evalsuite/_evalci.py
CHANGED
|
@@ -35,7 +35,10 @@ def _mean_ci(terms: np.ndarray, level: float) -> tuple[float, float]:
|
|
|
35
35
|
if n < 2:
|
|
36
36
|
return math.nan, math.nan
|
|
37
37
|
m = float(np.mean(terms))
|
|
38
|
-
|
|
38
|
+
d = terms - m
|
|
39
|
+
# Sample standard deviation via a BLAS dot product (one pass over the deviations instead of np.std's
|
|
40
|
+
# several temporaries); same two-pass formula, so the same accuracy.
|
|
41
|
+
se = math.sqrt(float(np.dot(d, d)) / (n - 1)) / math.sqrt(n)
|
|
39
42
|
q = _t_quantile(level, n - 1)
|
|
40
43
|
return m - q * se, m + q * se
|
|
41
44
|
|
|
@@ -108,17 +111,32 @@ def _analytic(
|
|
|
108
111
|
out[name] = (max(0.0, lo), hi, "t")
|
|
109
112
|
elif result.task == "regression" and np.ndim(y_true) == 1:
|
|
110
113
|
e = np.asarray(y_pred, dtype=float) - np.asarray(y_true, dtype=float)
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
114
|
+
n = e.shape[0]
|
|
115
|
+
if n >= 2:
|
|
116
|
+
# One pass of BLAS dot products serves every error metric: Σe², Σe⁴ (and Σe) give the means and
|
|
117
|
+
# sample variances of |e|, e² and e without temporaries for |e| (|e|·|e| = e·e).
|
|
118
|
+
tq = _t_quantile(level, n - 1)
|
|
119
|
+
ee = float(np.dot(e, e))
|
|
120
|
+
sq: Optional[np.ndarray] = None
|
|
121
|
+
|
|
122
|
+
def t_ci(mean: float, sum_sq: float) -> tuple[float, float]:
|
|
123
|
+
var = max(0.0, (sum_sq - n * mean * mean) / (n - 1))
|
|
124
|
+
half = tq * math.sqrt(var / n)
|
|
125
|
+
return mean - half, mean + half
|
|
126
|
+
|
|
127
|
+
for name in result.metrics:
|
|
128
|
+
if name == "mae":
|
|
129
|
+
lo, hi = t_ci(float(result.metrics["mae"].value), ee)
|
|
130
|
+
out[name] = (max(0.0, lo), hi, "t")
|
|
131
|
+
elif name in ("mse", "rmse"):
|
|
132
|
+
if sq is None:
|
|
133
|
+
sq = e * e
|
|
134
|
+
lo, hi = t_ci(ee / n, float(np.dot(sq, sq)))
|
|
135
|
+
lo = max(0.0, lo)
|
|
136
|
+
out[name] = (lo, hi, "t") if name == "mse" else (math.sqrt(lo), math.sqrt(hi), "t (from MSE)")
|
|
137
|
+
elif name == "mean_bias_error":
|
|
138
|
+
lo, hi = t_ci(float(e.mean()), ee)
|
|
139
|
+
out[name] = (lo, hi, "t")
|
|
122
140
|
return out
|
|
123
141
|
|
|
124
142
|
|
evalsuite/_update.py
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"""Staying current: a once-a-day notice when a newer EvalSuite is on PyPI, and a one-command upgrade.
|
|
2
|
+
|
|
3
|
+
pip itself never replaces an installed package unless asked (``pip install -U``), and no package can change
|
|
4
|
+
that. EvalSuite therefore tells you when a newer release exists and upgrades on request:
|
|
5
|
+
|
|
6
|
+
* On import, if the last check (cached for a day in the user cache directory) found a newer release, one line
|
|
7
|
+
is printed to stderr. The check itself runs in a background thread, so importing never waits on the network.
|
|
8
|
+
* ``evalsuite.upgrade()`` or ``evalsuite upgrade`` installs the latest release into the running interpreter
|
|
9
|
+
(``python -m pip install --upgrade evalsuite-python``).
|
|
10
|
+
* ``evalsuite.check_for_update()`` returns the installed and latest versions.
|
|
11
|
+
|
|
12
|
+
Set ``EVALSUITE_NO_UPDATE_CHECK=1`` to turn the check off; it is also off in CI (``CI`` set) and under pytest.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
import json
|
|
18
|
+
import os
|
|
19
|
+
import subprocess
|
|
20
|
+
import sys
|
|
21
|
+
import threading
|
|
22
|
+
import time
|
|
23
|
+
from dataclasses import dataclass
|
|
24
|
+
from pathlib import Path
|
|
25
|
+
from typing import Any, Optional
|
|
26
|
+
|
|
27
|
+
PACKAGE = "evalsuite-python"
|
|
28
|
+
PYPI_URL = f"https://pypi.org/pypi/{PACKAGE}/json"
|
|
29
|
+
DAY = 24 * 3600
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@dataclass(frozen=True)
|
|
33
|
+
class UpdateInfo:
|
|
34
|
+
"""Installed and latest released versions."""
|
|
35
|
+
|
|
36
|
+
installed: str
|
|
37
|
+
latest: Optional[str]
|
|
38
|
+
|
|
39
|
+
@property
|
|
40
|
+
def update_available(self) -> bool:
|
|
41
|
+
return self.latest is not None and _key(self.latest) > _key(self.installed)
|
|
42
|
+
|
|
43
|
+
def __repr__(self) -> str:
|
|
44
|
+
if self.latest is None:
|
|
45
|
+
return f"UpdateInfo(installed={self.installed}, latest=unknown)"
|
|
46
|
+
state = "update available" if self.update_available else "up to date"
|
|
47
|
+
return f"UpdateInfo(installed={self.installed}, latest={self.latest}, {state})"
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _key(version: str) -> tuple[int, ...]:
|
|
51
|
+
"""Release tuple of a version string ('1.1.2' -> (1, 1, 2)); pre-release suffixes sort below the release."""
|
|
52
|
+
parts: list[int] = []
|
|
53
|
+
for piece in version.split("."):
|
|
54
|
+
digits = ""
|
|
55
|
+
for ch in piece:
|
|
56
|
+
if not ch.isdigit():
|
|
57
|
+
break
|
|
58
|
+
digits += ch
|
|
59
|
+
parts.append(int(digits) if digits else 0)
|
|
60
|
+
if len(digits) < len(piece): # e.g. "2rc1": a pre-release of 2
|
|
61
|
+
parts[-1] -= 1
|
|
62
|
+
break
|
|
63
|
+
return tuple(parts)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def _installed() -> str:
|
|
67
|
+
from .version import __version__
|
|
68
|
+
|
|
69
|
+
return __version__
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def _cache_file() -> Path:
|
|
73
|
+
base = os.environ.get("XDG_CACHE_HOME") or (
|
|
74
|
+
os.path.join(os.environ.get("LOCALAPPDATA", ""), "evalsuite")
|
|
75
|
+
if sys.platform == "win32" and os.environ.get("LOCALAPPDATA")
|
|
76
|
+
else os.path.join(os.path.expanduser("~"), ".cache")
|
|
77
|
+
)
|
|
78
|
+
return Path(base) / "evalsuite" / "update-check.json"
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def _read_cache() -> dict[str, Any]:
|
|
82
|
+
try:
|
|
83
|
+
data = json.loads(_cache_file().read_text())
|
|
84
|
+
return data if isinstance(data, dict) else {}
|
|
85
|
+
except (OSError, ValueError):
|
|
86
|
+
return {}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def _write_cache(data: dict[str, Any]) -> None:
|
|
90
|
+
try:
|
|
91
|
+
path = _cache_file()
|
|
92
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
93
|
+
path.write_text(json.dumps(data))
|
|
94
|
+
except OSError:
|
|
95
|
+
pass
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def _fetch_latest(timeout: float = 3.0) -> Optional[str]:
|
|
99
|
+
"""Latest version on PyPI, or None when PyPI cannot be reached."""
|
|
100
|
+
from urllib.request import Request, urlopen
|
|
101
|
+
|
|
102
|
+
try:
|
|
103
|
+
req = Request(PYPI_URL, headers={"Accept": "application/json", "User-Agent": f"evalsuite/{_installed()}"})
|
|
104
|
+
with urlopen(req, timeout=timeout) as resp: # noqa: S310 - fixed https URL
|
|
105
|
+
version = json.load(resp)["info"]["version"]
|
|
106
|
+
return str(version)
|
|
107
|
+
except Exception: # offline, proxy, firewall, malformed response: never an error for the user
|
|
108
|
+
return None
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def check_for_update(*, timeout: float = 3.0) -> UpdateInfo:
|
|
112
|
+
"""Ask PyPI for the latest release now (refreshes the daily cache)."""
|
|
113
|
+
latest = _fetch_latest(timeout)
|
|
114
|
+
if latest is not None:
|
|
115
|
+
data = _read_cache()
|
|
116
|
+
data.update({"checked": time.time(), "latest": latest})
|
|
117
|
+
_write_cache(data)
|
|
118
|
+
return UpdateInfo(_installed(), latest)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def upgrade(*, quiet: bool = False) -> int:
|
|
122
|
+
"""Install the latest release into this Python environment (``python -m pip install --upgrade``).
|
|
123
|
+
|
|
124
|
+
Returns pip's exit code. In a virtual environment, conda environment or user install, the upgrade goes
|
|
125
|
+
exactly where the running ``evalsuite`` came from, because it uses this interpreter's pip."""
|
|
126
|
+
cmd = [sys.executable, "-m", "pip", "install", "--upgrade", PACKAGE]
|
|
127
|
+
if quiet:
|
|
128
|
+
cmd.append("--quiet")
|
|
129
|
+
return subprocess.call(cmd) # noqa: S603 - fixed arguments
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def _disabled() -> bool:
|
|
133
|
+
env = os.environ
|
|
134
|
+
return bool(
|
|
135
|
+
env.get("EVALSUITE_NO_UPDATE_CHECK")
|
|
136
|
+
or env.get("CI")
|
|
137
|
+
or env.get("PYTEST_CURRENT_TEST")
|
|
138
|
+
or "pytest" in sys.modules
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def _background_refresh() -> None:
|
|
143
|
+
latest = _fetch_latest()
|
|
144
|
+
if latest is not None:
|
|
145
|
+
data = _read_cache()
|
|
146
|
+
data.update({"checked": time.time(), "latest": latest})
|
|
147
|
+
_write_cache(data)
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def notify_on_import() -> None:
|
|
151
|
+
"""Print the cached notice (at most once a day) and refresh the cache in the background when stale."""
|
|
152
|
+
if _disabled():
|
|
153
|
+
return
|
|
154
|
+
data = _read_cache()
|
|
155
|
+
now = time.time()
|
|
156
|
+
latest = data.get("latest")
|
|
157
|
+
installed = _installed()
|
|
158
|
+
if isinstance(latest, str) and _key(latest) > _key(installed) and now - float(data.get("notified", 0)) > DAY:
|
|
159
|
+
print(
|
|
160
|
+
f"EvalSuite {latest} is available (you have {installed}). Upgrade with: evalsuite upgrade "
|
|
161
|
+
f"(or pip install -U {PACKAGE}). Silence with EVALSUITE_NO_UPDATE_CHECK=1.",
|
|
162
|
+
file=sys.stderr,
|
|
163
|
+
)
|
|
164
|
+
data["notified"] = now
|
|
165
|
+
_write_cache(data)
|
|
166
|
+
if now - float(data.get("checked", 0)) > DAY:
|
|
167
|
+
threading.Thread(target=_background_refresh, name="evalsuite-update-check", daemon=True).start()
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
__all__ = ["UpdateInfo", "check_for_update", "upgrade"]
|
evalsuite/cli/main.py
CHANGED
|
@@ -425,6 +425,38 @@ def cmd_metrics(args: argparse.Namespace) -> int:
|
|
|
425
425
|
return 0
|
|
426
426
|
|
|
427
427
|
|
|
428
|
+
def cmd_upgrade(args: argparse.Namespace) -> int:
|
|
429
|
+
from .._update import check_for_update, upgrade
|
|
430
|
+
|
|
431
|
+
info = check_for_update()
|
|
432
|
+
if info.latest is None and not args.force:
|
|
433
|
+
print(f"evalsuite-python {info.installed}: PyPI could not be reached; upgrading anyway.", file=sys.stderr)
|
|
434
|
+
elif not info.update_available and not args.force:
|
|
435
|
+
print(f"evalsuite-python {info.installed} is the latest release.")
|
|
436
|
+
return 0
|
|
437
|
+
elif info.latest is not None:
|
|
438
|
+
print(f"Upgrading evalsuite-python {info.installed} -> {info.latest} ...")
|
|
439
|
+
if args.check:
|
|
440
|
+
return 0
|
|
441
|
+
return upgrade()
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
def cmd_version(args: argparse.Namespace) -> int:
|
|
445
|
+
from .._update import check_for_update
|
|
446
|
+
|
|
447
|
+
info = check_for_update() if args.check else None
|
|
448
|
+
line = f"evalsuite-python {__version__}"
|
|
449
|
+
if info is not None:
|
|
450
|
+
if info.latest is None:
|
|
451
|
+
line += " (could not reach PyPI)"
|
|
452
|
+
elif info.update_available:
|
|
453
|
+
line += f" (latest: {info.latest}; upgrade with: evalsuite upgrade)"
|
|
454
|
+
else:
|
|
455
|
+
line += " (latest)"
|
|
456
|
+
print(line)
|
|
457
|
+
return 0
|
|
458
|
+
|
|
459
|
+
|
|
428
460
|
def cmd_info(args: argparse.Namespace) -> int:
|
|
429
461
|
import evalsuite as es
|
|
430
462
|
|
|
@@ -594,6 +626,17 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
594
626
|
add_output(p, digits=3)
|
|
595
627
|
p.set_defaults(func=cmd_leaderboard)
|
|
596
628
|
|
|
629
|
+
p = sub.add_parser(
|
|
630
|
+
"upgrade", help="install the latest EvalSuite release into this Python environment (pip install -U)"
|
|
631
|
+
)
|
|
632
|
+
p.add_argument("--check", action="store_true", help="only report whether a newer release exists")
|
|
633
|
+
p.add_argument("--force", action="store_true", help="run pip even if this is already the latest release")
|
|
634
|
+
p.set_defaults(func=cmd_upgrade)
|
|
635
|
+
|
|
636
|
+
p = sub.add_parser("version", help="show the installed version (--check: compare with PyPI)")
|
|
637
|
+
p.add_argument("--check", action="store_true", help="also look up the latest release on PyPI")
|
|
638
|
+
p.set_defaults(func=cmd_version)
|
|
639
|
+
|
|
597
640
|
p = sub.add_parser("metrics", help="list available metrics")
|
|
598
641
|
p.add_argument("--category", choices=("classification", "regression", "clinical", "calibration"))
|
|
599
642
|
p.set_defaults(func=cmd_metrics)
|
evalsuite/version.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: evalsuite-python
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.2
|
|
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
|
|
@@ -97,22 +97,26 @@ Description-Content-Type: text/markdown
|
|
|
97
97
|
EvalSuite brings classification, regression, clinical, statistical, segmentation and object-detection
|
|
98
98
|
evaluation into one consistent, validated, documented framework.
|
|
99
99
|
|
|
100
|
-
> **Status: stable (1.1.
|
|
101
|
-
>
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
100
|
+
> **Status: stable (1.1.2).** [Example notebooks](notebooks/README.md) (Colab) ·
|
|
101
|
+
> [in-browser tools](https://evalsuite-nine.vercel.app/tools) · [changelog](CHANGELOG.md)
|
|
102
|
+
|
|
103
|
+
**What's new**
|
|
104
|
+
|
|
105
|
+
- **1.1.2** — a once-a-day notice when a newer release exists, and a one-command upgrade (`evalsuite upgrade`
|
|
106
|
+
or `es.upgrade()`); every README refreshed with current benchmark numbers.
|
|
107
|
+
- **1.1.1** — hardening: every engine metric fuzzed (no crashes on malformed input), NaN / Infinity preserved in
|
|
108
|
+
every language, bug fixes in `evaluate()`'s task detection, 2.4–6× faster engine bootstrap intervals.
|
|
109
|
+
- **1.1** — the engine everywhere: clinical, calibration, retrieval and segmentation metrics with confidence
|
|
110
|
+
intervals in JavaScript, C, R and Julia; an R source package; Colab notebooks; BLEU and HD95 faster than the
|
|
111
|
+
Python path.
|
|
112
|
+
- **1.0** — `evaluate()` reports confidence intervals by default and tests against a baseline; an LLM
|
|
113
|
+
leaderboard that knows when models are tied; scikit-learn, Hugging Face, Keras, Lightning, MLflow and W&B
|
|
114
|
+
integrations; monitoring with drift alerts; TRIPOD+AI and model-card report cards; npm (WebAssembly), C, R
|
|
115
|
+
and Julia bindings.
|
|
116
|
+
- **0.8** — a full Rust edition on crates.io ([`evalsuite`](https://crates.io/crates/evalsuite)) and the
|
|
117
|
+
`evalsuite-cli` command. **0.6–0.7** — a compiled, multithreaded Rust core with identical results.
|
|
118
|
+
**0.5** — LLM systems (safety, robustness, agents, code, long context, efficiency). **0.1–0.4** —
|
|
119
|
+
classification, regression, clinical, statistics, vision and LLM evaluation.
|
|
116
120
|
|
|
117
121
|
## Installation
|
|
118
122
|
|
|
@@ -120,6 +124,12 @@ evaluation into one consistent, validated, documented framework.
|
|
|
120
124
|
pip install evalsuite-python
|
|
121
125
|
```
|
|
122
126
|
|
|
127
|
+
To move to the newest release later, run `evalsuite upgrade` (or `pip install -U evalsuite-python`). pip never
|
|
128
|
+
replaces an installed package on its own, so EvalSuite prints a one-line notice, at most once a day, when a
|
|
129
|
+
newer release is on PyPI; the check runs in the background and never slows `import evalsuite`
|
|
130
|
+
(`EVALSUITE_NO_UPDATE_CHECK=1` turns it off; it is always off in CI). `es.check_for_update()` and
|
|
131
|
+
`evalsuite version --check` report the installed and latest versions.
|
|
132
|
+
|
|
123
133
|
The package is installed as `evalsuite-python` and imported as `evalsuite`:
|
|
124
134
|
|
|
125
135
|
```python
|
|
@@ -146,7 +156,7 @@ and as a standalone command (`cargo install evalsuite-cli`):
|
|
|
146
156
|
|
|
147
157
|
```toml
|
|
148
158
|
[dependencies]
|
|
149
|
-
evalsuite = "
|
|
159
|
+
evalsuite = "1.1"
|
|
150
160
|
```
|
|
151
161
|
|
|
152
162
|
```rust
|
|
@@ -158,7 +168,28 @@ evalsuite evaluate preds.csv --y-true label --y-pred pred --y-prob score
|
|
|
158
168
|
```
|
|
159
169
|
|
|
160
170
|
See [rust/evalsuite/README.md](rust/evalsuite/README.md) for the module list, performance and the few
|
|
161
|
-
documented differences, and [rust/evalsuite-cli/README.md](rust/evalsuite-cli/README.md) for the command
|
|
171
|
+
documented differences, and [rust/evalsuite-cli/README.md](rust/evalsuite-cli/README.md) for the command
|
|
172
|
+
(`evalsuite upgrade` installs its latest release).
|
|
173
|
+
|
|
174
|
+
### JavaScript, C, R and Julia
|
|
175
|
+
|
|
176
|
+
One engine, the same numbers in every language ([bindings/README.md](bindings/README.md)):
|
|
177
|
+
|
|
178
|
+
```js
|
|
179
|
+
// npm install evalsuite@latest
|
|
180
|
+
const es = require("evalsuite");
|
|
181
|
+
es.evaluate("roc_auc", { y_true: [0, 0, 1, 1], y_prob: [0.1, 0.4, 0.35, 0.8], ci: "analytic" });
|
|
182
|
+
// { metric: "roc_auc", value: 0.75, ci_low: ..., ci_high: ..., ci_method: "delong" }
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
```r
|
|
186
|
+
library(evalsuite) # install.packages from the release tarball or R-universe
|
|
187
|
+
es_metric("f1", y_true = c(0, 1, 1, 0), y_pred = c(0, 1, 0, 0))
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
C (`evalsuite.h`, `-levalsuite_c`) and Julia (`EvalSuite.metric("f1"; y_true=..., y_pred=...)`) take the same
|
|
191
|
+
arguments. Metrics: classification, clinical, calibration, regression, text, retrieval, segmentation, drift
|
|
192
|
+
and the leaderboard, with `ci: "analytic"` or `"bootstrap"` intervals.
|
|
162
193
|
|
|
163
194
|
## Why EvalSuite
|
|
164
195
|
|
|
@@ -344,6 +375,67 @@ es.time_to_first_token(request_times=[0.0, 1.0], first_token_times=[0.21, 1.35])
|
|
|
344
375
|
es.inference_cost([1200, 800], [300, 150], input_price=3.0, output_price=15.0) # prices per 1M tokens
|
|
345
376
|
```
|
|
346
377
|
|
|
378
|
+
## Confidence intervals and baselines by default
|
|
379
|
+
|
|
380
|
+
```python
|
|
381
|
+
result = es.evaluate(y_true, new_pred, y_prob=new_prob, baseline_pred=old_pred, baseline_prob=old_prob)
|
|
382
|
+
print(result.summary())
|
|
383
|
+
# Random forest vs logistic regression, breast-cancer test split (notebooks/01):
|
|
384
|
+
# Accuracy 0.9430 (0.9049–0.9664) -0.0044 vs baseline (p=1.000, mcnemar-exact)
|
|
385
|
+
# ROC AUC 0.9833 (0.9637–1.0000) -0.0097 vs baseline (p=0.285, delong)
|
|
386
|
+
# Brier score 0.0375 (0.0216–0.0535) -0.0001 vs baseline (p=0.989, paired-bootstrap)
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
Intervals are analytic by default (Wilson, DeLong, Student-t; no extra cost), `ci="bootstrap"` for any metric,
|
|
390
|
+
`ci=False` to turn them off; baseline tests are paired and Holm-adjusted.
|
|
391
|
+
|
|
392
|
+
## Report cards (TRIPOD+AI, model cards)
|
|
393
|
+
|
|
394
|
+
```python
|
|
395
|
+
card = es.report_card(y_true, y_prob, threshold=0.2, groups=site, group_name="site")
|
|
396
|
+
print(card.paragraph()) # results paragraph with intervals, ready for a paper
|
|
397
|
+
card.to_markdown()
|
|
398
|
+
card.to_latex()
|
|
399
|
+
# card.to_docx("performance.docx") # Word: pip install "evalsuite-python[docx]"
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
Discrimination, calibration, Brier score, threshold measures, net benefit and subgroup performance, plus the
|
|
403
|
+
TRIPOD+AI checklist; `standard="model-card"` fills a model card's quantitative sections.
|
|
404
|
+
|
|
405
|
+
## LLM leaderboards
|
|
406
|
+
|
|
407
|
+
```python
|
|
408
|
+
board = es.leaderboard({"model-a": "runs/a.jsonl", "model-b": "runs/b.jsonl"}, scorer="gsm8k")
|
|
409
|
+
print(board.summary()) # ranks shared when differences are not significant (McNemar, Holm)
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
Scorers (exact match, GSM8K, boxed, choice, numeric, ...), per-category tables, contamination and LLM-judge
|
|
413
|
+
position checks; also `evalsuite leaderboard runs/*.jsonl` and the [in-browser tool](https://evalsuite-nine.vercel.app/tools).
|
|
414
|
+
|
|
415
|
+
## Monitoring
|
|
416
|
+
|
|
417
|
+
```python
|
|
418
|
+
mon = es.Monitor(
|
|
419
|
+
window=1000, alerts={"roc_auc": ("<", 0.8), "psi": (">", 0.25)}, reference_scores=validation_probabilities
|
|
420
|
+
)
|
|
421
|
+
alerts = mon.update(y_true_batch, y_pred=pred_batch, y_prob=prob_batch)
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
Sliding-window metrics, PSI and Kolmogorov–Smirnov drift (also before labels arrive, with `observe`), alert
|
|
425
|
+
callbacks and `snapshot()` with intervals.
|
|
426
|
+
|
|
427
|
+
## Integrations
|
|
428
|
+
|
|
429
|
+
```python
|
|
430
|
+
from evalsuite import integrations as ei
|
|
431
|
+
|
|
432
|
+
cross_val_score(model, X, y, scoring=ei.sklearn_scorer("mcc"))
|
|
433
|
+
Trainer(..., compute_metrics=ei.hf_compute_metrics(["accuracy", "f1"]))
|
|
434
|
+
model.fit(X, y, callbacks=[ei.keras_callback(X_val, y_val)])
|
|
435
|
+
ei.log_mlflow(result)
|
|
436
|
+
ei.log_wandb(result)
|
|
437
|
+
```
|
|
438
|
+
|
|
347
439
|
## Classification report
|
|
348
440
|
|
|
349
441
|
```python
|
|
@@ -392,7 +484,9 @@ evalsuite segmentation true_masks.npy pred_masks.npy --ignore-index 255 --plot p
|
|
|
392
484
|
evalsuite detection instances_val.json detections.json --plot pr_curves.png
|
|
393
485
|
evalsuite metrics --category clinical
|
|
394
486
|
evalsuite info classification.mcc
|
|
487
|
+
evalsuite leaderboard runs/*.jsonl --scorer gsm8k -o leaderboard.md
|
|
395
488
|
evalsuite benchmark --quick
|
|
489
|
+
evalsuite upgrade # install the latest release
|
|
396
490
|
```
|
|
397
491
|
|
|
398
492
|
Input files can be CSV, TSV, Parquet or JSON. Output format follows `--format` or the `-o` extension
|
|
@@ -400,46 +494,46 @@ Input files can be CSV, TSV, Parquet or JSON. Output format follows `--format` o
|
|
|
400
494
|
|
|
401
495
|
## Performance
|
|
402
496
|
|
|
403
|
-
Benchmarked against reference implementations on the same data (fastest of 5 runs; EvalSuite
|
|
404
|
-
NumPy 2.5, Linux x86_64). **
|
|
405
|
-
difference 2.5e-14),
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
segmentation; 1,000 images for detection and 50 for Hausdorff;
|
|
409
|
-
alphabetical order:
|
|
497
|
+
Benchmarked against reference implementations on the same data (fastest of 5 runs; EvalSuite 1.1.2, Python 3.13,
|
|
498
|
+
NumPy 2.5, Linux x86_64 with 2 cores). **Every one of the 78 comparisons agrees with the reference** (largest
|
|
499
|
+
difference 2.5e-14), 77 are faster (the other, Hochberg's correction at 100,000 p-values, is level at 0.98×),
|
|
500
|
+
and the geometric-mean speed-up across 27 cases at three sizes is **3.86×**. `evaluate()` now also computes
|
|
501
|
+
the default confidence intervals inside these timings and is still 18× faster than scikit-learn's separate
|
|
502
|
+
metric calls. At 1,000,000 samples (pixels for segmentation; 1,000 images for detection and 50 for Hausdorff;
|
|
503
|
+
10,000 examples for the LLM cases), in alphabetical order:
|
|
410
504
|
|
|
411
505
|
| Case | Reference | EvalSuite (ms) | Reference (ms) | Speed-up |
|
|
412
506
|
| --- | --- | ---: | ---: | ---: |
|
|
413
|
-
| 10 classes: macro F1 | scikit-learn |
|
|
414
|
-
| agreement: Krippendorff's alpha, interval (4 raters × 10000 items) | krippendorff | 1.
|
|
415
|
-
| binary: 8 label metrics via evaluate() | scikit-learn |
|
|
416
|
-
| binary: ROC AUC | scikit-learn |
|
|
417
|
-
| calibration: slope and intercept | statsmodels |
|
|
418
|
-
| clinical: diagnostic report (7 CIs) | statsmodels | 5.
|
|
419
|
-
| clinical: sensitivity, specificity, LR+, LR− | scikit-learn |
|
|
420
|
-
| decision curve: 99 thresholds | NumPy loop |
|
|
421
|
-
| detection: COCO evaluation (1000 images) | pycocotools |
|
|
422
|
-
| multiple testing: Hochberg (n p-values) | statsmodels |
|
|
423
|
-
| regression: MAE, MSE, RMSE, R² via evaluate() | scikit-learn | 7
|
|
424
|
-
| retrieval: MRR, MAP@20, NDCG@10 (10000 queries) | ranx |
|
|
425
|
-
| segmentation: Dice and IoU per class (n = pixels) | scikit-learn |
|
|
426
|
-
| segmentation: Hausdorff distance (50 images) | SciPy |
|
|
427
|
-
| statistics: Cramér's V (5×5 table) | SciPy | 0.0 | 0.
|
|
428
|
-
| statistics: Mann–Whitney U | SciPy |
|
|
429
|
-
| statistics: Welch t-test | SciPy |
|
|
430
|
-
| structured: JSON Schema compliance (10000 documents) | jsonschema |
|
|
431
|
-
| systems: CodeBLEU n-gram terms (1000 programs) |
|
|
432
|
-
| systems: confidence AUROC (n answers) | scikit-learn |
|
|
433
|
-
| systems: distribution-shift drop, Welch CI (n scores) | SciPy |
|
|
434
|
-
| systems: invalid tool calls vs JSON Schema (10000 tasks) | jsonschema |
|
|
435
|
-
| systems: latency p50 / p95 / p99 (n requests) | NumPy |
|
|
436
|
-
| systems: maintainability index (1000 programs) | radon |
|
|
437
|
-
| text:
|
|
438
|
-
| text:
|
|
439
|
-
| text:
|
|
440
|
-
|
|
441
|
-
**Every metric is benchmarked too** (`evalsuite benchmark --suite metrics
|
|
442
|
-
statistics functions at 10,000 and 100,000 samples. 86 are compared with a reference library, 118 with an
|
|
507
|
+
| 10 classes: macro F1 | scikit-learn | 8.6 | 35.6 | **4.16×** |
|
|
508
|
+
| agreement: Krippendorff's alpha, interval (4 raters × 10000 items) | krippendorff | 1.6 | 3.2 | **2.01×** |
|
|
509
|
+
| binary: 8 label metrics via evaluate() | scikit-learn | 9.2 | 172.0 | **18.70×** |
|
|
510
|
+
| binary: ROC AUC | scikit-learn | 84.0 | 211.6 | **2.52×** |
|
|
511
|
+
| calibration: slope and intercept | statsmodels | 218.2 | 1217.0 | **5.58×** |
|
|
512
|
+
| clinical: diagnostic report (7 CIs) | statsmodels | 5.5 | 6.5 | **1.17×** |
|
|
513
|
+
| clinical: sensitivity, specificity, LR+, LR− | scikit-learn | 19.5 | 76.4 | **3.91×** |
|
|
514
|
+
| decision curve: 99 thresholds | NumPy loop | 169.5 | 196.8 | **1.16×** |
|
|
515
|
+
| detection: COCO evaluation (1000 images) | pycocotools | 40.2 | 831.8 | **20.71×** |
|
|
516
|
+
| multiple testing: Hochberg (n p-values) | statsmodels | 77.4 | 96.0 | **1.24×** |
|
|
517
|
+
| regression: MAE, MSE, RMSE, R² via evaluate() | scikit-learn | 9.7 | 11.4 | **1.18×** |
|
|
518
|
+
| retrieval: MRR, MAP@20, NDCG@10 (10000 queries) | ranx | 106.7 | 777.2 | **7.28×** |
|
|
519
|
+
| segmentation: Dice and IoU per class (n = pixels) | scikit-learn | 34.9 | 72.2 | **2.07×** |
|
|
520
|
+
| segmentation: Hausdorff distance (50 images) | SciPy | 7.6 | 18.5 | **2.43×** |
|
|
521
|
+
| statistics: Cramér's V (5×5 table) | SciPy | 0.0 | 0.3 | **15.93×** |
|
|
522
|
+
| statistics: Mann–Whitney U | SciPy | 127.5 | 385.5 | **3.02×** |
|
|
523
|
+
| statistics: Welch t-test | SciPy | 5.4 | 8.1 | **1.50×** |
|
|
524
|
+
| structured: JSON Schema compliance (10000 documents) | jsonschema | 133.2 | 295.5 | **2.22×** |
|
|
525
|
+
| systems: CodeBLEU n-gram terms (1000 programs) | – | 435.4 | – | – |
|
|
526
|
+
| systems: confidence AUROC (n answers) | scikit-learn | 181.8 | 242.6 | **1.33×** |
|
|
527
|
+
| systems: distribution-shift drop, Welch CI (n scores) | SciPy | 6.3 | 7.5 | **1.20×** |
|
|
528
|
+
| systems: invalid tool calls vs JSON Schema (10000 tasks) | jsonschema | 127.6 | 285.0 | **2.23×** |
|
|
529
|
+
| systems: latency p50 / p95 / p99 (n requests) | NumPy | 9.0 | 15.3 | **1.71×** |
|
|
530
|
+
| systems: maintainability index (1000 programs) | radon | 118.3 | 131.9 | **1.11×** |
|
|
531
|
+
| text: METEOR, exact and stem matches (10000 sentences) | NLTK | 92.4 | 493.8 | **5.34×** |
|
|
532
|
+
| text: ROUGE-1, ROUGE-2, ROUGE-L (10000 sentences) | rouge-score | 219.5 | 889.0 | **4.05×** |
|
|
533
|
+
| text: corpus BLEU and chrF (10000 sentences) | sacreBLEU | 266.7 | 2399.8 | **9.00×** |
|
|
534
|
+
|
|
535
|
+
**Every metric is benchmarked too** (`evalsuite benchmark --suite metrics`, last full run with 0.7.1): all 225
|
|
536
|
+
registered metrics and statistics functions at 10,000 and 100,000 samples. 86 are compared with a reference library, 118 with an
|
|
443
537
|
independent textbook formula and 21 (learned, judge-dependent or randomised) are timed alone; **all 204
|
|
444
538
|
comparisons agree**, and against the libraries the geometric-mean speed-up is **6.64×** (171 of 172
|
|
445
539
|
measurements faster). Per-metric table in BENCHMARKS.md.
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
evalsuite/__init__.py,sha256=
|
|
1
|
+
evalsuite/__init__.py,sha256=GlKjVK9VcRFCZqWBxgtnzBbmipMuoxJlRWiHvk1Azm8,6377
|
|
2
2
|
evalsuite/__main__.py,sha256=Nq90_8VlUN1mif-AVgX-kZRL63bd94F5-F7F9UkVZD4,117
|
|
3
3
|
evalsuite/_bench_metrics.py,sha256=GLLa9OhCNmu6IyWkxC0AcNf7p-CTpoOwWUS99C1o2o8,75792
|
|
4
|
-
evalsuite/_evalci.py,sha256=
|
|
4
|
+
evalsuite/_evalci.py,sha256=5fDWxJjfSLmwA3Vfq_8Zl99u6uc847EVvGoPsYufWuI,11271
|
|
5
5
|
evalsuite/_lazy.py,sha256=Ddq0uWuiyxtsT0jBtCSITQPvttiQ7znXAbjkMIOVefk,901
|
|
6
6
|
evalsuite/_native.py,sha256=haMBiKqPDmHGoGbq4Cn8iFmm1Vt-tFYYsyRQ3XLyueE,2351
|
|
7
|
+
evalsuite/_update.py,sha256=tL4R4Rn1oyLnsU69LzHw3U_7nw-YKcfgmq0qywyHtmg,6007
|
|
7
8
|
evalsuite/api.py,sha256=XaL5eEThZ0TI-C4I6wfNKlNYQ0VSQfJQa72kMbFXo9Q,13225
|
|
8
9
|
evalsuite/benchmarks.py,sha256=TWXIhdYPbdDPanCOFL1lRCo3ppRYaDF58PB-o3ZZyTA,37846
|
|
9
10
|
evalsuite/calibration.py,sha256=jhCPOmCFGEkUkcx-hSAIb-JCMq9oF6JZt4uDGvg5NaU,15083
|
|
@@ -14,12 +15,12 @@ evalsuite/monitor.py,sha256=qW8KGJSm-9boIUQoiylxJRV_yD_jvCGh-rFXNKyPPlI,9006
|
|
|
14
15
|
evalsuite/plot.py,sha256=7eOyzoRbg6Aad6OhtIQG3laIioQ8fs2K0YzodjG5rHA,26049
|
|
15
16
|
evalsuite/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
17
|
evalsuite/reporting.py,sha256=-LISv9vvEnltT26GtzLjVlxOCcAwmjv4-HyB8_1UF5o,9615
|
|
17
|
-
evalsuite/version.py,sha256=
|
|
18
|
+
evalsuite/version.py,sha256=cL-C3uQEcEscEYq9HlwernA8baZ7f3xVtxgnTB6bEJU,98
|
|
18
19
|
evalsuite/classification/__init__.py,sha256=ErBIXbBGnhfW6v-1Cn5SegiERoyxNlmO1tEKcLM15mA,833
|
|
19
20
|
evalsuite/classification/_common.py,sha256=3ANV33ix_mnOzvOAG8glyJO-iYVhhTGO0S3YG0ZddB8,4543
|
|
20
21
|
evalsuite/classification/metrics.py,sha256=cP9TAVVk6Pob2VUuxMfQpOakzVmuMOXzGzqO2oGhED8,40575
|
|
21
22
|
evalsuite/cli/__init__.py,sha256=1x48hORLcg_Is2X08A7CPBT6VDJ1QL94zaJP1HTFxUY,96
|
|
22
|
-
evalsuite/cli/main.py,sha256=
|
|
23
|
+
evalsuite/cli/main.py,sha256=6_Bgz-XI5-NtbTcLLjKdPq-KWvBBTb0xP7GrDKJwyWs,27809
|
|
23
24
|
evalsuite/clinical/__init__.py,sha256=xaXLvNvTJsuP525fLb2FyVVNlopIrZczoPrwmEQIvzE,549
|
|
24
25
|
evalsuite/clinical/metrics.py,sha256=Abz4rA9FfOIWn7MXAMnxAH_C3XICY9x-nPQhP1-79xU,13453
|
|
25
26
|
evalsuite/clinical/report.py,sha256=JaS9PKjUHkiKl_AURC1TwNiDc_V-6B2KNhV4kzHZhdE,14996
|
|
@@ -67,9 +68,9 @@ evalsuite/text/structured.py,sha256=x08yYf2rdlmiA_D_dI1L-fc9quHiBPMKgAGQbG3kJr8,
|
|
|
67
68
|
evalsuite/vision/__init__.py,sha256=9gpOBTPveM_srE6BM-SgCssdQurya2LPHhoMLGOh2A0,991
|
|
68
69
|
evalsuite/vision/detection.py,sha256=Cjr-Y5-pV0wiQk1JiHLYvDdKzMlCEvVQarzY7fqGWw4,32010
|
|
69
70
|
evalsuite/vision/segmentation.py,sha256=tYYsBfEYdPvi94k3dJgp8ODn8X0qKsLW5QAv7KuQMj0,41953
|
|
70
|
-
evalsuite_python-1.1.
|
|
71
|
-
evalsuite_python-1.1.
|
|
72
|
-
evalsuite_python-1.1.
|
|
73
|
-
evalsuite_python-1.1.
|
|
74
|
-
evalsuite_python-1.1.
|
|
75
|
-
evalsuite_python-1.1.
|
|
71
|
+
evalsuite_python-1.1.2.dist-info/METADATA,sha256=TE1DlX0rVS7ejM1d_JWKAPEO0N4Uv97-iueFR-IKuLQ,35137
|
|
72
|
+
evalsuite_python-1.1.2.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
73
|
+
evalsuite_python-1.1.2.dist-info/entry_points.txt,sha256=YYIwisn4L4sQt3ntzbM0_Z4yZE2KCu3GJ6KfWL1kIwc,54
|
|
74
|
+
evalsuite_python-1.1.2.dist-info/licenses/LICENSE,sha256=cRRQ6Kk8w2qCqtDSSUJQGy-0rqjmjJG09cZ6iIiMvdc,1095
|
|
75
|
+
evalsuite_python-1.1.2.dist-info/licenses/LICENSE-APACHE,sha256=K4pWYv3dt61u1BuIxjOGBxhgRkpsH4X_dzeIbOILXw0,10784
|
|
76
|
+
evalsuite_python-1.1.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{evalsuite_python-1.1.1.dist-info → evalsuite_python-1.1.2.dist-info}/licenses/LICENSE-APACHE
RENAMED
|
File without changes
|