TREC and statistical evaluation
Notes on TREC-style test collections and statistical evaluation methods for comparing information retrieval systems (metrics, pooling, incomplete judgments, and significance tests).
Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.
Why it matters
TREC-style test collections and statistical evaluation let an engineer measure and compare search-system quality in a repeatable way. They provide reliable metrics (like MAP and NDCG), procedures to build relevance judgments (pooling), and statistical tests to decide whether one system is truly better than another.
Key ideas
Start with basics from first principles.
Test collection: a triplet (D, T, R) where D is a document set, T is a set of topics (queries), and R is a set of relevance judgments (often called qrels). The collection is the experimental ground-truth for IR evaluation.
Topic (query): a statement of information need used to produce ranked output from systems. In TREC (Text REtrieval Conference, by NIST), topics usually have an id, title, description, and often a narrative.
Relevance judgment: a human-labelled score that indicates how relevant a document is to a topic. If binary, values are {relevant, non-relevant}; graded judgments use ordinal levels (e.g. 0,1,2,3).
Run: a system's ranked list of documents for each topic.
Pooling: a method to create relevance judgments when judging every document is infeasible. For each topic, collect the top k documents from many systems into a pool, and have humans judge only that pool. Pooling introduces incompleteness bias because documents outside the pool are usually unjudged.
Evaluation metric: a function that maps a topic's run + judgments to a number measuring quality (precision, recall, AP, DCG, etc.). Use averaged metrics (e.g. MAP) across topics to compare systems.
Incomplete judgments: when not all documents are judged, some metrics (like MAP) can be biased. Measures designed to tolerate incomplete judgments include bpref. In common tools (e.g., trec_eval), unjudged documents are treated as nonrelevant for AP/precision, but ignored for bpref (and inferred measures like infNDCG); always state how unjudged are handled.
Statistical significance: when comparing systems, we treat per-topic scores as paired observations and test whether observed differences are likely from chance. Common tests: paired t-test, Wilcoxon signed-rank test, randomization (permutation) test, and bootstrap for confidence intervals.
Precise definitions and assumptions:
Paired t-test: let d_i = score_A(i) − score_B(i) for topics i=1..n. Assume d_i are independent and identically distributed and roughly normal. Test H0: μ_d = 0 vs H1: μ_d ≠ 0. The test statistic is t = d̄ / (s_d / sqrt(n)), where d̄ is mean of d_i and s_d is the sample standard deviation of d_i. Degrees of freedom = n−1.
Wilcoxon signed-rank: nonparametric alternative for paired differences. Assumes differences are symmetric about the median. Rank the absolute differences, sum ranks of positive differences; compute W and use tables or normal approximation for large n.
Randomization (permutation) test (paired): For each topic, randomly swap the two system scores with probability 0.5 many times, recompute mean difference each time to get null distribution; p-value = fraction of permutations where |mean_diff_perm| >= |observed_mean_diff|. No normality assumption, but assumes exchangeability under H0.
Multiple comparisons: when comparing many systems, control family-wise error rate using Bonferroni (adjust alpha by m comparisons) or Holm-Bonferroni (stepwise, less conservative).
Effect size: report alongside p-values. For paired data, Cohen's d for paired samples: d = d̄/s_d.
Relations to other course topics: evaluation uses outputs from models (Vector space model, BM25, Language models), relies on preprocessing (tokenisation, stemming) and indexing (inverted index), and interacts with efficiency topics (query scheduling) when evaluating speed.
Diagrams to draw in exam answers (describe what to draw and label):
- For pooling: draw two vertical columns labeled System A and System B. From each, draw top-k boxes, merge into a single set labeled Pool, then arrow to human judge box that produces qrels. Label "pooling" and "unjudged docs" outside pool.
- For paired test: draw per-topic score pairs (A,B) as dots on 2D scatter, diagonal line y=x; annotate differences d_i as vertical distances from diagonal.
Formulas
Precision@k = (# relevant in top k) / k – # relevant in top k (no unit); applies to binary relevance.
Recall = (# relevant retrieved) / (# relevant in collection for that query) – applies when total relevant count known.
AP = (1 / R) * sum_{j: doc_j relevant} Precision@rank_j – where R = total relevant for that query; AP is undefined if R=0 (usually set to 0).
MAP = (1 / n) * sum_{i=1..n} AP_i – mean over n topics.
DCG_p = rel_1 + sum_{i=2..p} rel_i / log2(i) – rel_i is graded relevance at position i. Use log base 2. Other common conventions use gains g(rel_i) = 2^{rel_i} − 1 and/or discount log2(i+1); state your convention and use the same for IDCG/NDCG.
NDCG_p = DCG_p / IDCG_p – IDCG_p is DCG_p of ideal ranking (documents ordered by decreasing rel).
bpref = (1 / R) * sum_{r: relevant} (1 - min(# judged-nonrelevant ranked above r, R) / R) – counts use only judged documents; R is the number of judged relevant docs; designed to handle incomplete judgments.
d_i = score_A(i) - score_B(i) – per-topic paired differences.
d̄ = (1/n) * sum_{i=1..n} d_i – mean difference.
s_d = sqrt( sum_{i=1..n} (d_i - d̄)^2 / (n-1) ) – sample standard deviation of differences.
t = d̄ / (s_d / sqrt(n)) – paired t-test statistic, df = n - 1.
For Wilcoxon signed-rank: rank absolute d_i (excluding zeros), compute W = sum of ranks for positive d_i. Compare W to null distribution (tabulated or approximate normal for large n).
Permutation test (algorithmic): repeatedly (many times) randomly swap each pair with p=0.5, compute mean difference; p-value = fraction with absolute mean >= observed absolute mean.
Worked examples
Example 1 — compute AP and MAP (numerical, step-by-step) Data: 3 topics. For a single system, ranked lists with relevant documents at these ranks:
- Topic1: relevant at ranks 2 and 4 (R1 = 2).
- Topic2: relevant at rank 1 (R2 = 1).
- Topic3: relevant at ranks 3, 4, 5 (R3 = 3).
Compute AP for each topic.
Topic1: Precision@2 = 1/2 = 0.5; Precision@4 = 2/4 = 0.5.
AP1 = (0.5 + 0.5) / 2 = 0.5.
Topic2: Precision@1 = 1/1 = 1.0.
AP2 = 1.0.
Topic3: Precision@3 = 1/3 = 0.333333; Precision@4 = 2/4 = 0.5; Precision@5 = 3/5 = 0.6.
AP3 = (0.333333 + 0.5 + 0.6) / 3 = 0.4777777.
MAP = (AP1 + AP2 + AP3) / 3 = (0.5 + 1.0 + 0.4777777) / 3 = 0.659259.
Final answer: MAP = 0.659 (approx).
Example 2 — paired t-test (numerical, step-by-step) Compare two systems A and B on n=5 topics with per-topic APs:
- A: [0.60, 0.45, 0.70, 0.30, 0.80]
- B: [0.55, 0.50, 0.65, 0.35, 0.75]
Differences d = A - B = [0.05, -0.05, 0.05, -0.05, 0.05].
Sum(d) = 0.05; d̄ = 0.05 / 5 = 0.01.
Compute s_d:
Deviations from mean = [0.04, -0.06, 0.04, -0.06, 0.04]. Squares = [0.0016, 0.0036, 0.0016, 0.0036, 0.0016].
Sum squares = 0.012. s_d = sqrt(0.012 / (5 - 1)) = sqrt(0.003) = 0.0547723.
t = d̄ / (s_d / sqrt(n)) = 0.01 / (0.0547723 / 2.2360679) = 0.01 / 0.0244974 = 0.4082.
Degrees of freedom = 4. Two-tailed p-value for t=0.4082 (df=4) ≈ 0.70. Conclusion: not statistically significant; fail to reject H0.
Example 3 — NDCG with graded relevance (numerical)
One query, system ranking with graded relevance at ranks: [3,2,3,0]. Compute NDCG@4.
DCG = 3 + 2/log2(2) + 3/log2(3) + 0/log2(4) = 3 + 2/1 + 3/1.585 = 3 + 2 + 1.892789 = 6.892789.
Ideal order by relevance: [3,3,2,0], IDCG = 3 + 3/log2(2) + 2/log2(3) = 3 + 3 + 1.261859 = 7.261859.
NDCG = DCG / IDCG = 6.892789 / 7.261859 = 0.9490.
Final answer: NDCG@4 ≈ 0.949.
Common mistakes
- Confusing precision@k with recall or forgetting to state k.
- Forgetting log base 2 in DCG formula or using log base e without adjusting.
- Ignoring incomplete judgments: reporting MAP without noting pooling can mislead.
- Not reporting effect size or confidence intervals—p-value alone is insufficient.
For your exam
Types of questions you will face:
- Definitions: define test collection, pooling, qrels, run, AP, MAP, NDCG, bpref.
- Short notes: explain pooling and its biases; compare bpref vs MAP under incomplete judgments.
- Derivations: derive the paired t-test statistic from basic sample mean and variance formulas (show steps), or derive DCG normalization.
- Numericals: compute AP/MAP, NDCG, perform a paired t-test for small n, compute bpref by hand for an incomplete judgment set.
- Diagrams: draw pooling flow, or scatter of paired scores with diagonal.
What a full-marks answer includes:
- Clear definitions (bold or stated), assumptions for any statistical test used, step-by-step calculations with units or percentages, statement of conclusion (reject/fail to reject) with p-value and effect size, and a short comment on practical significance and possible biases (e.g., pooling).
Quick check
- What does a test collection contain? 2) Write the formula for AP for a single query. 3) Which test should you use when you cannot assume normality of per-query differences?
Answers: Test collection = (D, T, R) documents, topics, judgments;
AP = (1 / R) * sum_{j: doc_j relevant} Precision@rank_j; use Wilcoxon signed-rank or permutation (randomization) test.
Finished this topic? Mark it so your progress, study plan and readiness keep up.
Stuck on something here?