HEvaluate predictions · evaluate.verification
Evaluate verification scores (EER, DCF, DET)
How well do a system's scores tell same-source trials from different-source ones, and what do its errors cost?
Scores a verification system from its trials: each row compares two items (two voices, a claim and a recording) and has a score that should be high when both come from the same source. Reports the equal error rate, the minimum and actual detection cost at a stated prior and costs, Cllr for calibrated log-likelihood ratios, the detection error tradeoff (DET) curve and the miss rate at fixed false alarm rates, with intervals from resampling trials and a breakdown by condition.
A real result
Example “Cosine default”, recorded in both engines. In the app, “Try this example” loads it into Analyze.
On 120 target and 480 non-target trials, the equal error rate was 2.50% (95% CI 1.25% to 3.75%) and the minimum detection cost 0.308 at π = 0.01, C_miss = 1, C_fa = 1.
- EER
- 2.5%
- Minimum DCF
- 0.3083
- Miss rate at 1% false alarms
- 14.2%
Plots
View data
| Miss rate (false rejects) | False alarm rate (false accepts) | Trials |
|---|---|---|
| 0 | 1 | All trials |
| 0 | 0.9979 | All trials |
| 0 | 0.9958 | All trials |
| 0 | 0.9938 | All trials |
| 0 | 0.9917 | All trials |
| 0 | 0.9896 | All trials |
| 0 | 0.9875 | All trials |
| 0 | 0.9854 | All trials |
| 0 | 0.9833 | All trials |
| 0 | 0.9812 | All trials |
| 0 | 0.9792 | All trials |
| 0 | 0.9771 | All trials |
| 0 | 0.9750 | All trials |
| 0 | 0.9729 | All trials |
| 0 | 0.9708 | All trials |
| 0 | 0.9667 | All trials |
| 0 | 0.9646 | All trials |
| 0 | 0.9625 | All trials |
| 0 | 0.9604 | All trials |
| 0 | 0.9583 | All trials |
| 0 | 0.9542 | All trials |
| 0 | 0.9521 | All trials |
| 0 | 0.9500 | All trials |
| 0 | 0.9479 | All trials |
| 0 | 0.9458 | All trials |
| 0 | 0.9437 | All trials |
| 0 | 0.9417 | All trials |
| 0 | 0.9396 | All trials |
| 0 | 0.9375 | All trials |
| 0 | 0.9333 | All trials |
| 0 | 0.9292 | All trials |
| 0 | 0.9229 | All trials |
| 0 | 0.9208 | All trials |
| 0 | 0.9187 | All trials |
| 0 | 0.9167 | All trials |
| 0 | 0.9146 | All trials |
| 0 | 0.9125 | All trials |
| 0 | 0.9104 | All trials |
| 0 | 0.9083 | All trials |
| 0 | 0.9063 | All trials |
| 0 | 0.9042 | All trials |
| 0 | 0.9021 | All trials |
| 0 | 0.9000 | All trials |
| 0 | 0.8979 | All trials |
| 0 | 0.8958 | All trials |
| 0 | 0.8917 | All trials |
| 0 | 0.8875 | All trials |
| 0 | 0.8833 | All trials |
| 0 | 0.8812 | All trials |
| 0 | 0.8792 | All trials |
| 0 | 0.8771 | All trials |
| 0 | 0.8729 | All trials |
| 0 | 0.8708 | All trials |
| 0 | 0.8667 | All trials |
| 0 | 0.8646 | All trials |
| 0 | 0.8625 | All trials |
| 0 | 0.8604 | All trials |
| 0 | 0.8562 | All trials |
| 0 | 0.8521 | All trials |
| 0 | 0.8500 | All trials |
First 60 of 393 rows.
View data
| Trial | cosine |
|---|---|
| Non-target | 0.2010 |
| Non-target | 0.3850 |
| Non-target | 0.3840 |
| Non-target | 0.2920 |
| Non-target | 0.1320 |
| Target | 0.7800 |
| Non-target | 0.0460 |
| Non-target | 0.2990 |
| Non-target | 0.1560 |
| Target | 0.5810 |
| Non-target | 0.1420 |
| Target | 0.7880 |
| Non-target | 0.2190 |
| Non-target | 0.3400 |
| Target | 0.6650 |
| Non-target | 0.1770 |
| Non-target | 0.2680 |
| Non-target | 0.1140 |
| Non-target | 0.1120 |
| Non-target | 0.1060 |
| Non-target | 0.0700 |
| Non-target | 0.1600 |
| Non-target | 0.0750 |
| Target | 0.5230 |
| Target | 0.7550 |
| Non-target | 0.1600 |
| Non-target | 0.0440 |
| Non-target | 0.2420 |
| Non-target | 0.2490 |
| Non-target | 0.1260 |
| Non-target | 0.2680 |
| Non-target | 0.2330 |
| Non-target | 0.1860 |
| Non-target | 0.2620 |
| Target | 0.7300 |
| Target | 0.6190 |
| Non-target | 0.0450 |
| Non-target | 0.1300 |
| Non-target | 0.1830 |
| Non-target | 0.1420 |
| Target | 0.6450 |
| Non-target | 0.3110 |
| Non-target | 0.2200 |
| Non-target | 0.2510 |
| Non-target | 0.2220 |
| Non-target | 0.4550 |
| Non-target | 0.2000 |
| Non-target | 0.2160 |
| Target | 0.7740 |
| Target | 0.5580 |
| Target | 0.7230 |
| Target | 0.8650 |
| Non-target | 0.2250 |
| Non-target | 0.1050 |
| Non-target | 0.2870 |
| Target | 0.5110 |
| Non-target | 0.1620 |
| Non-target | 0.1110 |
| Non-target | 0.1560 |
| Non-target | 0.0790 |
First 60 of 600 rows.
Assumptions
- Scores come from a fixed system — Fix the system and any threshold before scoring these trials. The minimum DCF picks its threshold on them, so it is optimistic; the actual DCF uses a threshold fixed in advance.
- Trials are not independent — Trials that share a speaker or item are correlated, so intervals from resampling trials are narrower than a resampling of speakers would give.
- Enough errors at the EER — About 3 misses and 12 false alarms at the EER; with fewer than 30 of either the rates are rough (Doddington's rule of 30).
Verification metrics (95% intervals from resampling trials)
| Measure | Value | 95% CI low | 95% CI high | Threshold | False alarm rate | Miss rate |
|---|---|---|---|---|---|---|
| Equal error rate (EER) | 0.0250 | 0.0125 | 0.0375 | 0.4360 | 0.0250 | 0.0250 |
| Minimum DCF (threshold picked on these trials) | 0.3083 | 0.1167 | 0.3896 | 0.5620 | 0 | 0.3083 |
Miss rate at fixed false alarm rates
| False alarm rate at most | Miss rate | Threshold |
|---|---|---|
| 0.0010 | 0.3083 | 0.5620 |
| 0.0100 | 0.1417 | 0.5020 |
| 0.0500 | 0.0083 | 0.3890 |
| 0.1000 | 0 | 0.3360 |
- A trial is accepted when cosine ≥ the threshold; target trials: same = true. EER: linear interpolation on the operating points. DCF = C_miss·π·miss rate + C_fa·(1 − π)·false alarm rate, normalized by min(C_miss·π, C_fa·(1 − π)); π = 0.01. Intervals: 1000 resamples of trials within each class on the shared seeded stream (seed 42).
On 120 target and 480 non-target trials, the equal error rate was 2.50% (95% CI 1.25% to 3.75%) and the minimum detection cost 0.308 at π = 0.01, C_miss = 1, C_fa = 1.
- EER
- 2.5%
- Minimum DCF
- 0.3083
- Miss rate at 1% false alarms
- 14.2%
To keep this page light, the plots are shown once, under the R tab.
Assumptions
- Scores come from a fixed system — Fix the system and any threshold before scoring these trials. The minimum DCF picks its threshold on them, so it is optimistic; the actual DCF uses a threshold fixed in advance.
- Trials are not independent — Trials that share a speaker or item are correlated, so intervals from resampling trials are narrower than a resampling of speakers would give.
- Enough errors at the EER — About 3 misses and 12 false alarms at the EER; with fewer than 30 of either the rates are rough (Doddington's rule of 30).
Verification metrics (95% intervals from resampling trials)
| Measure | Value | 95% CI low | 95% CI high | Threshold | False alarm rate | Miss rate |
|---|---|---|---|---|---|---|
| Equal error rate (EER) | 0.0250 | 0.0125 | 0.0375 | 0.4360 | 0.0250 | 0.0250 |
| Minimum DCF (threshold picked on these trials) | 0.3083 | 0.1167 | 0.3896 | 0.5620 | 0 | 0.3083 |
Miss rate at fixed false alarm rates
| False alarm rate at most | Miss rate | Threshold |
|---|---|---|
| 0.0010 | 0.3083 | 0.5620 |
| 0.0100 | 0.1417 | 0.5020 |
| 0.0500 | 0.0083 | 0.3890 |
| 0.1000 | 0 | 0.3360 |
- A trial is accepted when cosine ≥ the threshold; target trials: same = true. EER: linear interpolation on the operating points. DCF = C_miss·π·miss rate + C_fa·(1 − π)·false alarm rate, normalized by min(C_miss·π, C_fa·(1 − π)); π = 0.01. Intervals: 1000 resamples of trials within each class on the shared seeded stream (seed 42).
Do it in CodeSplash Run it on your own data, in Python or R, with the code to prove it.
Worked examples in the app
- Cosine defaultaud3_trials · label: same · score: cosine
- Cosine groups rocchaud3_trials · group: channel · label: same · score: cosine
- Llr calibratedaud3_trials · label: trial · score: llr
- Fixed threshold empirical prioraud3_trials · label: same · score: cosine
- Perfect separationaud3_trials · label: same · score: perfect
- Degenerate constantaud3_trials · label: same · score: cosine
- Degenerate tiesaud3_trials · label: same · score: cosine
- Degenerate single levelaud3_trials · label: trial · score: cosine
In the guides
Where it sits in the decision guides
- Multimodal data exploration (text, image, video) · DS & ML Decision Guide · Describe — summarize and visualize
- Predict: regression MAE, RMSE, R²; classification accuracy, precision, recall, F1, AUC; calibration, lift, log loss · DS & ML Decision Guide · How to evaluate — common metrics by question type
What you need
- Trial scorenumeric · 1 column
- The system's score for each trial; higher means "more likely the same source" (a cosine similarity or a log-likelihood ratio).
- Same source?categorical / boolean · 1 column · 2–2 levels
- Whether each trial really is a same-source (target) trial; two levels.
- Condition (optional)categorical / boolean · 0–1 column · 1–20 levels
- A condition such as channel, language or gender; the EER and minimum DCF are shown for each one too.
Choices you make
hypothesis
- Same-source leveldefault —
The level that marks target (same-source) trials; default the last stored level (true for true/false columns).
- Target prior (π)default 0.01
How often a trial is a target trial in the use you care about; it weights misses against false alarms in the cost (NIST SRE uses 0.01).
- Cost of a missdefault 1
The cost of rejecting a true same-source trial (a false reject).
- Cost of a false alarmdefault 1
The cost of accepting a different-source trial (a false accept).
- Confidence leveldefault 0.95
How sure the intervals should be: 0.95 gives 95% confidence intervals. Higher confidence means wider intervals.
options
- Equal error ratedefault linear
How the equal error rate is read between operating points.
- Linear interpolation(default) — Where the two error rates cross on the operating points (scikit-learn's det_curve points; ML Studio's convention).
- ROC convex hull — The crossing on the ROC convex hull (BOSARIS and NIST); never above the linear value.
- Scores are calibrated log-likelihood ratiosdefault off
Reads scores as natural-log likelihood ratios: the actual cost uses the Bayes threshold and Cllr is reported.
- Fixed decision thresholddefault —
A threshold set before seeing these trials; the actual cost uses it. Ignored when scores are log-likelihood ratios.
statistics
- Trial resamplesdefault 1000
Bootstrap resamples of trials (within targets and non-targets) for the intervals.
Checks and remedies
CodeSplash checks each testable assumption on every run and shows the result on the card; premises the data can’t test are marked. If a check fails, these are the ways forward.
Scores come from a fixed systemNot checked from data: state why it holds
Fix the system and any threshold before scoring these trials; the minimum DCF still picks its threshold on them, so it is optimistic.
Trials are not independentNot checked from data: state why it holds
Trials that share a speaker or item are correlated, so intervals from resampling trials are narrower than they should be.
Enough errors at the EER
Doddington's rule of 30: with fewer than 30 misses or 30 false alarms at the operating point, the error rates are rough.
What it reports
- n
- One comparison of two items (two voices, a claim and a recording) with a score; a target trial is a real match.
- n_target
- One comparison of two items (two voices, a claim and a recording) with a score; a target trial is a real match.
- n_nontarget
- One comparison of two items (two voices, a claim and a recording) with a score; a target trial is a real match.
- target_level
- One comparison of two items (two voices, a claim and a recording) with a score; a target trial is a real match.
- p_target
- Misses and false alarms weighted by their costs and the target prior π, normalized so 1 is accepting or rejecting all.
- c_miss
- Misses and false alarms weighted by their costs and the target prior π, normalized so 1 is accepting or rejecting all.
- c_fa
- Misses and false alarms weighted by their costs and the target prior π, normalized so 1 is accepting or rejecting all.
- eer_method
- The EER read on the ROC convex hull (NIST, BOSARIS); never above the EER interpolated between operating points.
- eer
- Where misses and false alarms are equally common, with a bootstrap interval and the score threshold nearest the crossing.
- eer_low
- Where misses and false alarms are equally common, with a bootstrap interval and the score threshold nearest the crossing.
- eer_high
- Where misses and false alarms are equally common, with a bootstrap interval and the score threshold nearest the crossing.
- eer_threshold
- Where misses and false alarms are equally common, with a bootstrap interval and the score threshold nearest the crossing.
- min_dcf
- Misses and false alarms weighted by their costs and the target prior π, normalized so 1 is accepting or rejecting all.
- min_dcf_low
- Misses and false alarms weighted by their costs and the target prior π, normalized so 1 is accepting or rejecting all.
- min_dcf_high
- Misses and false alarms weighted by their costs and the target prior π, normalized so 1 is accepting or rejecting all.
- min_dcf_threshold
- Misses and false alarms weighted by their costs and the target prior π, normalized so 1 is accepting or rejecting all.
- min_dcf_fpr
- Misses and false alarms weighted by their costs and the target prior π, normalized so 1 is accepting or rejecting all.
- min_dcf_fnr
- Misses and false alarms weighted by their costs and the target prior π, normalized so 1 is accepting or rejecting all.
- actual_threshold
- The cost at a threshold fixed in advance: yours, or for log-likelihood ratios the Bayes threshold log(C_fa(1−π)/(C_miss π)).
- actual_dcf
- The cost at a threshold fixed in advance: yours, or for log-likelihood ratios the Bayes threshold log(C_fa(1−π)/(C_miss π)).
- actual_fpr
- The cost at a threshold fixed in advance: yours, or for log-likelihood ratios the Bayes threshold log(C_fa(1−π)/(C_miss π)).
- actual_fnr
- The cost at a threshold fixed in advance: yours, or for log-likelihood ratios the Bayes threshold log(C_fa(1−π)/(C_miss π)).
- cllr
- Bits of cost of scores read as log-likelihood ratios: 0 is perfect, 1 is no better than ignoring the scores.
- fnr_at_fpr_01
- The share of target trials rejected when the threshold lets through at most 1% of non-target trials.
- n_groups
- The EER and minimum DCF within each level of a condition column (channel, language, gender).
Python and R
Python and R agree to 10 decimals (relative tolerance 1e-10). Python uses pandas, numpy, codesplash; R uses stats, nanoparquet, codesplashr.
Default traps between the two languages
- Both engines sort with a stable rule, count errors exactly and resample the same trials from the shared Wichmann–Hill stream; sums can differ in the last bits.
The exact script CodeSplash ran for example “Cosine default” · Python 3.13.5 · scipy 1.18.1 · pandas 3.1.0
# Evaluate verification scores (EER, DCF, DET)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method evaluate.verification 1.0.0 · spec b3990d6ff44d22ee
# Dataset: aud3_trials (version 1)
# Runs on its own: outside the app, cs.publish() writes $CS_RESULT_PATH or prints the result JSON.
# %% Setup
import math
import numpy as np
import pandas as pd
import codesplash as cs
from codesplash.errors import check_groups
from codesplash.evaluate import verification as vf # DET points, EER, DCF, Cllr (twin: codesplashr cs_verif_*)
# %% Data
df = pd.read_parquet("tests/parity/fixtures/aud3_trials.parquet", columns=["cosine", "same"])
n_input = len(df)
df["same"] = pd.Categorical(df["same"], categories=["false", "true"]) # stored level order
df = df.dropna(subset=["cosine", "same"]) # listwise deletion over the analysis columns
df["same"] = df["same"].cat.remove_unused_categories()
n_dropped = n_input - len(df)
warnings = []
if n_dropped:
warnings.append(cs.cs_warning("CS_W_ROWS_DROPPED", dropped=n_dropped, total=n_input))
if n_input and not len(df):
cs.cs_error("CS_E_NO_ROWS")
cs.check_finite_columns(df, ["cosine", "same"]) # infinite values stop the run (registry/errors.yaml)
# %% Trials
sc, lc = "cosine", "same"
gc = None
present = [str(v) for v in df[lc].cat.categories] # levels with data, in stored order
check_groups(df[lc], lc, minimum=2, exactly=2)
target_level = present[-1] # default: the last level ("true")
s = df[sc].to_numpy(dtype=float)
pos = (df[lc].astype(str) == target_level).to_numpy()
p_target = 0.01 # None: the share of target trials
c_miss, c_fa = 1, 1
eer_method = "linear" # linear | rocch
llr = False
fixed_threshold = None
reps = int(1000)
conf = 0.95
seed = 42 # portable Wichmann–Hill stream: R resamples the same trials
# %% Verification metrics
res = vf.summary(s, pos, p_target, c_miss, c_fa, eer_method, None if llr else fixed_threshold, llr)
ci = vf.bootstrap(s, pos, reps, seed, conf, p_target, c_miss, c_fa, eer_method)
pts = vf.det_points(s, pos)
prior = res["prior"]
n_t, n_n = res["n_target"], res["n_nontarget"]
op_rows = []
for target in (0.001, 0.01, 0.05, 0.1):
fnr_t, thr_t = vf.fnr_at_fpr(pts, target)
op_rows.append({"fpr_target": target, "fnr": fnr_t, "threshold": thr_t})
fnr_01 = op_rows[1]["fnr"]
# %% Conditions
groups = [str(v) for v in df[gc].cat.categories] if gc else []
gcol = df[gc].astype(str).to_numpy() if gc else None
g_rows, g_curves = [], []
for lv in groups:
m = gcol == lv
nt, nn = int(np.sum(pos & m)), int(np.sum(~pos & m))
if nt == 0 or nn == 0:
g_rows.append({"group": lv, "n_target": nt, "n_nontarget": nn, "eer": None, "min_dcf": None})
continue
r = vf.summary(s[m], pos[m], p_target, c_miss, c_fa, eer_method)
g_rows.append({"group": lv, "n_target": nt, "n_nontarget": nn, "eer": r["eer"], "min_dcf": r["min_dcf"]})
if len(g_curves) < 7:
g_curves.append((lv, vf.det_points(s[m], pos[m])))
# %% Assumptions
e_t, e_n = res["eer"] * n_t, res["eer"] * n_n
few = min(e_t, e_n) < 30
assumptions = [
{"key": "held_out", "label": "Scores come from a fixed system", "status": "info",
"detail": "Fix the system and any threshold before scoring these trials. The minimum DCF picks its threshold on them, so it is optimistic; the actual DCF uses a threshold fixed in advance."},
{"key": "independence", "label": "Trials are not independent", "status": "info",
"detail": "Trials that share a speaker or item are correlated, so intervals from resampling trials are narrower than a resampling of speakers would give."},
{"key": "errors", "label": "Enough errors at the EER", "status": "warn" if few else "pass",
"detail": f"About {e_t:.0f} misses and {e_n:.0f} false alarms at the EER" + ("; with fewer than 30 of either the rates are rough (Doddington's rule of 30)." if few else ".")},
]
if res["eer"] > 0.5:
warnings.append("The equal error rate is above 50%: higher scores go with different-source trials. Check the same-source level.")
# %% Result
pct = f"{conf:.0%}"
f3 = lambda v: "—" if v is None else f"{v:.3f}"
fp = lambda v: "—" if v is None else f"{100 * v:.2f}%"
values = {"n": int(len(df)), "n_target": n_t, "n_nontarget": n_n, "target_level": target_level, "p_target": prior,
"c_miss": c_miss, "c_fa": c_fa, "eer_method": eer_method,
"eer": res["eer"], "eer_low": ci["eer_low"], "eer_high": ci["eer_high"], "eer_threshold": res["eer_threshold"],
"min_dcf": res["min_dcf"], "min_dcf_low": ci["min_dcf_low"], "min_dcf_high": ci["min_dcf_high"],
"min_dcf_threshold": res["min_dcf_threshold"], "min_dcf_fpr": res["min_dcf_fpr"], "min_dcf_fnr": res["min_dcf_fnr"],
"actual_threshold": res["actual_threshold"], "actual_dcf": res["actual_dcf"], "actual_fpr": res["actual_fpr"],
"actual_fnr": res["actual_fnr"], "cllr": res["cllr"], "fnr_at_fpr_01": fnr_01, "n_groups": len(groups)}
metric_rows = [
{"measure": "Equal error rate (EER)", "value": res["eer"], "low": ci["eer_low"], "high": ci["eer_high"],
"threshold": res["eer_threshold"], "fpr": res["eer"], "fnr": res["eer"]},
{"measure": "Minimum DCF (threshold picked on these trials)", "value": res["min_dcf"], "low": ci["min_dcf_low"],
"high": ci["min_dcf_high"], "threshold": res["min_dcf_threshold"], "fpr": res["min_dcf_fpr"], "fnr": res["min_dcf_fnr"]},
]
if res["actual_dcf"] is not None:
metric_rows.append({"measure": "Actual DCF (Bayes threshold)" if llr else "Actual DCF (fixed threshold)", "value": res["actual_dcf"],
"low": None, "high": None, "threshold": res["actual_threshold"], "fpr": res["actual_fpr"], "fnr": res["actual_fnr"]})
if res["cllr"] is not None:
metric_rows.append({"measure": "Cllr (bits)", "value": res["cllr"], "low": None, "high": None, "threshold": None, "fpr": None, "fnr": None})
tables = [
{"key": "metrics", "title": f"Verification metrics ({pct} intervals from resampling trials)",
"columns": [{"key": "measure", "label": "Measure", "type": "string"}, {"key": "value", "label": "Value", "type": "number"},
{"key": "low", "label": f"{pct} CI low", "type": "number"}, {"key": "high", "label": f"{pct} CI high", "type": "number"},
{"key": "threshold", "label": "Threshold", "type": "number"}, {"key": "fpr", "label": "False alarm rate", "type": "number"},
{"key": "fnr", "label": "Miss rate", "type": "number"}],
"rows": metric_rows},
{"key": "operating_points", "title": "Miss rate at fixed false alarm rates",
"columns": [{"key": "fpr_target", "label": "False alarm rate at most", "type": "number"}, {"key": "fnr", "label": "Miss rate", "type": "number"},
{"key": "threshold", "label": "Threshold", "type": "number"}],
"rows": op_rows},
]
if groups:
tables.append({"key": "groups", "title": f"By {gc}",
"columns": [{"key": "group", "label": gc, "type": "string"}, {"key": "n_target", "label": "Target trials", "type": "integer"},
{"key": "n_nontarget", "label": "Non-target trials", "type": "integer"}, {"key": "eer", "label": "EER", "type": "number"},
{"key": "min_dcf", "label": "Minimum DCF", "type": "number"}],
"rows": g_rows})
series = [("All trials", pts)] + g_curves
det_f, det_m, det_s = [], [], []
for name, p in series:
inner = [i for i in range(p["threshold"].size) if math.isfinite(p["threshold"][i])]
for j in vf.thin(len(inner)):
det_f.append(float(p["fpr"][inner[j]]))
det_m.append(float(p["fnr"][inner[j]]))
det_s.append(name)
charts = [cs.chart("det", "det-curve", "Detection error tradeoff: miss rate against false alarm rate", {
"fpr": cs.col("False alarm rate (false accepts)", det_f),
"fnr": cs.col("Miss rate (false rejects)", det_m),
"model": cs.col("Trials", det_s, "categorical", levels=[name for name, _ in series])},
controls={"eer": res["eer"], "minDcf": res["min_dcf"], "minDcfFpr": res["min_dcf_fpr"], "minDcfFnr": res["min_dcf_fnr"],
"actualDcf": res["actual_dcf"], "actualFpr": res["actual_fpr"], "actualFnr": res["actual_fnr"]})]
keep = vf.thin(int(len(df)), 20000)
charts.append(cs.chart("scores", "density", "Scores of target and non-target trials", {
"x": cs.col(sc, [float(s[i]) for i in keep]),
"group": cs.col("Trial", ["Target" if pos[i] else "Non-target" for i in keep], "categorical", levels=["Non-target", "Target"])},
controls={"compare": False}))
summary = (f"On {n_t} target and {n_n} non-target trials, the equal error rate was {fp(res['eer'])} ({pct} CI {fp(ci['eer_low'])} to {fp(ci['eer_high'])}) "
f"and the minimum detection cost {f3(res['min_dcf'])} at π = {prior:g}, C_miss = {c_miss:g}, C_fa = {c_fa:g}.")
if res["actual_dcf"] is not None:
summary += f" At the {'Bayes' if llr else 'fixed'} threshold {res['actual_threshold']:.3g} the actual cost was {f3(res['actual_dcf'])}."
if res["cllr"] is not None:
summary += f" Cllr = {res['cllr']:.3f} bits."
cs.publish({
"method": "evaluate.verification",
"methodVersion": "1.0.0",
"title": "Verification scores",
"engine": cs.engine_info("pandas", "numpy"),
"n": int(len(df)),
"summary": summary,
"statistics": [{"key": "eer", "label": "EER", "value": res["eer"], "format": "percent"},
{"key": "min_dcf", "label": "Minimum DCF", "value": res["min_dcf"]},
{"key": "fnr_at_fpr_01", "label": "Miss rate at 1% false alarms", "value": fnr_01, "format": "percent"}],
"tables": tables,
"assumptions": assumptions,
"warnings": warnings,
"notes": [f"A trial is accepted when {sc} ≥ the threshold; target trials: {lc} = {target_level}. "
f"EER: {'linear interpolation on the operating points' if eer_method == 'linear' else 'the crossing on the ROC convex hull'}. "
f"DCF = C_miss·π·miss rate + C_fa·(1 − π)·false alarm rate, normalized by min(C_miss·π, C_fa·(1 − π)); π = {prior:g}"
+ (" (the share of target trials)." if p_target is None else ".")
+ f" Intervals: {reps} resamples of trials within each class on the shared seeded stream (seed {seed})."],
"charts": charts,
"values": values,
})
The exact script CodeSplash ran for example “Cosine default” · R version 4.5.1 (2025-06-13)
# Evaluate verification scores (EER, DCF, DET)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method evaluate.verification 1.0.0 · spec b3990d6ff44d22ee
# Dataset: aud3_trials (version 1)
# Runs on its own: outside the app, cs_publish() writes $CS_RESULT_PATH or prints the result JSON.
# %% Setup
library(codesplashr) # cs_verif_* (DET points, EER, DCF, Cllr)
# %% Data
df <- as.data.frame(nanoparquet::read_parquet("tests/parity/fixtures/aud3_trials.parquet", col_select = c("cosine", "same")))
n_input <- nrow(df)
df[["same"]] <- factor(df[["same"]], levels = c("false", "true")) # stored level order
df <- df[stats::complete.cases(df[c("cosine", "same")]), , drop = FALSE] # listwise deletion
df[] <- lapply(df, function(x) if (is.factor(x)) droplevels(x) else x)
n_dropped <- n_input - nrow(df)
warnings <- list()
if (n_dropped > 0) {
warnings <- c(warnings, cs_warning("CS_W_ROWS_DROPPED", dropped = n_dropped, total = n_input))
}
if (n_input > 0 && nrow(df) == 0) cs_error("CS_E_NO_ROWS")
cs_check_finite_columns(df, c("cosine", "same")) # infinite values stop the run (registry/errors.yaml)
# %% Trials
sc <- "cosine"
lc <- "same"
gc <- NULL
present <- levels(df[[lc]]) # levels with data, in stored order
cs_check_groups(df[[lc]], lc, minimum = 2, exactly = 2)
target_level <- present[length(present)] # default: the last level ("true")
s <- as.numeric(df[[sc]])
pos <- as.character(df[[lc]]) == target_level
p_target <- 0.01 # NULL: the share of target trials
c_miss <- 1
c_fa <- 1
eer_method <- "linear" # linear | rocch
llr <- FALSE
fixed_threshold <- NULL
reps <- as.integer(1000)
conf <- 0.95
seed <- 42 # portable Wichmann-Hill stream: Python resamples the same trials
# %% Verification metrics
res <- cs_verif_summary(s, pos, p_target, c_miss, c_fa, eer_method, if (llr) NULL else fixed_threshold, llr)
ci <- cs_verif_bootstrap(s, pos, reps, seed, conf, p_target, c_miss, c_fa, eer_method)
pts <- cs_verif_det_points(s, pos)
prior <- res$prior
n_t <- res$n_target
n_n <- res$n_nontarget
op_rows <- lapply(c(0.001, 0.01, 0.05, 0.1), function(target) {
o <- cs_verif_fnr_at_fpr(pts, target)
list(fpr_target = target, fnr = o$fnr, threshold = o$threshold)
})
fnr_01 <- op_rows[[2]]$fnr
# %% Conditions
groups <- if (!is.null(gc)) levels(df[[gc]]) else character(0)
gcol <- if (!is.null(gc)) as.character(df[[gc]]) else NULL
g_rows <- list()
g_curves <- list()
for (lv in groups) {
m <- gcol == lv
nt <- sum(pos & m)
nn <- sum(!pos & m)
if (nt == 0 || nn == 0) {
g_rows[[length(g_rows) + 1L]] <- list(group = lv, n_target = nt, n_nontarget = nn, eer = NULL, min_dcf = NULL)
next
}
r <- cs_verif_summary(s[m], pos[m], p_target, c_miss, c_fa, eer_method)
g_rows[[length(g_rows) + 1L]] <- list(group = lv, n_target = nt, n_nontarget = nn, eer = r$eer, min_dcf = r$min_dcf)
if (length(g_curves) < 7) g_curves[[length(g_curves) + 1L]] <- list(name = lv, pts = cs_verif_det_points(s[m], pos[m]))
}
# %% Assumptions
e_t <- res$eer * n_t
e_n <- res$eer * n_n
few <- min(e_t, e_n) < 30
assumptions <- list(
list(key = "held_out", label = "Scores come from a fixed system", status = "info",
detail = "Fix the system and any threshold before scoring these trials. The minimum DCF picks its threshold on them, so it is optimistic; the actual DCF uses a threshold fixed in advance."),
list(key = "independence", label = "Trials are not independent", status = "info",
detail = "Trials that share a speaker or item are correlated, so intervals from resampling trials are narrower than a resampling of speakers would give."),
list(key = "errors", label = "Enough errors at the EER", status = if (few) "warn" else "pass",
detail = paste0(sprintf("About %.0f misses and %.0f false alarms at the EER", e_t, e_n),
if (few) "; with fewer than 30 of either the rates are rough (Doddington's rule of 30)." else "."))
)
if (res$eer > 0.5) warnings <- c(warnings, "The equal error rate is above 50%: higher scores go with different-source trials. Check the same-source level.")
# %% Result
pct <- sprintf("%.0f%%", conf * 100)
f3 <- function(v) if (is.null(v)) "—" else sprintf("%.3f", v)
fp <- function(v) if (is.null(v)) "—" else sprintf("%.2f%%", 100 * v)
values <- list(n = nrow(df), n_target = n_t, n_nontarget = n_n, target_level = target_level, p_target = prior,
c_miss = c_miss, c_fa = c_fa, eer_method = eer_method,
eer = res$eer, eer_low = ci$eer_low, eer_high = ci$eer_high, eer_threshold = res$eer_threshold,
min_dcf = res$min_dcf, min_dcf_low = ci$min_dcf_low, min_dcf_high = ci$min_dcf_high,
min_dcf_threshold = res$min_dcf_threshold, min_dcf_fpr = res$min_dcf_fpr, min_dcf_fnr = res$min_dcf_fnr,
actual_threshold = res$actual_threshold, actual_dcf = res$actual_dcf, actual_fpr = res$actual_fpr,
actual_fnr = res$actual_fnr, cllr = res$cllr, fnr_at_fpr_01 = fnr_01, n_groups = length(groups))
metric_rows <- list(
list(measure = "Equal error rate (EER)", value = res$eer, low = ci$eer_low, high = ci$eer_high,
threshold = res$eer_threshold, fpr = res$eer, fnr = res$eer),
list(measure = "Minimum DCF (threshold picked on these trials)", value = res$min_dcf, low = ci$min_dcf_low,
high = ci$min_dcf_high, threshold = res$min_dcf_threshold, fpr = res$min_dcf_fpr, fnr = res$min_dcf_fnr)
)
if (!is.null(res$actual_dcf)) metric_rows[[length(metric_rows) + 1L]] <- list(
measure = if (llr) "Actual DCF (Bayes threshold)" else "Actual DCF (fixed threshold)", value = res$actual_dcf,
low = NULL, high = NULL, threshold = res$actual_threshold, fpr = res$actual_fpr, fnr = res$actual_fnr)
if (!is.null(res$cllr)) metric_rows[[length(metric_rows) + 1L]] <- list(
measure = "Cllr (bits)", value = res$cllr, low = NULL, high = NULL, threshold = NULL, fpr = NULL, fnr = NULL)
tables <- list(
list(key = "metrics", title = sprintf("Verification metrics (%s intervals from resampling trials)", pct),
columns = list(list(key = "measure", label = "Measure", type = "string"), list(key = "value", label = "Value", type = "number"),
list(key = "low", label = paste(pct, "CI low"), type = "number"), list(key = "high", label = paste(pct, "CI high"), type = "number"),
list(key = "threshold", label = "Threshold", type = "number"), list(key = "fpr", label = "False alarm rate", type = "number"),
list(key = "fnr", label = "Miss rate", type = "number")),
rows = metric_rows),
list(key = "operating_points", title = "Miss rate at fixed false alarm rates",
columns = list(list(key = "fpr_target", label = "False alarm rate at most", type = "number"), list(key = "fnr", label = "Miss rate", type = "number"),
list(key = "threshold", label = "Threshold", type = "number")),
rows = op_rows)
)
if (length(groups)) tables[[length(tables) + 1L]] <- list(key = "groups", title = sprintf("By %s", gc),
columns = list(list(key = "group", label = gc, type = "string"), list(key = "n_target", label = "Target trials", type = "integer"),
list(key = "n_nontarget", label = "Non-target trials", type = "integer"), list(key = "eer", label = "EER", type = "number"),
list(key = "min_dcf", label = "Minimum DCF", type = "number")),
rows = g_rows)
series <- c(list(list(name = "All trials", pts = pts)), g_curves)
det_f <- numeric(0)
det_m <- numeric(0)
det_s <- character(0)
for (se in series) {
inner <- which(is.finite(se$pts$threshold))
j <- inner[cs_verif_thin(length(inner))]
det_f <- c(det_f, se$pts$fpr[j])
det_m <- c(det_m, se$pts$fnr[j])
det_s <- c(det_s, rep(se$name, length(j)))
}
charts <- list(cs_chart("det", "det-curve", "Detection error tradeoff: miss rate against false alarm rate", list(
fpr = cs_col("False alarm rate (false accepts)", det_f),
fnr = cs_col("Miss rate (false rejects)", det_m),
model = cs_col("Trials", det_s, "categorical", levels = vapply(series, function(se) se$name, character(1)))),
controls = list(eer = res$eer, minDcf = res$min_dcf, minDcfFpr = res$min_dcf_fpr, minDcfFnr = res$min_dcf_fnr,
actualDcf = res$actual_dcf, actualFpr = res$actual_fpr, actualFnr = res$actual_fnr)))
keep <- cs_verif_thin(nrow(df), 20000L)
charts[[length(charts) + 1L]] <- cs_chart("scores", "density", "Scores of target and non-target trials", list(
x = cs_col(sc, s[keep]),
group = cs_col("Trial", ifelse(pos[keep], "Target", "Non-target"), "categorical", levels = c("Non-target", "Target"))),
controls = list(compare = FALSE))
summary <- sprintf("On %d target and %d non-target trials, the equal error rate was %s (%s CI %s to %s) and the minimum detection cost %s at π = %s, C_miss = %s, C_fa = %s.",
as.integer(n_t), as.integer(n_n), fp(res$eer), pct, fp(ci$eer_low), fp(ci$eer_high), f3(res$min_dcf),
format(prior, digits = 6), format(c_miss, digits = 6), format(c_fa, digits = 6))
if (!is.null(res$actual_dcf)) summary <- paste(summary, sprintf("At the %s threshold %s the actual cost was %s.",
if (llr) "Bayes" else "fixed", formatC(res$actual_threshold, digits = 3, format = "g"), f3(res$actual_dcf)))
if (!is.null(res$cllr)) summary <- paste(summary, sprintf("Cllr = %.3f bits.", res$cllr))
cs_publish(list(
method = "evaluate.verification",
methodVersion = "1.0.0",
title = "Verification scores",
engine = cs_engine_info("stats", "nanoparquet"),
n = nrow(df),
summary = summary,
statistics = list(list(key = "eer", label = "EER", value = res$eer, format = "percent"),
list(key = "min_dcf", label = "Minimum DCF", value = res$min_dcf),
list(key = "fnr_at_fpr_01", label = "Miss rate at 1% false alarms", value = fnr_01, format = "percent")),
tables = tables,
assumptions = assumptions,
warnings = warnings,
notes = list(paste0(sprintf("A trial is accepted when %s ≥ the threshold; target trials: %s = %s. ", sc, lc, target_level),
sprintf("EER: %s. ", if (eer_method == "linear") "linear interpolation on the operating points" else "the crossing on the ROC convex hull"),
sprintf("DCF = C_miss·π·miss rate + C_fa·(1 − π)·false alarm rate, normalized by min(C_miss·π, C_fa·(1 − π)); π = %s", format(prior, digits = 6)),
if (is.null(p_target)) " (the share of target trials)." else ".",
sprintf(" Intervals: %d resamples of trials within each class on the shared seeded stream (seed %d).", reps, as.integer(seed)))),
charts = charts,
values = values
))
Sources
- Martin, A., Doddington, G., Kamm, T., Ordowski, M., & Przybocki, M. (1997). The DET curve in assessment of detection task performance. Proceedings of Eurospeech, 1895–1898.
- Brümmer, N., & du Preez, J. (2006). Application-independent evaluation of speaker detection. Computer Speech & Language, 20(2–3), 230–275.
- Brümmer, N., & de Villiers, E. (2011). The BOSARIS toolkit: Theory, algorithms and code for surviving the new DCF. arXiv:1304.2865.
- NIST (2020). NIST 2020 CTS Speaker Recognition Challenge evaluation plan (the detection cost function).
- Doddington, G. R., Przybocki, M. A., Martin, A. F., & Reynolds, D. A. (2000). The NIST speaker recognition evaluation: overview, methodology, systems, results, perspective. Speech Communication, 31(2–3), 225–254.
From the CodeSplash method registry · evaluate.verification v1.0.0.