Skip to content
svgtext-metric-ci

Corpus scores with intervals

Which system scores higher on each metric, and is the gap larger than the resampling noise?

Demo data · seed 20261101 · 10 rows · default settings · 640 × 360SVG, lightSVG, darkDemo CSV

How to read it

  1. Read each row as one metric: the dot is the corpus score and the bar its bootstrap interval.
  2. Compare dots of different colours within a metric to see which system scores higher.
  3. Use the method's paired p-value to judge the gap; intervals that overlap can still differ significantly.
  1. Callout 1: A corpus score with its interval.
  2. Callout 2: A second system on the same metric.
  3. Callout 3: A wide interval: few rows or very uneven outputs.

Watch out

  • The interval reflects which rows happened to be tested, not how well the references capture good answers.
  • A higher BLEU is not a better system unless people or a judge agree.

Defaults

No settings: the chart draws one way.

Pinned in the code

  • Draws what the Python or R engine computed; the chart computes nothing statistical.
  • Intervals are paired bootstrap percentile intervals over rows (Koehn 2004) on the shared Wichmann–Hill stream: every replicate resamples the same rows for every system.
  • Corpus BLEU and chrF pool n-gram counts over rows before forming the score; ROUGE is the mean of row F1 values. None is a mean of the row-level dots.
  • Overlapping intervals do not by themselves mean no difference; the method's paired p-value against the first system answers that.
# Corpus scores with intervals — Codesplash Chart Lab (recipe "text-metric-ci")
# controls: defaults
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

try:
    import codesplash as cs  # optional: the app's chart theme
except ImportError:
    cs = None
if cs:
    cs.use_codesplash(dark=False)
PALETTE = cs.palette(dark=False)["categorical"] if cs else plt.rcParams["axes.prop_cycle"].by_key()["color"]

df = pd.read_csv("text-metric-ci-demo.csv", keep_default_na=False, na_values=[""])  # demo data (only empty cells are missing): Chart Lab → Code → Download demo CSV
df["metric"] = pd.Categorical(df["metric"].astype("string"), categories=["BLEU", "chrF", "ROUGE-1", "ROUGE-2", "ROUGE-L"])
df["system"] = pd.Categorical(df["system"].astype("string"), categories=["baseline", "fine-tuned"])

_tokens = cs.palette(dark=False) if cs else {}
SEQ = _tokens.get("sequential", ["#eff6fd", "#1a469d"])  # sequential ramp (low → high)
DIV = _tokens.get("diverging", ["#c13e2e", "#f3f5f8", "#0859ac"])  # negative, midpoint, positive
REF = _tokens.get("reference", "#4e5661")
GREY = _tokens.get("dim", "#ced1d6")
def levels_of(s):
    """Declared level order (categoricals), else order of first appearance."""
    if isinstance(s.dtype, pd.CategoricalDtype):
        return [v for v in s.cat.categories if (s == v).any()]
    return list(dict.fromkeys(s.dropna().astype(str)))
M = "metric"
EST = "score"
LO = "lower"
HI = "upper"
SYS = "system"
d = df.dropna(subset=[M, EST])
metrics = levels_of(d[M])
systems = levels_of(d[SYS]) if SYS else [None]
fig, ax = plt.subplots(figsize=(7, 0.6 * len(metrics) * max(1, len(systems)) + 1.2))
for j, s in enumerate(systems):
    for i, m in enumerate(metrics):
        r = d[(d[M].astype(str) == m) & ((d[SYS].astype(str) == str(s)) if SYS else True)]
        if r.empty:
            continue
        y = len(metrics) - 1 - i + 0.8 * ((j + 0.5) / len(systems) - 0.5)
        r = r.iloc[0]
        ax.errorbar(r[EST], y, xerr=[[r[EST] - r[LO]], [r[HI] - r[EST]]], fmt="o", color=PALETTE[j % len(PALETTE)], capsize=3, label=s if i == 0 else None)
ax.set_yticks(range(len(metrics)), metrics[::-1])
ax.set_xlabel("score (0–100)")
if SYS:
    ax.legend(title=SYS, fontsize=8)
ax.set_title("Corpus scores with bootstrap intervals")
plt.show()

Needs pandas, numpy, matplotlib · reads text-metric-ci-demo.csv · app theme from the optional codesplash helper

  • Intervals are the engine's paired bootstrap percentiles; the emitted code draws them as given.