Metrics¶
Agreement and correlation metrics for validating LLM judges against ground truth.
Overview¶
When your dataset includes ground truth labels, compute_metrics() measures how well your LLM judge agrees with human annotations. Metrics include accuracy, precision, recall, F1, Cohen's kappa, correlations, and systematic bias analysis.
For ensemble (multi-judge) evaluations, each per-criterion metrics object also reports inter-judge agreement (judges vs. each other, independent of ground truth). The recommended statistic is Krippendorff's alpha (krippendorff_alpha) — it handles unequal/missing raters and is level-aware (nominal vs. ordinal). Fleiss' kappa (fleiss_kappa) is also computed as the classic fixed-rater nominal measure, complete-case. Both are populated only with an ensemble of ≥2 judges and ≥2 items, and are None otherwise.
One inter-judge statistic on binary/nominal data
On binary and nominal data Krippendorff's nominal α and Fleiss' κ coincide up to a
finite-sample correction (1 − κ_F)/(N·R) — they are one statistic, not corroborating
evidence. summary() therefore reports α as the single primary inter-judge column
for binary/nominal criteria and drops the bare Fleiss column (a note explains the
omission); to_dataframe() leaves the binary/nominal fleiss_kappa value None. On
ordinal data α is distance-aware while Fleiss is nominal (different geometry), so
both are kept with a distinguishing note.
Research Background
Casabianca et al. (2025) recommend agreement metrics including ICC, Krippendorff's alpha, and quadratic-weighted kappa (QWK), with iterative refinement until agreement with human-labeled subsets is acceptable. He et al. (2025) emphasize that correlation alone can mask systematic bias.
Quick Example¶
from autorubric import RubricDataset, LLMConfig, evaluate
from autorubric.graders import CriterionGrader
dataset = RubricDataset.from_file("data_with_ground_truth.json")
grader = CriterionGrader(llm_config=LLMConfig(model="openai/gpt-4.1-mini"))
result = await evaluate(dataset, grader, show_progress=True)
# Compute metrics
metrics = result.compute_metrics(dataset)
# Formatted summary. The header names the handling modes
# (CANNOT_ASSESS / NA estimands), the criterion-level scalars carry their
# aggregation level (micro vs macro), and binary criteria show φ + FP/FN/FPR/FNR.
print(metrics.summary())
# verbose=True additionally prints the per-judge RMSE/Spearman columns and each
# judge's confusion matrix (the default per-judge line leads with accuracy + kappa + φ).
print(metrics.summary(verbose=True))
# Export options. to_dataframe() uses level-labelled aggregate keys
# (accuracy_micro / accuracy_macro / mean_kappa_macro / kappa_micro / phi_micro / ...)
# and round-trips the handling modes + coverage columns.
df = metrics.to_dataframe()
metrics.to_file("metrics.json")
Bootstrap Confidence Intervals¶
metrics = result.compute_metrics(
dataset,
bootstrap=True,
n_bootstrap=1000,
confidence_level=0.95,
seed=42,
)
print(metrics.summary())
# Bootstrap CIs (95%):
# Accuracy: [85.2%, 92.1%]
# Kappa: [0.712, 0.845]
Per-Judge Metrics (Ensemble)¶
metrics = result.compute_metrics(
dataset,
per_judge=True,
)
for judge_id, jm in metrics.per_judge.items():
# jm.criterion_accuracy is `float | None` (None when undefined); score_rmse is always a float.
acc = f"{jm.criterion_accuracy:.1%}" if jm.criterion_accuracy is not None else "n/a"
print(f"{judge_id}: Accuracy={acc}, RMSE={jm.score_rmse:.4f}")
Metric Fields¶
None means genuinely undefined, never a fabricated 0.0
The numeric metric fields below are typed float | None. A field is None
when the metric is genuinely undefined for the data at hand — it is never
silently reported as a fake 0.0. Always guard the format spec (e.g.
f"{x:.2f}" if x is not None else "n/a") before printing these.
| Field | Description |
|---|---|
criterion_accuracy |
Overall accuracy across all criteria. float | None — None when undefined (e.g. no paired predictions). |
criterion_precision |
Precision for the binary MET class. float | None — None when not applicable, e.g. a multi-choice-only rubric (no binary MET class). |
criterion_recall |
Recall for the binary MET class. float | None — None when not applicable (multi-choice-only rubric). |
criterion_f1 |
F1 for the binary MET class. float | None — None when not applicable (multi-choice-only rubric). |
mean_kappa |
Mean Cohen's kappa across criteria (macro — unweighted mean over criteria). float | None — None when undefined (e.g. degenerate single-class). |
macro_accuracy |
Unweighted mean of the per-criterion accuracies (macro). float | None. |
micro_kappa |
Cohen's kappa pooled across criteria (micro, distinct from the macro mean_kappa). float | None. |
criterion_phi |
Matthews correlation coefficient (φ) pooled over the binary MET-vs-rest flats (micro). float | None — None for a multi-choice-only rubric or on single-class data. φ = Pearson = Spearman = Kendall = MCC on binary data; the κ − φ gap is the judge's positive-rate drift. |
mean_krippendorff_alpha |
Macro mean of the per-criterion Krippendorff's α (inter-judge). float | None. |
cannot_assess_mode / na_mode |
How CANNOT_ASSESS / NA were handled when the metrics were computed (exclude / as_unmet / as_category). Frozen on the result and round-tripped by to_file so a serialized number is never ambiguous among the estimands. |
n_samples |
Total paired observations contributing to the aggregate metrics. int | None. |
coverage_stats |
Under the exclude mode, how much of the raw paired sample survived abstention/error exclusion (CoverageStats | None). Counts n_total (raw pre-exclusion denominator), n_covered (== per-criterion n_samples), and n_errored; rates coverage, judge_abstain_rate, gt_abstain_rate, union_exclusion_rate, error_rate are each float | None (None when n_total == 0). |
per_criterion |
Per-criterion metrics breakdown (polymorphic: CriterionMetrics, OrdinalCriterionMetrics, NominalCriterionMetrics). Their per-criterion numeric fields (accuracy, precision, recall, f1, kappa, weighted_kappa, adjacent_accuracy, per-option metrics) are likewise float | None when undefined. |
score_rmse |
RMSE of cumulative scores (always a float). |
score_mae |
MAE of cumulative scores (always a float). |
score_spearman |
Spearman rank correlation (CorrelationResult). Its .coefficient is float | None — None for a constant array or fewer than 3 samples. |
score_kendall |
Kendall tau correlation (CorrelationResult). .coefficient is float | None (None for a constant array or < 3 samples). |
score_pearson |
Pearson correlation (CorrelationResult). .coefficient is float | None (None for a constant array or < 3 samples). |
bias |
Systematic bias analysis (BiasResult). Its .mean_bias / .std_bias are float | None — mean_bias is None at n=0 and std_bias is None for n < 2. |
bootstrap |
Bootstrap confidence intervals (BootstrapResults, if enabled) |
per_judge |
Per-judge metrics for ensemble (dict[str, JudgeMetrics], if enabled) |
n_items |
Number of items used in computation |
n_criteria |
Number of criteria |
n_binary_criteria |
Number of binary criteria |
n_ordinal_criteria |
Number of ordinal multi-choice criteria |
n_nominal_criteria |
Number of nominal multi-choice criteria |
na_stats |
Statistics for NA handling in multi-choice criteria (NAStats): na_count_true / na_count_pred counts, na_kappa (float | None) on the {NA, not-NA} dichotomy, and na_false_positive / na_false_negative. |
cannot_assess_stats |
Statistics for CANNOT_ASSESS handling in binary criteria (CannotAssessStats) — the binary parallel of na_stats (a distinct kind of abstention; see below): ca_count_true / ca_count_pred counts, ca_kappa (float | None) on the {CANNOT_ASSESS, not-CANNOT_ASSESS} dichotomy, and ca_false_positive / ca_false_negative. |
warnings |
Any warnings generated during computation |
compute_metrics¶
Compute agreement metrics between predictions and ground truth.
compute_metrics
¶
compute_metrics(eval_result: EvalResult, dataset: RubricDataset, *, bootstrap: bool = False, n_bootstrap: int = 1000, per_judge: bool = False, cannot_assess: CannotAssessMode = 'exclude', na_mode: NAMode = 'exclude', confidence_level: float = 0.95, seed: int | None = None) -> MetricsResult
Compute comprehensive evaluation metrics.
This is the main entry point for computing metrics from an evaluation run. It compares predicted verdicts and scores against ground truth from the dataset. Supports binary, ordinal, and nominal (multi-choice) criteria.
| PARAMETER | DESCRIPTION |
|---|---|
eval_result
|
The evaluation result from EvalRunner.
TYPE:
|
dataset
|
The dataset with ground truth labels.
TYPE:
|
bootstrap
|
If True, compute bootstrap confidence intervals (expensive). Covers ANY
rubric type via an item-level resample:
TYPE:
|
n_bootstrap
|
Number of bootstrap samples if bootstrap=True.
TYPE:
|
per_judge
|
If True and ensemble, compute per-judge metrics.
TYPE:
|
cannot_assess
|
How to handle CANNOT_ASSESS verdicts (binary criteria): - "exclude": Skip pairs where either is CANNOT_ASSESS (default) - "as_unmet": Treat CANNOT_ASSESS as UNMET - "as_category": Keep CANNOT_ASSESS as a distinct third class. Accuracy and Cohen's kappa are then computed over three classes (a CANNOT_ASSESS prediction matching a CANNOT_ASSESS ground truth counts as correct); precision/recall/f1 remain MET-vs-rest.
TYPE:
|
na_mode
|
How to handle NA options (multi-choice criteria). Mirrors
TYPE:
|
confidence_level
|
Confidence level for bootstrap CIs (default 0.95).
TYPE:
|
seed
|
Random seed for bootstrap reproducibility.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
MetricsResult
|
MetricsResult with comprehensive metrics and optional per-judge breakdown. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If no common items between eval_result and dataset. |
Example
result = await evaluate(dataset, grader) metrics = result.compute_metrics(dataset) print(metrics.summary()) df = metrics.to_dataframe()
Source code in src/autorubric/metrics/_compute.py
1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 | |
MetricsResult¶
Complete metrics result with aggregate and per-criterion breakdowns.
MetricsResult
¶
Bases: BaseModel
Complete metrics result from compute_metrics().
This is the main result type returned by EvalResult.compute_metrics(). It provides a comprehensive view of evaluation quality including: - Criterion-level agreement metrics - Score-level correlation and error metrics - Per-criterion breakdown (supports binary, ordinal, and nominal criteria) - Optional bootstrap confidence intervals - Optional per-judge metrics for ensemble evaluations
| ATTRIBUTE | DESCRIPTION |
|---|---|
criterion_accuracy |
Overall accuracy across all criteria (binary label accuracy
and/or multi-choice exact-match).
TYPE:
|
criterion_precision |
Overall precision for the binary MET class.
TYPE:
|
criterion_recall |
Overall recall for the binary MET class.
TYPE:
|
criterion_f1 |
Overall F1 for the binary MET class.
TYPE:
|
mean_kappa |
Mean kappa across criteria (weighted for ordinal, unweighted for
binary/nominal).
TYPE:
|
per_criterion |
Per-criterion metrics breakdown (polymorphic union type).
TYPE:
|
score_rmse |
RMSE of cumulative scores.
TYPE:
|
score_mae |
MAE of cumulative scores.
TYPE:
|
score_spearman |
Spearman correlation result.
TYPE:
|
score_kendall |
Kendall tau correlation result.
TYPE:
|
score_pearson |
Pearson correlation result.
TYPE:
|
bias |
Systematic bias analysis.
TYPE:
|
bootstrap |
Optional bootstrap confidence intervals.
TYPE:
|
per_judge |
Optional per-judge metrics for ensemble.
TYPE:
|
n_items |
Number of items used in computation.
TYPE:
|
n_criteria |
Number of criteria.
TYPE:
|
n_binary_criteria |
Number of binary criteria (default 0 for backwards compat).
TYPE:
|
n_ordinal_criteria |
Number of ordinal multi-choice criteria.
TYPE:
|
n_nominal_criteria |
Number of nominal multi-choice criteria.
TYPE:
|
na_stats |
Statistics for NA handling in multi-choice criteria.
TYPE:
|
cannot_assess_stats |
Statistics for CANNOT_ASSESS handling in binary criteria —
the binary parallel to
TYPE:
|
cannot_assess_mode |
How binary CANNOT_ASSESS verdicts were handled when these metrics
were computed (
TYPE:
|
na_mode |
How multi-choice NA options were handled when these metrics were computed
(the multi-choice analog of
TYPE:
|
n_samples |
Total number of paired observations contributing to the aggregate metrics.
TYPE:
|
mean_krippendorff_alpha |
Macro mean of the per-criterion Krippendorff's alpha.
TYPE:
|
criterion_phi |
Aggregate (micro) Matthews correlation coefficient (φ) over the pooled
binary {MET, UNMET} flats.
TYPE:
|
macro_accuracy |
Unweighted mean of the per-criterion accuracies.
TYPE:
|
micro_kappa |
Aggregate (micro) Cohen's kappa pooled across criteria.
TYPE:
|
coverage_stats |
Aggregate rollup of how much of the raw paired sample survived
abstention/error exclusion. Only populated under the
TYPE:
|
warnings |
Any warnings generated during computation.
TYPE:
|
summary
¶
Return formatted text summary of metrics.
| PARAMETER | DESCRIPTION |
|---|---|
verbose
|
When
TYPE:
|
Source code in src/autorubric/metrics/_types.py
1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 | |
to_dataframe
¶
Export metrics to pandas DataFrame.
Returns a flat DataFrame with a 'level' column indicating 'aggregate' / 'criterion'
/ 'judge'. The criterion-level scalars carry their aggregation level in the
column name: accuracy_micro / precision_micro / recall_micro /
f1_micro / kappa_micro / phi_micro are pooled over decisions, while
accuracy_macro and mean_kappa_macro are unweighted means over criteria (the
former bare accuracy / precision / recall / f1 / kappa columns
are gone — they mixed levels). The handling modes (cannot_assess_mode /
na_mode) and n_samples round-trip on the aggregate row, alongside coverage
columns (coverage / judge_abstain_rate / gt_abstain_rate /
union_exclusion_rate / n_errored / error_rate; None outside exclude
mode). On binary/nominal data Krippendorff's α equals Fleiss' κ up to a
finite-sample correction, so α is the single primary inter-judge column and the bare
fleiss_kappa value is emitted only for ordinal criteria (different geometry).
Source code in src/autorubric/metrics/_types.py
1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 | |
to_file
¶
Save metrics to a JSON file.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
Path to the output JSON file.
TYPE:
|
Source code in src/autorubric/metrics/_types.py
CriterionMetrics¶
Per-criterion binary metrics.
CriterionMetrics
¶
Bases: BaseModel
Metrics for a single binary criterion.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
Name of the criterion.
TYPE:
|
index |
Index of the criterion in the rubric.
TYPE:
|
criterion_type |
Type of criterion ("binary" for this class).
TYPE:
|
n_samples |
Number of samples used for this criterion.
TYPE:
|
accuracy |
Binary accuracy (proportion of exact matches). None when undefined / no samples.
TYPE:
|
precision |
Precision for MET class. None when undefined / no samples.
TYPE:
|
recall |
Recall for MET class. None when undefined / no samples.
TYPE:
|
f1 |
F1 score for MET class. None when undefined / no samples.
TYPE:
|
kappa |
Cohen's kappa coefficient. None when undefined (degenerate single-class) / no samples.
TYPE:
|
kappa_interpretation |
Human-readable interpretation of kappa ("undefined" when kappa is None).
TYPE:
|
krippendorff_alpha |
Krippendorff's alpha — the general, recommended inter-judge agreement statistic. It natively handles unequal/missing raters (errored or excluded votes) and is level-aware (nominal for binary criteria). None unless this is an ensemble with >=2 judges and >=2 items.
TYPE:
|
fleiss_kappa |
Fleiss' kappa — the classic fixed-rater nominal inter-judge agreement
measure, computed complete-case (only items where every judge cast a genuine
counted vote contribute). Prefer
TYPE:
|
support_true |
Count of MET in ground truth.
TYPE:
|
support_pred |
Count of MET in predictions.
TYPE:
|
confusion_matrix |
2×2 labelled confusion matrix (
TYPE:
|
fpr |
False-positive rate (true UNMET predicted MET).
TYPE:
|
fnr |
False-negative rate (true MET predicted UNMET).
TYPE:
|
phi |
Matthews correlation coefficient (the φ coefficient) on the {MET, UNMET}
dichotomy.
TYPE:
|
is_degenerate |
True iff this criterion had samples (
TYPE:
|
coverage_stats |
How much of the raw paired sample survived abstention/error
exclusion. Only populated under the
TYPE:
|
CorrelationResult¶
Correlation statistics between predicted and ground truth scores.
CorrelationResult
¶
Bases: BaseModel
Result from correlation calculation (Spearman, Kendall, Pearson).
| ATTRIBUTE | DESCRIPTION |
|---|---|
coefficient |
The correlation coefficient (-1 to 1).
TYPE:
|
p_value |
P-value for testing the null hypothesis of no correlation.
TYPE:
|
ci |
Optional confidence interval for the coefficient.
TYPE:
|
interpretation |
Human-readable interpretation ("undefined" for a constant/NaN array, "insufficient data" for <3 samples).
TYPE:
|
n_samples |
Number of samples used in calculation.
TYPE:
|
method |
Correlation method used (e.g., "spearman", "kendall", "pearson").
TYPE:
|
interpret_correlation
staticmethod
¶
Return human-readable interpretation of correlation coefficient.
Source code in src/autorubric/metrics/_types.py
BootstrapResults¶
Bootstrap confidence intervals for key metrics.
BootstrapResults
¶
Bases: BaseModel
Bootstrap confidence interval results.
The three CIs are MARGINAL — bootstrapped on two independent item-level resample axes (a verdict-item axis for accuracy/kappa, an independent scored-item axis for RMSE), so they reflect each statistic's own sampling distribution, not their joint covariance. Covers any rubric type (binary / multi-choice / mixed).
| ATTRIBUTE | DESCRIPTION |
|---|---|
accuracy_ci |
95% CI for
TYPE:
|
kappa_ci |
95% CI for
TYPE:
|
rmse_ci |
95% CI for
TYPE:
|
n_bootstrap |
Number of bootstrap samples used.
TYPE:
|
confidence_level |
Confidence level (default 0.95).
TYPE:
|
BootstrapResult¶
Single bootstrap result with confidence interval.
BootstrapResult
¶
Bases: BaseModel
Bootstrap confidence interval result.
| ATTRIBUTE | DESCRIPTION |
|---|---|
estimate |
Point estimate of the statistic.
TYPE:
|
ci |
Confidence interval from bootstrap.
TYPE:
|
standard_error |
Bootstrap standard error.
TYPE:
|
n_bootstrap |
Number of bootstrap samples used.
TYPE:
|
bootstrap_distribution |
Optional array of bootstrap estimates.
TYPE:
|
ConfidenceInterval¶
Confidence interval bounds.
ConfidenceInterval
¶
Bases: BaseModel
Confidence interval for a statistic.
| ATTRIBUTE | DESCRIPTION |
|---|---|
lower |
Lower bound of the interval.
TYPE:
|
upper |
Upper bound of the interval.
TYPE:
|
confidence |
Confidence level (default 0.95 for 95% CI).
TYPE:
|
method |
Method used to compute the interval.
TYPE:
|
JudgeMetrics¶
Per-judge metrics for ensemble evaluations.
JudgeMetrics
¶
Bases: BaseModel
Metrics for a single judge in an ensemble.
Mirrors the aggregate's type handling field-for-field: precision/recall/f1 are the
binary MET-vs-rest metric → None for a multi-choice-only rubric (no MET class),
and accuracy/mean_kappa generalize but are None when undefined.
| ATTRIBUTE | DESCRIPTION |
|---|---|
judge_id |
Identifier for this judge.
TYPE:
|
criterion_accuracy |
Overall criterion-level accuracy (binary label and/or
multi-choice exact-match).
TYPE:
|
criterion_precision |
Overall precision for the binary MET class.
TYPE:
|
criterion_recall |
Overall recall for the binary MET class.
TYPE:
|
criterion_f1 |
Overall F1 for the binary MET class.
TYPE:
|
mean_kappa |
Mean Cohen's kappa across criteria.
TYPE:
|
phi |
Matthews correlation coefficient (φ) for this judge on the binary {MET, UNMET}
dichotomy, pooled across criteria.
TYPE:
|
confusion_matrix |
This judge's confusion matrix, aggregated across criteria from the
raw pre-filter codes (binary MET/UNMET with an abstain
TYPE:
|
score_rmse |
RMSE of cumulative scores.
TYPE:
|
score_mae |
MAE of cumulative scores.
TYPE:
|
score_spearman |
Spearman correlation result.
TYPE:
|
score_kendall |
Kendall tau correlation result.
TYPE:
|
score_pearson |
Pearson correlation result.
TYPE:
|
bias |
Systematic bias analysis result.
TYPE:
|
BiasResult¶
Systematic bias analysis between predicted and ground truth scores.
BiasResult
¶
Bases: BaseModel
Result from systematic bias analysis.
Systematic bias occurs when one rater consistently scores higher or lower than another, independent of the item being rated.
A statistic is None when it is genuinely undefined for the sample size, never a
fake 0.0. mean_bias is the single pred−true difference at n=1 (computable) and
is None only at n=0. std_bias is None when undefined (n<2). effect_size
(Cohen's d) is None when std_bias is 0 or undefined.
| ATTRIBUTE | DESCRIPTION |
|---|---|
mean_bias |
Mean difference (predictions - actuals).
TYPE:
|
std_bias |
Standard deviation of differences.
TYPE:
|
is_significant |
Whether the bias is statistically significant (p < 0.05).
TYPE:
|
p_value |
P-value from t-test.
TYPE:
|
direction |
Direction of bias ("positive" if predictions > actuals).
TYPE:
|
effect_size |
Cohen's d effect size.
TYPE:
|
ci |
Confidence interval for mean bias.
TYPE:
|
n_samples |
Number of samples.
TYPE:
|
interpret_effect_size
staticmethod
¶
Interpret effect size using Cohen's guidelines.
Source code in src/autorubric/metrics/_types.py
OrdinalCriterionMetrics¶
Per-criterion metrics for ordinal multi-choice criteria.
OrdinalCriterionMetrics
¶
Bases: BaseModel
Metrics for an ordinal multi-choice criterion.
Ordinal criteria have options with inherent ordering (e.g., satisfaction 1-4). This enables additional metrics like weighted kappa and rank correlations.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
Name of the criterion.
TYPE:
|
index |
Index of the criterion in the rubric.
TYPE:
|
criterion_type |
Type of criterion ("ordinal" for this class).
TYPE:
|
n_samples |
Number of samples used in computation.
TYPE:
|
n_options |
Number of options in this criterion.
TYPE:
|
exact_accuracy |
Proportion of exact index matches. None when undefined / no samples.
TYPE:
|
adjacent_accuracy |
Proportion within +/-1 position. None when undefined / no samples.
TYPE:
|
weighted_kappa |
Quadratic-weighted Cohen's kappa (accounts for distance). None when undefined (degenerate single-class) / no samples.
TYPE:
|
kappa_interpretation |
Human-readable interpretation of kappa ("undefined" when weighted_kappa is None).
TYPE:
|
krippendorff_alpha |
Krippendorff's alpha — the general, recommended inter-judge
agreement statistic. Computed with
TYPE:
|
fleiss_kappa |
Fleiss' kappa — the classic fixed-rater nominal measure (ignores
ordering), computed complete-case. Prefer
TYPE:
|
spearman |
Spearman rank correlation result.
TYPE:
|
kendall |
Kendall tau correlation result.
TYPE:
|
rmse |
RMSE on option values (0-1 scale). None when undefined / no samples.
TYPE:
|
mae |
MAE on option values (0-1 scale). None when undefined / no samples.
TYPE:
|
per_option |
Per-option precision/recall/F1 breakdown.
TYPE:
|
confusion_matrix |
N×N labelled confusion matrix (rows=true, cols=pred); its
TYPE:
|
is_degenerate |
True iff this criterion had samples (
TYPE:
|
coverage_stats |
How much of the raw paired sample survived abstention/error
exclusion. Only populated under the
TYPE:
|
NominalCriterionMetrics¶
Per-criterion metrics for nominal multi-choice criteria.
NominalCriterionMetrics
¶
Bases: BaseModel
Metrics for a nominal multi-choice criterion.
Nominal criteria have unordered categories (e.g., "too few", "just right", "too many"). Distance between options is not meaningful, so only exact matches matter.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
Name of the criterion.
TYPE:
|
index |
Index of the criterion in the rubric.
TYPE:
|
criterion_type |
Type of criterion ("nominal" for this class).
TYPE:
|
n_samples |
Number of samples used in computation.
TYPE:
|
n_options |
Number of options in this criterion.
TYPE:
|
exact_accuracy |
Proportion of exact index matches. None when undefined / no samples.
TYPE:
|
kappa |
Unweighted Cohen's kappa (N×N). None when undefined (degenerate single-class) / no samples.
TYPE:
|
kappa_interpretation |
Human-readable interpretation of kappa ("undefined" when kappa is None).
TYPE:
|
krippendorff_alpha |
Krippendorff's alpha — the general, recommended inter-judge
agreement statistic. Computed with
TYPE:
|
fleiss_kappa |
Fleiss' kappa — the classic fixed-rater nominal measure, computed
complete-case. Prefer
TYPE:
|
per_option |
Per-option precision/recall/F1 breakdown.
TYPE:
|
confusion_matrix |
N×N labelled confusion matrix (rows=true, cols=pred); its
TYPE:
|
is_degenerate |
True iff this criterion had samples (
TYPE:
|
coverage_stats |
How much of the raw paired sample survived abstention/error
exclusion. Only populated under the
TYPE:
|
NAStats¶
Statistics for NA (not applicable) handling in multi-choice criteria.
NAStats
¶
Bases: BaseModel
Statistics for NA (not applicable) handling in multi-choice criteria.
Tracks how the prediction and ground truth agree on the dichotomized {NA, not-NA} decision per item, similar to how CANNOT_ASSESS is handled for binary criteria.
| ATTRIBUTE | DESCRIPTION |
|---|---|
na_count_true |
Number of NA selections in ground truth.
TYPE:
|
na_count_pred |
Number of NA selections in predictions.
TYPE:
|
na_kappa |
Cohen's kappa on the {NA, not-NA} dichotomy (pred vs truth).
Range [-1, 1]; 1.0 is perfect agreement, 0 is chance-level, negative is
worse than chance. None when undefined (no paired NA observations,
single class, or NaN). The framework reports prediction-vs-ground-truth
categorical agreement as Cohen's kappa across the board (binary
TYPE:
|
na_kappa_interpretation |
Landis & Koch interpretation of
TYPE:
|
na_false_positive |
Count where prediction was NA but ground truth was not.
TYPE:
|
na_false_negative |
Count where ground truth was NA but prediction was not.
TYPE:
|
CannotAssessStats¶
Statistics for CANNOT_ASSESS handling in binary criteria — the binary parallel of NAStats. Both are abstentions that flow through the same SKIP scoring path and get a dichotomized Cohen's-kappa diagnostic, but they are tracked as distinct types: CANNOT_ASSESS is an epistemic abstention on a yes/no decision ("I cannot determine MET vs. UNMET"), while multi-choice NA is "no applicable option" (a statement about the option space). Its fields are ca_-prefixed: ca_count_true, ca_count_pred, ca_kappa (float | None), ca_kappa_interpretation, ca_false_positive, ca_false_negative.
CannotAssessStats
¶
Bases: BaseModel
Statistics for CANNOT_ASSESS handling in binary criteria.
The binary parallel of :class:NAStats: tracks how the prediction and ground truth
agree on the dichotomized {CANNOT_ASSESS, not-CANNOT_ASSESS} decision per item.
Both CANNOT_ASSESS (binary) and NA (multi-choice) are abstentions that flow through
the same SKIP scoring path (score_reports), and both get a parallel dichotomized
Cohen's-kappa diagnostic block. They are nonetheless distinct kinds of abstention,
which is exactly why they are tracked by separate stats types rather than merged:
- Binary CANNOT_ASSESS is the judge being unable to determine MET-vs-UNMET — an epistemic abstention on a yes/no question ("I cannot decide whether this requirement is met").
- Multi-choice NA is "not applicable / cannot pick an applicable option" — abstaining because no scored category fits, a statement about the option space rather than a yes/no decision.
Keeping them separate (and prefixing these fields ca_) makes the semantic
distinction explicit in the data model while preserving the structural analogy.
| ATTRIBUTE | DESCRIPTION |
|---|---|
ca_count_true |
Number of CANNOT_ASSESS verdicts in ground truth.
TYPE:
|
ca_count_pred |
Number of CANNOT_ASSESS verdicts in predictions.
TYPE:
|
ca_kappa |
Cohen's kappa on the {CANNOT_ASSESS, not-CANNOT_ASSESS} dichotomy
(pred vs truth). Range [-1, 1]; 1.0 is perfect agreement, 0 is chance-level,
negative is worse than chance. None when undefined (no paired CANNOT_ASSESS
observations, single class, or NaN). The framework reports
prediction-vs-ground-truth categorical agreement as Cohen's kappa across the
board (binary
TYPE:
|
ca_kappa_interpretation |
Landis & Koch interpretation of
TYPE:
|
ca_false_positive |
Count where prediction was CANNOT_ASSESS but ground truth was not.
TYPE:
|
ca_false_negative |
Count where ground truth was CANNOT_ASSESS but prediction was not.
TYPE:
|
CoverageStats¶
How much of the raw paired sample survived abstention/error exclusion. Built only under the exclude handling mode (under as_unmet / as_category no observation is dropped, so coverage would be trivially 1.0 and these stats are left None). n_total is the raw pre-exclusion denominator and n_covered equals the per-criterion n_samples; every rate (coverage, judge_abstain_rate, gt_abstain_rate, union_exclusion_rate, error_rate) is float | None, None when its denominator is zero.
CoverageStats
¶
Bases: BaseModel
How much of the raw paired sample survived abstention/error exclusion.
Built only under the exclude handling mode, where abstentions (CANNOT_ASSESS / NA) and
grading errors drop a paired observation from the agreement denominator. Under as_unmet
or as_category no observation is dropped, so coverage would be trivially 1.0 and
these stats are not produced (left None by callers).
n_total is the raw pre-exclusion denominator; n_covered is what remained after the
union of all exclusion reasons (it equals the per-criterion n_samples). Every rate
honours undefined→None (None when its denominator is zero); counts stay int.
| ATTRIBUTE | DESCRIPTION |
|---|---|
n_total |
Raw pre-exclusion paired count (the denominator before any drops).
TYPE:
|
n_covered |
Paired count remaining after union-exclusion (== per-criterion
TYPE:
|
coverage |
TYPE:
|
judge_abstain_rate |
Fraction of the raw pairs where the judge/prediction abstained.
None when
TYPE:
|
gt_abstain_rate |
Fraction of the raw pairs where the ground truth abstained. None when
TYPE:
|
union_exclusion_rate |
Fraction excluded for any reason (
TYPE:
|
n_errored |
Count of paired observations dropped because grading errored.
TYPE:
|
error_rate |
TYPE:
|
References¶
Casabianca, J., McCaffrey, D. F., Johnson, M. S., Alper, N., and Zubenko, V. (2025). Validity Arguments For Constructed Response Scoring Using Generative Artificial Intelligence Applications. arXiv:2501.02334.
He, J., Shi, J., Zhuo, T. Y., Treude, C., Sun, J., Xing, Z., Du, X., and Lo, D. (2025). LLM-as-a-Judge for Software Engineering: Literature Review, Vision, and the Road Ahead. arXiv:2510.24367.