EvalSuite

Unified, reproducible evaluation for machine learning, LLM and research.
EvalSuite brings classification, regression, clinical, statistical, segmentation and object-detection
evaluation into one consistent, validated, documented framework.
Status: stable (0.8.0). Every item on the 0.1.0–0.5.0 roadmaps is implemented and verified, including SPICE.
0.6 adds a compiled Rust core: same API and identical results, with text metrics, COCO evaluation and
bootstrap resampling several times faster and multithreaded (prebuilt wheels for Linux, macOS and Windows).
0.7.0 moves ROC AUC / average precision (and so evaluate()), the LLM-systems consistency metrics,
groundedness, citation coverage, toxicity, exposure and Elo into the core.
0.7.1 adds bootstrapped ROC AUC / AP (4–5× faster intervals), DeLong, QA exact match / F1,
Hausdorff / surface distances, calibration and the WEAT permutation test.
0.8.0 adds a full Rust edition on crates.io (evalsuite): every
metric except code_complexity, checked case by case against this package.
LLM systems arrive in 0.5.0: safety, robustness, calibration and uncertainty, agents and tool use,
multilingual, code generation, long context and summarization, and inference efficiency and cost.
Installation
pip install evalsuite-python
The package is installed as evalsuite-python and imported as evalsuite:
import evalsuite as es
EvalSuite has a compiled core written in Rust. pip installs a prebuilt wheel on Linux (x86_64, aarch64;
glibc and musl), macOS (Apple silicon, Intel) and Windows (x64, arm64) for Python 3.9 to 3.14, so no compiler
is needed. Anywhere else pip falls back to a pure-Python wheel that gives exactly the same results, more slowly.
evalsuite._native.backend() says which one is in use ("rust" or "python"), and
EVALSUITE_PURE_PYTHON=1 selects the Python implementations on any install.
The core runs independent examples (sentences, images, classes, resamples) in parallel on all CPU cores; set
EVALSUITE_NUM_THREADS to cap the number of threads. Results never depend on the thread count: sums are always
taken in example order. Bootstrap functions (bootstrap_ci, paired_bootstrap_test, compare) and
weat_effect_size accept resampling="native" to draw resamples (or permutations) in the core (seeded
xoshiro256++): reproducible with random_state and faster on large inputs, but a different random stream from
the default NumPy one, so interval endpoints and p-values differ slightly (statistically equivalent).
Rust
The same metrics are available as a pure-Rust crate, verified against this package on 36,054 recorded cases:
[dependencies]
evalsuite = "0.8"
let acc = evalsuite::classification::accuracy(&[1, 0, 1, 1], &[1, 0, 0, 1], None).unwrap(); // 0.75
See rust/evalsuite/README.md for the module list and the few documented
differences.
Why EvalSuite
- One consistent API. Every metric returns a result object that behaves like a number and exports to
JSON, pandas, Markdown and LaTeX.
- Explicit conventions. Averaging, label order, the positive class and zero-division behaviour are stated
and recorded in every result, never silently assumed.
- Validated. Each metric is tested against scikit-learn where definitions coincide, plus property-based
tests and edge cases.
- Documented. Every metric carries its definition, formula, range, input requirements and references,
available programmatically through
metric_info().
- Efficient.
evaluate() validates inputs once and computes the confusion matrix once for all metrics.
- Lightweight. Requires only NumPy, SciPy and pandas.
Quick start
import evalsuite as es
y_true = [0, 1, 1, 0, 1, 0]
y_pred = [0, 1, 0, 0, 1, 1]
y_prob = [0.1, 0.9, 0.4, 0.2, 0.8, 0.6]
result = es.evaluate(y_true, y_pred, y_prob=y_prob)
print(result.summary())
result["f1"] # MetricResult(f1=0.666667)
f"{result['mcc']:.3f}" # '0.333'
result.to_latex(caption="Test-set performance")
result.to_dataframe()
es.f1(y_true, y_pred) # individual metrics
es.roc_auc(y_true, y_prob)
es.metric_info("classification.mcc").formula # documentation
es.list_metrics("regression")
Comparing models
result = es.compare(
y_true,
{"logistic": pred_lr, "forest": pred_rf, "boosting": pred_gb},
probabilities={"logistic": prob_lr, "forest": prob_rf, "boosting": prob_gb},
random_state=0,
)
print(result.summary()) # estimates with 95% CIs, paired tests, Holm-adjusted p-values
result.to_latex(label="tab:models")
es.bootstrap_ci("f1", y_true, y_pred, average="macro", random_state=0) # BCa interval for any metric
es.accuracy_ci(y_true, y_pred) # Wilson interval
es.delong_test(y_true, prob_a, prob_b) # two correlated AUCs
es.mcnemar_test(y_true, pred_a, pred_b)
Every model is evaluated on the same bootstrap resamples, so differences are paired. Accuracy is compared
with McNemar's test, binary ROC AUC with DeLong's test and other metrics with a paired bootstrap test;
p-values are adjusted for multiple comparisons (Holm by default).
Clinical evaluation
report = es.diagnostic_report(y_true, y_pred) # binary test vs reference standard
print(report)
# Sensitivity, specificity, PPV, NPV (Wilson CIs), LR+ and LR− (log CIs, Simel 1991),
# diagnostic odds ratio (Woolf), Youden's J, accuracy and prevalence
es.lr_positive(y_true, y_pred)
es.youden_j(y_true, y_pred)
dca = es.decision_curve(y_true, {"model": y_prob}) # net benefit vs treat all / treat none
dca.useful_range() # thresholds where the model beats both
es.plot.decision_curve(y_true, {"model": y_prob})
Ratios that divide by zero are inf or NaN with a warning, never 0.
Calibration
es.calibration_report(y_true, y_prob) # Brier, ECE, MCE, intercept, slope, Hosmer–Lemeshow
es.calibration_slope(y_true, y_prob) # ideal 1; < 1 means predictions are too extreme
es.calibration_intercept(y_true, y_prob) # ideal 0 (calibration-in-the-large)
es.hosmer_lemeshow(y_true, y_prob, n_groups=10)
Statistical tests
es.t_test(scores_a, scores_b) # Welch by default; mean difference with CI and Cohen's d
es.paired_t_test(fold_scores_a, fold_scores_b)
es.wilcoxon_test(fold_scores_a, fold_scores_b) # with matched-pairs rank-biserial r
es.mann_whitney_test(a, b) # with rank-biserial r
es.friedman_test(scores_a, scores_b, scores_c) # with Kendall's W
es.kruskal_wallis_test(g1, g2, g3)
es.shapiro_wilk_test(residuals)
es.chi_square_test(table) # with Cramér's V
es.fisher_exact_test([[8, 2], [1, 5]])
es.adjust_pvalues(p_values, method="hochberg") # also holm, bonferroni, bh, by
Every test returns a TestResult with the statistic, p-value and an effect size, computed with SciPy and
checked against SciPy and statsmodels in the test suite.
Segmentation
# label masks: one 2-D image, or images on the first axis (N, H, W) / (N, D, H, W), or a list of masks
es.dice(y_true, y_pred) # macro over classes, pixel counts summed over the dataset
es.iou(y_true, y_pred, average=None) # per class; classes absent from both masks are NaN, not 0
es.miou(y_true, y_pred, ignore_index=255)
es.dice(y_true, y_pred, aggregate="image") # mean of per-image scores (medical imaging convention)
es.boundary_iou(y_true, y_pred) # Cheng et al. 2021
es.hausdorff_distance(y_true, y_pred, percentile=95, spacing=(0.8, 0.8)) # HD95 in mm
report = es.segmentation_report(y_true, y_pred, class_names={0: "background", 1: "liver"})
print(report) # mIoU, Dice, pixel accuracy, Boundary IoU, HD95, ASSD + per-class table
es.plot.segmentation(image, y_true[0], y_pred[0]) # prediction fill, truth outline
es.plot.per_class(report, metric="iou") # per-class bars (also takes a detection report)
Object detection
y_true = [{"boxes": [[x1, y1, x2, y2], ...], "labels": [3, ...]}, ...] # one dict per image
y_pred = [{"boxes": [...], "labels": [...], "scores": [...]}, ...]
report = es.detection_report(y_true, y_pred) # the 12 COCO numbers + AP per class
report["map"], report["map_50"], report["mar_100"]
es.mean_average_precision(y_true, y_pred, iou_threshold=0.5) # mAP@.50
es.average_precision_detection(y_true, y_pred, interpolation="voc") # per class, VOC-style
es.box_iou(boxes_a, boxes_b, box_format="xywh")
y_true, y_pred = es.from_coco("instances_val.json", "detections.json")
es.plot.detection_pr(y_true, y_pred)
The COCO protocol (crowd regions, area ranges, max detections, 101-point interpolation) matches
pycocotools to the last digit in the test suite.
Models can be compared over the same images with intervals and paired tests, as for every other task:
es.compare(y_true, {"unet": masks_a, "deeplab": masks_b}) resamples images; for detection it compares
mAP.
LLM evaluation
es.bleu(references, predictions) # sacreBLEU-identical; also chrf, ter, rouge_l, meteor, cider
es.text_report(references, predictions) # BLEU, chrF(++), TER, ROUGE, METEOR, EM, token F1 at once
es.bertscore(ref_token_embs, pred_token_embs) # from your encoder's embeddings; also mauve, moverscore
es.model_score(refs, preds, scorer=comet_fn) # any learned metric or judge, with intervals and compare
es.faithfulness(claim_verdicts) # also hallucination_rate, citation_recall, answer_correctness
es.bradley_terry(comparisons, scale="elo") # also win_rate, elo_ratings, krippendorff_alpha
es.ndcg_at_k(relevant, retrieved, k=10) # also mrr, context_precision, context_recall
es.json_schema_compliance(outputs, schema) # also tool_call_f1, instruction_compliance_rate
es.pass_at_k(n_samples, n_correct, k=10) # also benchmark_accuracy(..., style="gsm8k")
es.compare(references, {"a": preds_a, "b": preds_b}, metrics=["bleu", "rouge_l"]) # paired over examples
es.plot.ratings(comparisons) # Bradley–Terry leaderboard with intervals; also win_matrix, text_scores
es.spice(reference_tuples, candidate_tuples) # scene-graph F-score; parser= for captions, synonyms="wordnet"
LLM systems
Safety, robustness, uncertainty, agents, multilingual, code, long context and serving cost. The verdicts
these take (harmful or not, test passed or not, confidence) come from your own judge, classifier or sandbox;
EvalSuite turns them into rates with Wilson intervals and breakdowns. PII detection, CodeBLEU, cyclomatic
complexity and the maintainability index (identical to radon) are computed from the text itself, and
EvalSuite never executes generated code.
import evalsuite as es
es.harmful_response_rate([True, False, False, True], harmful_prompt=[True, True, False, True])
es.over_refusal_rate(refused=[True, False, True], should_refuse=[True, False, False])
es.pii_leakage_rate(["mail me at a@b.io", "nothing here"]) # e-mail, phone, Luhn-checked cards, IPs
es.paraphrase_consistency([["Paris", "paris"], ["4", "5", "4"]])
es.aurc(correct=[True, True, False, True], confidence=[0.9, 0.8, 0.7, 0.4]) # also selective_risk
es.plan_adherence(plans=[["search", "read", "answer"]], executed=[["search", "answer"]])
es.language_parity({"en": [1, 1, 0, 1], "sw": [1, 0, 0, 1]})
es.codebleu(["def add(a, b):\n return a + b"], ["def add(x, y):\n return x + y"])
es.code_complexity(["def f(x):\n return 1 if x else 0"]) # cyclomatic complexity + maintainability
es.needle_in_haystack(correct=[1, 0, 1, 1], context_lengths=[4000, 4000, 8000, 8000], depths=[0, 0.5, 0, 0.5])
es.time_to_first_token(request_times=[0.0, 1.0], first_token_times=[0.21, 1.35])
es.inference_cost([1200, 800], [300, 150], input_price=3.0, output_price=15.0) # prices per 1M tokens
Classification report
report = es.classification_report(y_true, y_pred)
print(report) # per-class precision, recall, F1, specificity, support + averages
report.save("report.html") # also .csv .md .tex .json .txt
Plots
pip install "evalsuite-python[plot]" # adds matplotlib; importing evalsuite never loads it
es.plot.roc(y_true, {"logistic": prob_lr, "forest": prob_rf}) # AUC in the legend
es.plot.pr(y_true, prob) # AP and the prevalence line
es.plot.calibration(y_true, prob) # reliability diagram, ECE, Brier
es.plot.confusion_matrix(y_true, y_pred, normalize="true")
es.plot.residuals(y_reg, pred_reg) # or kind="predicted"
es.plot.comparison(es.compare(...)) # forest plot with CIs
Each function returns a matplotlib Axes (pass ax= to draw into your own figure). The numbers shown are
computed with EvalSuite's metrics, so plots and tables always agree. Several models get distinct colours
and line styles, so figures stay readable in greyscale print.
Exports
Every result (evaluate, classification_report, compare, single metrics) exports to summary(),
to_json(), to_csv(), to_dataframe(), to_markdown(), to_latex() and to_html(), and save(path) picks
the format from the extension. HTML pages are standalone (inline CSS, no scripts) and escape all text.
Command line
evalsuite evaluate predictions.csv --y-true label --y-pred pred --y-prob prob
evalsuite report predictions.csv --y-true label --y-pred pred -o report.html
evalsuite compare predictions.csv --y-true label --pred lr=pred_lr --pred rf=pred_rf \
--prob lr=p_lr --prob rf=p_rf --plot comparison.png
evalsuite plot roc predictions.csv --y-true label --y-prob prob -o roc.png
evalsuite diagnostic predictions.csv --y-true label --y-pred pred # sensitivity, LR+, DOR... with CIs
evalsuite calibration predictions.csv --y-true label --y-prob prob # slope, intercept, ECE, HL
evalsuite plot decision predictions.csv --y-true label --y-prob prob -o dca.png
evalsuite segmentation true_masks.npy pred_masks.npy --ignore-index 255 --plot per_class.png
evalsuite detection instances_val.json detections.json --plot pr_curves.png
evalsuite metrics --category clinical
evalsuite info classification.mcc
evalsuite benchmark --quick
Input files can be CSV, TSV, Parquet or JSON. Output format follows --format or the -o extension
(text, json, csv, markdown, latex, html). Errors are reported in one line with exit code 2.
Performance
Benchmarked against reference implementations on the same data (fastest of 5 runs; EvalSuite 0.7.1, Python 3.13,
NumPy 2.5, Linux x86_64). Overall: 81 of 81 rows agree with the reference (largest
difference 2.5e-14), 80 are faster (the other, the maintainability index, runs Python's own ast parser
like radon and lands at 0.89× on this run), and the geometric-mean speed-up across all
27 cases and three sizes is 4.30×. At 1,000,000 samples (pixels for
segmentation; 1,000 images for detection and 50 for Hausdorff; 10,000 examples for the LLM cases), in
alphabetical order: