検索の測定

読了まで約69 分分、13 節 節の 12 例 例。

第2026.11.10版 2026年11月19日時点で例が通過 132 例中 132 例が合格 変更点

AIによる翻訳。英語版は人による検証済みである。 当社の書籍の作り方

英語版の書籍(版2026.11.10)から翻訳した。 原文を読む

この章を読み終えるころには、標準的なランキング指標をゼロから計算し、scikit-learn の結果と照らし合わせて検証し、ランカーを比較する前にどの指標を使うかを選び、テストクエリ上の二つのランカーの差が確かなものか、それとも偶然で生じうるものかを判断できるようになる。

第1章は、ある順位づけで終わっていた。そこで打ち負かすべきランカーとされたのは、意味検索である。ストアのテストクエリ、すなわちどのランカーもチューニングに用いていない検索に対して、BM25 の nDCG@10 は 0.725、意味検索は 0.830、ハイブリッドは 0.812、再ランク付けしたハイブリッドは 0.798 である。この順位を信頼する前に、二つの問いに答えなければならない。第一に、これらの指標は買い物客にとって重要なものを測っているか、そして正しく計算されているか。第二に、その差は本物か、それとも 30 件のクエリでは偶然でも生じうるものか。この章は両方に答え、差が確立されたといえるための本書の規則と、それを適用するハーネスで締めくくる。

この部分はまだ翻訳されていないため、英語で表示している。

Count the relevant products in the top k

最終変更:版2026.11.8

Most ranking metrics start from one question: how many of the results a shopper sees are relevant? Precision at k, written precision@k, is the share of the top k results that are relevant. Recall at k, recall@k, is the share of all relevant products that appear in the top k. Manning and colleagues describe precision as the share of retrieved documents that are relevant and recall as the share of relevant documents that are retrieved, and they note that raising one usually costs the other (Manning et al., 2008, section 8.3). Both need a yes-or-no idea of relevant. In this book a product is relevant to a query when its judgment is exact, grade 2. A product nobody judged for the query counts as not relevant.

BM25's top 10 for the store's test query clear shower curtain mixes clear curtains, curtains that aren't clear, and shower curtain hooks. How many of those ten are exact, and what is the most any test query could score? The example answers both by hand and checks the count against lib.metrics:

precision-recall-by-hand.py Python 3.12.15 · bm25s 0.3.16 · numpy 2.5.5 · pandas 3.1.1 · scipy 1.18.1 合格
"""Counts the exact products in BM25's top 10 for one query, computes precision and recall by hand, and checks them against lib.metrics, then finds the best score each test query could reach. The prose's point rests on the "exact in the top 10" and "exact products judged" lines, and on the ceiling lines after the blank line."""import pandas as pdfrom lib.lexical import LexicalSearchfrom lib.metrics import precision_at_k, recall_at_kfrom lib.store import load_products, load_queries, qrelsqueries, judgments = load_queries("test"), qrels("test")ranking = list(LexicalSearch(load_products()).search(queries.at[246, "query"], k=10).index)  # clear shower curtain# grade 2 is exact; a product the judges never graded is absent from this dict, so it is not exactexact = {product_id for product_id, grade in judgments[246].items() if grade == 2}found = sum(product_id in exact for product_id in ranking[:10])print("exact in the top 10:", found)print("exact products judged:", len(exact))print(f"precision@10 by hand: {found / 10:.3f}")print(f"recall@10 by hand: {found / len(exact):.3f}")print(f"precision@10 from lib.metrics: {precision_at_k(ranking, judgments[246], 10):.3f}")print(f"recall@10 from lib.metrics: {recall_at_k(ranking, judgments[246], 10):.3f}")# the best any ranking can do: a top 10 that holds as many exact products as the query hasexact_counts = pd.Series({query_id: sum(grade == 2 for grade in per_query.values())                          for query_id, per_query in judgments.items()})# a top 10 can hold at most 10 exact products, and no more than the query hasbest_precision = exact_counts.clip(upper=10) / 10# only 10 results are shown, so at most 10 of a query's exact products can be retrievedbest_recall = exact_counts.clip(upper=10) / exact_countsprint()print("queries where precision@10 can't reach 1:", (best_precision < 1).sum())print("fewest exact products for a query:", exact_counts.min())print("queries with that few:", (exact_counts == exact_counts.min()).sum())print(f"best precision@10 for those queries: {best_precision.min():.3f}")print("queries where recall@10 can't reach 1:", (best_recall < 1).sum())most = exact_counts.idxmax()print("query with the most exact products:", queries.at[most, "query"])print("its exact products:", exact_counts[most])print(f"its best recall@10: {best_recall[most]:.3f}")
出力python precision-recall-by-hand.py
exact in the top 10: 4
exact products judged: 12
precision@10 by hand: 0.400
recall@10 by hand: 0.333
precision@10 from lib.metrics: 0.400
recall@10 from lib.metrics: 0.333

queries where precision@10 can't reach 1: 7
fewest exact products for a query: 4
queries with that few: 4
best precision@10 for those queries: 0.400
queries where recall@10 can't reach 1: 22
query with the most exact products: outdoor light fixtures
its exact products: 170
its best recall@10: 0.059

lib.metrics agrees with the hand count. Of the top 10, 4 are exact, so precision@10 is 0.400. Against the 12 exact products the judges marked for this query, recall@10 is 0.333. precision_at_k and recall_at_k give the same two values.

Neither metric has one ceiling for every query. A query with fewer than 10 exact products can't fill its top 10 with them, so precision@10 can't reach 1. 7 test queries are like that, and the 4 with only 4 exact products can reach a precision@10 of 0.400 at best.

A query with more than 10 exact products can't reach full recall in 10 results. That holds for 22 of the test queries. The query with the most, outdoor light fixtures, has 170 exact products, so its recall@10 tops out at 0.059. A mean over the test queries mixes queries that can score 1 with queries that can't.

Recall has a second problem, because its denominator counts only the exact products the judges found. WANDS judged candidates gathered for each query, not the whole catalog (chapter 1), so some exact products were never judged. Zobel found that judgments gathered this way overestimate recall (Know where the judgments came from).

Working rule: Use precision@10 when you care how much of the first page is right, and read it next to each query's ceiling. Don't make recall@10 a headline in product search, where a query can have more than a hundred relevant products, as outdoor light fixtures has. We recommend recall at a deep cutoff, such as the top 100, for one job only: checking that retrieval passes enough relevant products to a reranker. Even then, read it as an overestimate.

この部分はまだ翻訳されていないため、英語で表示している。

Score the first relevant result with reciprocal rank

最終変更:版2026.11.10

Precision counts a whole page, but some shoppers want one product: a replacement part, or a model they already know. For them, what matters is how far down the first good result sits. Reciprocal rank (RR) scores a query as 1 divided by the position of the first relevant result, or 0 if there is none, and the mean of RR over queries is the mean reciprocal rank (MRR). TREC, the Text REtrieval Conference, runs shared evaluations of search systems. MRR was the official measure of its question-answering track at TREC-8, where each question scored the reciprocal of the rank of the first correct answer, or 0 when none of the five answers was correct. The track chose it partly because it stays between 0 and 1 and averages well (Voorhees, 1999).

Averaging RR is disputed. Fuhr points out that under RR "the difference between ranks 1 and 2 is the same as that between ranks 2 and ∞", so RR isn't an interval scale, one on which equal steps mean equal differences, and he argues that its mean shouldn't be computed (Fuhr, 2017, section 2.1). Sakai sees no reason to forbid it (Sakai, 2020). Moffat argues that such metrics are more meaningful in their current form than in the intervalized versions proposed for them (Moffat, 2022). We use MRR with that caveat: it is a coarse summary.

RR depends on where you draw the line for relevant, so score BM25's ranking for clear shower curtain twice: once counting only exact products, once counting partial ones too. Then compute MRR for BM25 and semantic retrieval over the test queries:

reciprocal-rank-by-hand.py Python 3.12.15 · bm25s 0.3.16 · numpy 2.5.5 · pandas 3.1.1 · scipy 1.18.1 合格
"""Writes reciprocal rank by hand for one query under two grade thresholds, then computes MRR for BM25 and semantic retrieval and checks it against lib.metrics. The prose's point rests on the two rr lines for clear shower curtain and the two MRR lines."""import pandas as pdfrom lib.lexical import LexicalSearchfrom lib.metrics import evaluatefrom lib.semantic import SemanticSearchfrom lib.store import load_products, load_queries, qrels# relevant=2 counts only exact products; relevant=1 counts partial ones toodef reciprocal_rank(ranking, judgments, relevant=2):    """1 / the position of the first relevant product, or 0 if the ranking has none."""    # positions count from 1, as a shopper counts results    for position, product_id in enumerate(ranking, start=1):        # a product nobody judged has grade 0, so it never counts as relevant        if judgments.get(product_id, 0) >= relevant:            return 1 / position    return 0.0queries, judgments = load_queries("test"), qrels("test")# each run goes 100 products deep, so RR can look past the top 10 for the first exact productruns = {"bm25": LexicalSearch(load_products()).run(queries, k=100), "semantic": SemanticSearch().run(queries, k=100)}ranking = runs["bm25"][246]                                        # clear shower curtainprint(f"rr, exact counts as relevant: {reciprocal_rank(ranking, judgments[246]):.3f}")print(f"rr, partial or better counts: {reciprocal_rank(ranking, judgments[246], relevant=1):.3f}")for name, run in runs.items():    rr = pd.Series({query_id: reciprocal_rank(run[query_id], judgments[query_id]) for query_id in judgments})    print(f"{name} mrr: {rr.mean():.3f}")    print(f"{name} mrr from lib.metrics: {evaluate(run, judgments)['rr'].mean():.3f}")    print(f"{name} queries with rr of 1:", (rr == 1).sum())
出力python reciprocal-rank-by-hand.py
rr, exact counts as relevant: 0.500
rr, partial or better counts: 1.000
bm25 mrr: 0.650
bm25 mrr from lib.metrics: 0.650
bm25 queries with rr of 1: 16
semantic mrr: 0.787
semantic mrr from lib.metrics: 0.787
semantic queries with rr of 1: 22

The grade threshold changes RR for this one query. BM25's first result for clear shower curtain is a partial match and its second is exact, so RR is 0.500 when only exact products count, and 1.000 when partial ones count too. Whenever you quote RR, say which grades count. The mean over the test queries matches the rr column of lib.metrics.evaluate: BM25 scores 0.650 and semantic retrieval 0.787. That column looks for the first exact product anywhere in the run, not only in the top 10.

RR has a blind spot. It is 1 for 22 test queries under semantic retrieval and for 16 under BM25, and on those queries it sees nothing below the first result. A ranker that puts one exact product first and nine irrelevant ones after it scores the same as a perfect top 10.

Working rule: Report MRR as the headline only when shoppers need one right product, as for a model number or a named product such as kohler whitehaven farmhouse kitchen sink. For queries where shoppers browse a page of options, such as wooden chair outdoor, use nDCG@10 as the headline and report MRR beside it.

割引利得から nDCG を組み立てる

最終変更:版2026.11.10

適合率や RR と異なり、第1章で一つのランキングの採点に使った nDCG@10 は、評価の等級を読み取る。各結果は、その等級を利得として寄与する。利得は順位が下がるほど大きくなる割引で縮められ、その総和が割引累積利得(DCG)である。正規化 DCG(nDCG)は、あるランキングの DCG を理想的なランキングの DCG で割ったものである。この指標の二つの要素には複数の版があり、版によって値が変わる。一つ目は理想的なランキングである。DCG を導入した Järvelin と Kekäläinen は、これを「何らかの IR 技術の結果ではなく、検索トピックの再現率基盤」に基づかせている(Järvelin and Kekäläinen, 2002)。実際には、ランカーが返した商品だけでなく、そのクエリで評価済みのすべての商品を最良の順に並べたものを指す。二つ目は割引である。彼らは文書のスコアを順位の対数で割ることを提案したが、どの対数を使うか、どの順位から割り引くかは版によって異なる。

lib.metrics の式は次のとおりである。ここで grade(i) は位置 i の商品の等級である。

DCG@k  = sum over positions i from 1 to k of  grade(i) / log2(i + 1)
nDCG@k = DCG@k / DCG@k of the ideal ranking

これが使われている唯一の版ではない。Järvelin と Kekäläinen は、対数の底より小さい順位を割り引かなかった。そのため底を 2 とすると、最初の二つの位置はそのまま数えられる。Burges らは、指数型の利得 2^grade − 1 と、log(1 + rank) による割引を用いた(Burges et al., 2005)。評価ツールにも違いがある。ir-measures のドキュメントは、pytrec_eval と gdeval とで異なる nDCG のオプションを挙げている(ir-measures)。したがって nDCG の値を示すときは、必ず版を明記すること。

DCG と nDCG を一から書き、第1章の BM25、セマンティック、ハイブリッドの各実行について lib.metrics と照合する。その中に、良すぎて信じにくいスコアが一つある。

ndcg-from-scratch.py Python 3.12.15 · bm25s 0.3.16 · numpy 2.5.5 · pandas 3.1.1 · scipy 1.18.1 合格
"""Writes DCG and nDCG from scratch and checks them against lib.metrics on every test query of three runs, then prints one query's grades beside its best possible grades. The prose's point rests on the largest-difference line and on the ndcg@10 line for luau string lights, read with the grade lines above it."""import mathfrom lib.fusion import reciprocal_rank_fusionfrom lib.lexical import LexicalSearchfrom lib.metrics import ndcg_at_kfrom lib.semantic import SemanticSearchfrom lib.store import load_products, load_queries, qrelsdef dcg(grades, k):    """Each grade divided by log2 of its position plus one, added up over the top k."""    # positions count from 1, so the first result is divided by log2(2)    return sum(grade / math.log2(position + 1) for position, grade in enumerate(grades[:k], start=1))def ndcg(ranking, judgments, k=10):    """DCG of the ranking over DCG of the best order of every judged product (unjudged counts as 0)."""    # the ideal ranking: every judged product, best grade first    ideal = dcg(sorted(judgments.values(), reverse=True), k)    # a product nobody judged counts as grade 0 in the ranking    return dcg([judgments.get(product_id, 0) for product_id in ranking], k) / idealqueries, judgments = load_queries("test"), qrels("test")bm25 = LexicalSearch(load_products()).run(queries, k=100)semantic = SemanticSearch().run(queries, k=100)runs = {"bm25": bm25, "semantic": semantic, "hybrid": reciprocal_rank_fusion([bm25, semantic])}gaps = [abs(ndcg(run[query_id], judgments[query_id]) - ndcg_at_k(run[query_id], judgments[query_id], 10))        for run in runs.values() for query_id in judgments]print("rankings checked:", len(gaps))print(f"largest difference from lib.metrics: {max(gaps):.3f}")ranking, per_query = bm25[461], judgments[461]                     # luau string lightsprint()print("query:", queries.at[461, "query"])print("grades in the top 10:", [per_query.get(product_id, 0) for product_id in ranking[:10]])print("best possible grades:", sorted(per_query.values(), reverse=True)[:10])print("exact products judged:", sum(grade == 2 for grade in per_query.values()))print("exact in the top 10:", sum(per_query.get(product_id, 0) == 2 for product_id in ranking[:10]))print(f"ndcg@10: {ndcg(ranking, per_query):.3f}")
出力python ndcg-from-scratch.py
rankings checked: 90
largest difference from lib.metrics: 0.000

query: luau string lights
grades in the top 10: [2, 2, 2, 2, 1, 1, 1, 1, 1, 1]
best possible grades: [2, 2, 2, 2, 1, 1, 1, 1, 1, 1]
exact products judged: 4
exact in the top 10: 4
ndcg@10: 1.000

90 件のランキングすべてで、手書きの版と lib.metrics の差は 0.000 を超えない。

luau string lights では、BM25 の上位 10 件に完全一致の商品が 4 件含まれ、スコアは 1.000 である。これは誤りではない。このクエリで評価済みの完全一致の商品は 4 件しかないため、可能な最良の上位 10 件は、それらに続いて部分一致の商品が並ぶものになり、BM25 はその順序を見つけたのである。nDCG@10 が 1 であるとは、「評価済みの商品の最良の順序と同等に良い」ことを意味し、「完全一致の商品が 10 件ある」ことを意味しない。

実践ルール: 線形の利得と log2(i + 1) の割引を用いる形を、カットオフ 10 で使い、理想的なランキングは評価済みのすべての商品から作る。数値を示すときは、必ずその版を明記する。nDCG の比較は、同じ評価で採点した実行どうしに限ること。新しい評価は理想的なランキングを変え、それとともにすべてのスコアを変える。

scikit-learn の ndcg_score と照合する

最終変更:版2026.11.8

指標は、それを独立に計算するライブラリと照合して確かめる。scikit-learn 1.9.1 では、ndcg_score は lib.metrics と同じ変種を用いる。すなわち、グレードをそのままゲインとし、各ゲインを log2(順位 + 1) で割り、正規化に用いる DCG は、同じグレードを最良の順に並べ替えて k で打ち切ったものである(scikit-learn のソースコード)。ドキュメントは Järvelin と Kekäläinen を引用しているが、コードが実装しているのは後発の順位 + 1 の形である(scikit-learn のドキュメント)。次の3点により、素朴な呼び出しは自前の計算と食い違う。

  • 渡した商品だけをスコア付けの対象とするため、理想の順位もそれらだけから作る。
  • 既定では、スコアが同点の商品のゲインを平均する。これは、同点の商品のあらゆる並べ方にわたる平均に等しい(McSherry and Najork, 2008)。
  • 入力はクエリごとに1行で、どの行も同じ長さでなければならず、返り値は行にわたる平均である(scikit-learn のソースコード)。

まず素朴な呼び出しを行う。ndcg_score に、clear shower curtain に対する BM25 の上位10件のグレードを渡す。スコアは BM25 の順位どおりになるように与える。続いて、lib.metrics がそのクエリを扱うのと同じ方法で各クエリの行を作り、3通りの実行結果をすべて比較する。

ndcg-matches-scikit-learn.py Python 3.12.15 · bm25s 0.3.16 · numpy 2.5.5 · pandas 3.1.1 · scikit-learn 1.9.1 · scipy 1.18.1 合格
"""Compares scikit-learn's ndcg_score with lib.metrics for one query, first with only the top 10 passed and then with every judged product in the row, and then on every test query of three runs. The prose's point rests on the ndcg@10 lines for clear shower curtain and on the 5-product lines."""from sklearn.metrics import ndcg_scorefrom lib.fusion import reciprocal_rank_fusionfrom lib.lexical import LexicalSearchfrom lib.metrics import ndcg_at_kfrom lib.semantic import SemanticSearchfrom lib.store import load_products, load_queries, qrelsdef sklearn_ndcg(ranking, judgments, k=10):    """One row for one query: every judged product, plus any retrieved product nobody judged."""    # every judged product once, then the retrieved products nobody judged    products = list(dict.fromkeys([*judgments, *ranking]))    position = {product_id: i for i, product_id in enumerate(ranking)}    grades = [[judgments.get(product_id, 0) for product_id in products]]    # ndcg_score ranks by score, so the negated position puts rank 1 highest    scores = [[-position.get(product_id, len(ranking)) for product_id in products]]  # not retrieved: below all    return ndcg_score(grades, scores, k=k)queries, judgments = load_queries("test"), qrels("test")bm25 = LexicalSearch(load_products()).run(queries, k=100)semantic = SemanticSearch().run(queries, k=100)runs = {"bm25": bm25, "semantic": semantic, "hybrid": reciprocal_rank_fusion([bm25, semantic])}top = bm25[246][:10]                                                # clear shower curtain# scores 10 down to 1 put the top 10 in BM25's order, so the first product scores highestnaive = ndcg_score([[judgments[246].get(product_id, 0) for product_id in top]], [list(range(10, 0, -1))], k=10)print(f"ndcg@10, only the top 10 passed: {naive:.3f}")print(f"ndcg@10 from lib.metrics: {ndcg_at_k(top, judgments[246], 10):.3f}")print(f"ndcg@10, every judged product passed: {sklearn_ndcg(top, judgments[246]):.3f}")gaps = [abs(sklearn_ndcg(run[query_id], judgments[query_id]) - ndcg_at_k(run[query_id], judgments[query_id], 10))        for run in runs.values() for query_id in judgments]print("rankings compared:", len(gaps))print(f"largest difference: {max(gaps):.3f}")short = bm25[246][:5]                                               # a ranking shorter than kprint(f"5-product ranking, lib.metrics: {ndcg_at_k(short, judgments[246], 10):.3f}")print(f"5-product ranking, scikit-learn: {sklearn_ndcg(short, judgments[246]):.3f}")
出力python ndcg-matches-scikit-learn.py
ndcg@10, only the top 10 passed: 0.901
ndcg@10 from lib.metrics: 0.615
ndcg@10, every judged product passed: 0.615
rankings compared: 90
largest difference: 0.000
5-product ranking, lib.metrics: 0.539
5-product ranking, scikit-learn: 0.629

上位10件だけを渡した場合、ndcg_score は 0.901 を返し、lib.metrics の 0.615 とは一致しない。これは、その10件だけの最良の順で割るため、BM25 が取り逃した、まさにその商品を見ることができないからである。lib.metrics は、そのクエリで判定された 253 件の商品すべての最良の順で割る。この例の sklearn_ndcg は、次の手順でこの違いを解消する。各行には、判定された商品をすべて入れ、さらに、取得されたが誰も判定していない商品があれば、それをグレード 0 として加える。この手順では、取得された商品には順位に基づくスコアを与え、それ以外の商品にはすべて、それらより低い同一のスコアを1つ与える。この手順を用いると、両者は 90 件のランキングすべてで一致する(最大の差は 0.000)。クエリごとに行の長さが異なるため、ndcg_score はクエリごとに1回呼び出し、結果の平均は自分で取ること。

この手順には1つ限界があり、短い実行結果でそれが現れる。ndcg_score は、実行結果が取得しなかった商品を、上位 k 件の中の空いた位置を占める同点の商品として扱い、それらの位置に平均ゲインを与える。lib.metrics は、買い物客にはそこに何も見えないため、空いた位置には何も与えない。BM25 のランキングを5件に切り詰めると両者は食い違い、lib.metrics の 0.539 に対して ndcg_score の 0.629 となる。短い実行結果は実際に起こる。LexicalSearch は、スコアが 0 より大きい商品だけを返すからである。

実践ルール: 自前の nDCG を報告し、ndcg_score は独立した検算として用いる。その際、各クエリの行には判定された商品をすべて含め、スコアは順位から取る。両者を比較する前に、どの実行結果にも少なくとも k 件の商品が含まれていることを確かめる。ランカーの生のスコアを渡す場合は、先に、たとえば product_id の順など、固定した順序で同点を解消しておく。そうしないと、スコアが同点の箇所で両者は食い違う。

比較する前に指標を選ぶ

最終変更:版2026.11.8

あらゆる指標は、買い物客のモデルである。precision@10 は、買い物客が最初のページ全体に目を通すものとし、そこにある良い商品の数を数える。RR は、買い物客が最初の良い商品で見るのをやめるものとする。nDCG@10 は、ページの下に行くほど注意が薄れていくこと、そして完全に合致する商品は部分的に合致する商品より価値が高いことを仮定する。本書の等級では、その価値は2倍である。Burges et al. (2005) のように指数ゲイン 2^grade − 1 を用いると、等級は 0、1、3 のゲインに変換され、完全に合致する商品は部分的に合致する商品3つ分の価値を持つ。経験則として、2つのランカーが大きく離れているときには、これらのモデルの結論は一致する。ランカーが近いときには、指標が勝者を決めてしまうことがある。指標を結果を見る前に選ぶのはそのためである。Fuhr は、「指標 X を用いて手法 A と B を比較したい」という形で、仮説を事前に述べておくことを求めている(Fuhr, 2017, section 2.6)。

基準となるランカーであるセマンティック検索と、第1章では両者を区別できなかったハイブリッドを取り上げる。指標の選択は評価の調整の一部であるため、その選択は 50 件の訓練クエリで行い、テストクエリは報告のために取っておく。両方のランカーを4つの指標でスコアリングする。

metric-choice-on-train.py Python 3.12.15 · bm25s 0.3.16 · numpy 2.5.5 · pandas 3.1.1 · scipy 1.18.1 合格
"""Scores semantic retrieval and the hybrid four ways on the train queries and names the higher scorer for each metric. The prose's point rests on the "higher" lines, the count of metrics each ranker wins, and the largest gap."""from lib.fusion import reciprocal_rank_fusionfrom lib.lexical import LexicalSearchfrom lib.metrics import evaluatefrom lib.semantic import SemanticSearchfrom lib.store import load_products, load_queries, qrelsqueries, judgments = load_queries("train"), qrels("train")          # choosing a metric is tuning: use trainbm25 = LexicalSearch(load_products()).run(queries, k=100)semantic = SemanticSearch().run(queries, k=100)runs = {"semantic": semantic, "hybrid": reciprocal_rank_fusion([bm25, semantic])}exponential = {query_id: {product_id: 2 ** grade - 1 for product_id, grade in per_query.items()}               for query_id, per_query in judgments.items()}       # gains 0, 1, 3 instead of 0, 1, 2means = {}for name, run in runs.items():    scores = evaluate(run, judgments)    means[name] = {"precision@10": scores["precision@10"].mean(), "mrr": scores["rr"].mean(),                   "ndcg@10": scores["ndcg@10"].mean(),                   "ndcg@10 with exponential gains": evaluate(run, exponential)["ndcg@10"].mean()}print("train queries:", len(judgments))winners = []for metric in means["semantic"]:    for name in runs:        print(f"{name} {metric}: {means[name][metric]:.3f}")    # max keeps the first name it meets, so on an exact tie the order of runs decides    winners.append(max(runs, key=lambda name: means[name][metric]))    print(f"higher {metric}: {winners[-1]}")for name in runs:    print(f"metrics won by {name}:", winners.count(name))print(f"largest gap: {max(abs(means['semantic'][m] - means['hybrid'][m]) for m in means['semantic']):.3f}")
出力python metric-choice-on-train.py
train queries: 50
semantic precision@10: 0.502
hybrid precision@10: 0.488
higher precision@10: semantic
semantic mrr: 0.673
hybrid mrr: 0.710
higher mrr: hybrid
semantic ndcg@10: 0.772
hybrid ndcg@10: 0.774
higher ndcg@10: hybrid
semantic ndcg@10 with exponential gains: 0.709
hybrid ndcg@10 with exponential gains: 0.708
higher ndcg@10 with exponential gains: semantic
metrics won by semantic: 2
metrics won by hybrid: 2
largest gap: 0.037

4つの指標は、勝者について一致しない。セマンティック検索が 2 個の指標で上回り、ハイブリッドが 2 個の指標で上回っており、両者の差はどの指標でも 0.037 を超えない。2つのランカーがこれほど近いと、差がどちらに傾くかは指標が決める。第1章が選んだ主要指標である nDCG@10 は、hybrid という結果で一方に有利に働く。これらは訓練クエリであるから、どちらのランカーが優れているかについては、ここからは何も言えない。

したがって、選択は結果ではなく買い物客に従うべきである。ストアは商品のページを表示し、その判定は等級付きであるから、第1章が選んだとおり、線形ゲインの nDCG@10 を主要指標とし、precision@10 と MRR をその脇に置く。

実践ルール: ランカーを比較する前に、主要指標とそのゲイン、カットオフを1つ選び、書き留めておくこと。判定が等級付きで、買い物客がページを閲覧する場合には、線形ゲインの nDCG@10 を推奨する。適合しなければならない交換部品のように、完全に合致する商品が近いものよりはるかに価値が高い場合には指数ゲインに切り替え、ほとんどのクエリに正解が1つしかない場合には MRR に切り替える。主要指標の脇にはほかの指標も併せて報告し、主要指標がどちらのランカーに有利かを見たあとで、それを変更してはならない。

平均だけでなく、クエリごとの差を読む

最終変更:版2026.11.8

全クエリにわたる主要指標の平均は、ストア全体にとっての要約である。しかし、買い物客が目にするのは一つのクエリの結果だけである。TREC Robust トラックはこの点を出発点として作られた。主催者らは、平均に合わせて調整すると、すでに成績の良いクエリが改善される一方で、成績の悪いクエリが犠牲になることがあると指摘している(Voorhees, 2004)。したがって、平均の変化を信頼する前に、クエリごとの差を確認する必要がある。これは、クエリごとに一つの数値、すなわち新しいランカーのスコアから古いランカーのスコアを引いた値である。これらは有意性検定が根拠として用いるデータでもある。

第1章で扱ったストアのハイブリッド検索は、平均すると BM25 を大きく上回るスコアを示す。両者を nDCG@10 でクエリごとに比較する。

per-query-hybrid-versus-bm25.py Python 3.12.15 · bm25s 0.3.16 · numpy 2.5.5 · pandas 3.1.1 · scipy 1.18.1 合格
"""Compares the hybrid and BM25 query by query on nDCG@10, then lists the three largest losses and the largest gain with its judged@10. The prose's point rests on the mean and median difference lines and on the largest-gain lines."""from lib.fusion import reciprocal_rank_fusionfrom lib.lexical import LexicalSearchfrom lib.metrics import evaluatefrom lib.semantic import SemanticSearchfrom lib.store import load_products, load_queries, qrelsqueries, judgments = load_queries("test"), qrels("test")bm25 = LexicalSearch(load_products()).run(queries, k=100)hybrid = reciprocal_rank_fusion([bm25, SemanticSearch().run(queries, k=100)])before, after = evaluate(bm25, judgments), evaluate(hybrid, judgments)# rounded to three decimals first, so a difference that rounds to 0 counts as a tie; sorted from the largest loss updifference = (after["ndcg@10"] - before["ndcg@10"]).round(3).sort_values()   # one value per test queryprint(f"mean difference: {difference.mean():.3f}")print(f"median difference: {difference.median():.3f}")print("hybrid better:", (difference > 0).sum())print("bm25 better:", (difference < 0).sum())print("tied:", (difference == 0).sum())print("\nhybrid's three largest losses:")print(queries.loc[difference.index[:3], "query"].to_frame().assign(difference=difference[:3]).to_string())# the last one after sorting: the largest gainlargest = difference.index[-1]print("\nlargest gain:", queries.at[largest, "query"])print(f"its gain: {difference[largest]:.3f}")print(f"its bm25 judged@10: {before.at[largest, 'judged@10']:.3f}")print(f"share of the mean gain from this query: {difference[largest] / difference.sum():.3f}")relative = after["ndcg@10"] / before["ndcg@10"] - 1                            # per-query relative gainsprint(f"\nrelative gain of the means: {after['ndcg@10'].mean() / before['ndcg@10'].mean() - 1:.3f}")print(f"mean of per-query relative gains: {relative.mean():.3f}")print(f"its bm25 ndcg@10: {before.at[largest, 'ndcg@10']:.3f}")print(f"its relative gain: {relative[largest]:.3f}")print(f"mean of per-query relative gains without it: {relative.drop(largest).mean():.3f}")
出力python per-query-hybrid-versus-bm25.py
mean difference: 0.087
median difference: 0.057
hybrid better: 17
bm25 better: 7
tied: 6

hybrid's three largest losses:
                             query  difference
query_id
293       wood floor protector mat      -0.072
292        decorative white pillow      -0.069
249        bistro table and chairs      -0.066

largest gain: outdoor light fixtures
its gain: 0.714
its bm25 judged@10: 0.200
share of the mean gain from this query: 0.274

relative gain of the means: 0.120
mean of per-query relative gains: 0.218
its bm25 ndcg@10: 0.286
its relative gain: 2.492
mean of per-query relative gains without it: 0.140

平均の差は 0.087 だが、中央値は 0.057 である。ハイブリッドが勝つクエリは負けるクエリより多く、17 対 7 であり、6 のクエリは引き分けである。

成果の多くは一つのクエリによる。outdoor light fixtures は 0.714 の改善を示し、全体の改善に占める割合は 0.274 である。このクエリにおける BM25 の judged@10 は 0.200 である。このクエリでは BM25 の上位10件の大半が、誰も判定していない電球であり、第1章は、それらに付く0という評価は妥当だと論じている。したがってこの改善は成立する。別のクエリであれば、ランカーが上位から外した未判定の商品が、良い商品である可能性もある。ハイブリッドの最大の損失3件のクエリは、買い物客にとって検索が悪化したと感じられるクエリであるため、まずそれらを読むべきである。

差は絶対的な数値で報告する。平均同士の相対的な改善は 0.120 だが、クエリごとの相対的な改善の平均は 0.218 である。クエリごとの比の平均は、BM25 のスコアが低いクエリに最も大きな重みを与えるためである。

outdoor light fixtures は、BM25 のスコアが 0.286 であり、それだけで 2.492 の相対的な改善に寄与する。この一つのクエリを除くと、相対的な改善の平均は 0.140 に下がる。Fuhr は、平均の相対的な変化からはクエリごとの変化について信頼できることは何も言えず、「算術平均については、絶対的な改善のみが意味を持つ」と示している(Fuhr, 2017, section 2.4)。

実践ルール: あらゆる比較において、差の平均と中央値、勝ち・負け・引き分けの件数、損失が最も大きいクエリを出力し、それらのクエリを読む。最も大きく動いたクエリについては、ランカーの手柄とする前に judged@10 を確認する。報告するのは平均の絶対的な差であり、パーセンテージではない。

順列検定でギャップを検定する

最終変更:版2026.11.10

数十件のクエリにおける2つの平均値の差は、偶然だけで生じうる。別のクエリを標本として選べば、異なる差が得られるからである。浅い指標ではこの問題がさらに深刻になる。BuckleyとVoorheesは、precision at 10のような指標では、システム間の差を確実に見分けるのに50件をはるかに超えるクエリが必要になることを見いだした(Buckley and Voorhees, 2000)。有意性検定は、2つのランカーの差が、帰無仮説、すなわち両者の性能が等しいという仮定のもとでどれほど意外なものかを問う。その答えがp値であり、帰無仮説のもとで、測定した差と同じかそれ以上に大きな差が得られる確率を指す。慣例として、p値が0.05を下回れば実際に差があることの証拠とみなされる。章の中で複数の比較を行う場合は、本書の実践ルールがこの基準を厳しくする。

本書の検定は対応ありである。2つのランカーを同じクエリで採点するため、各検定はクエリごとの差を対象とし、難しいクエリの低いスコアは相殺される。順列検定は、帰無仮説のもとで観測されるはずの差を直接構成する。2つのランカーが互換であるなら、各クエリの差は、符号が逆であることも同じ程度に起こりやすいはずである。そこで、各符号をランダムに反転させて平均を再計算し、これを数千回繰り返して、反転後の平均が実測値と同じかそれ以上に0から離れる頻度を数える。n件のクエリには2^n通りの符号パターンがあり、テスト用クエリでは1,073,741,824通りである。そのため検定ではそのうち9,999通りを標本抽出し、p値は推定値となる。

テスト用クエリでは、ハイブリッドはセマンティック検索に及ばない。この差が実在するかどうかは、第1章では未解決のままであった。テスト用クエリにおけるハイブリッドの、セマンティック検索に対する勝ち、負け、引き分けは9 / 14 / 7である。検定は、ハイブリッドの劣位が偶然より大きいと判定するだろうか。答えを予想してから、実行してみよう。

permutation-test-by-hand.py Python 3.12.15 · bm25s 0.3.16 · numpy 2.5.5 · pandas 3.1.1 · scipy 1.18.1 合格
"""Estimates the p-value of the hybrid's deficit against semantic retrieval by flipping each query's sign at random, once by hand and once with SciPy's permutation_test. The prose's point rests on the observed mean, the two p-value lines, and the line that compares the p-value with 0.05."""import numpy as npfrom scipy.stats import permutation_testfrom lib.fusion import reciprocal_rank_fusionfrom lib.lexical import LexicalSearchfrom lib.metrics import evaluatefrom lib.semantic import SemanticSearchfrom lib.store import load_products, load_queries, qrelsqueries, judgments = load_queries("test"), qrels("test")semantic = SemanticSearch().run(queries, k=100)hybrid = reciprocal_rank_fusion([LexicalSearch(load_products()).run(queries, k=100), semantic])after = evaluate(hybrid, judgments)["ndcg@10"].to_numpy()before = evaluate(semantic, judgments)["ndcg@10"].to_numpy()difference = after - before                                       # hybrid minus semantic, per test queryprint("test queries:", len(difference))print(f"sign patterns for the test queries: {2 ** len(difference):,}")print(f"observed mean difference: {difference.mean():.3f}")# if the two rankers were interchangeable, each query's difference would be as likely to have the other sign# a fixed seed, so every run draws the same sign patternsrng = np.random.default_rng(2026)# 9,999 random sign patterns, one sign for each query in eachsigns = rng.choice([-1, 1], size=(9999, len(difference)))flipped = (signs * difference).mean(axis=1)                       # 9,999 mean differences under that assumption# the 95th percentile of the flipped means' sizesprint(f"95% of flipped means are smaller than: {np.quantile(np.abs(flipped), 0.95):.3f}")print(f"p-value by hand: {np.mean(np.abs(flipped) >= abs(difference.mean())):.3f}")result = permutation_test((after, before), lambda after_scores, before_scores, axis: np.mean(after_scores - before_scores, axis=axis),                          # samples: flip each query's pair of scores, which is the paired setting                          permutation_type="samples", rng=np.random.default_rng(2026))print(f"p-value from scipy: {result.pvalue:.3f}")print("difference at the 0.05 level:", "larger than chance" if result.pvalue < 0.05 else "within chance")
出力python permutation-test-by-hand.py
test queries: 30
sign patterns for the test queries: 1,073,741,824
observed mean difference: -0.018
95% of flipped means are smaller than: 0.022
p-value by hand: 0.117
p-value from scipy: 0.125
difference at the 0.05 level: within chance

セマンティック検索に対するハイブリッドの劣位は、0.05水準でwithin chance。観測された平均差は-0.018であり、反転後の平均の95%は、大きさが0.022より小さい。p値、すなわち反転後の平均が観測値と同じかそれ以上に大きくなる割合は、0.117である。

SciPyのpermutation_testを、対応あり検定向けとしてドキュメントが示す設定であるpermutation_type="samples"で実行すると、0.125が返る(SciPy documentation)。両者の推定値がわずかに異なるのは、それぞれが独自にランダムな符号パターンを抽出するためである。劣位が実在するには、平均がばらつきを上回る必要がある。逆方向に振れるクエリが少数あれば、そのギャップは埋まってしまう。

SciPyのリサンプリング関数は、乱数生成器をrngで受け取る。これはrandom_state引数に取って代わるものである。1.18.1ではどちらも使えるが、ドキュメントには「新しいコードでは rng キーワードだけを使うべきである」とある。random_stateを使う呼び出しは、移行期間の後に警告を出すからである(SciPy documentation)。本書のすべての例では、固定のシードとともにrngを渡している。

実践ルール: 対応を取ろうとするギャップは、必ずクエリごとの差に対する対応あり順列検定で検定する。本書はこの検定に基づいて判断する。その根拠は本書の実践ルールに示してある。しきい値を上回るp値は「差があるという証拠がない」と読み、「差がない」とは決して読まない。クエリ数がこれほど少ないと、検定は実在するギャップを見逃しうる。McKechnieらは、こうした見逃しを偽陽性とあわせて測定することを論じている(McKechnie et al., 2025)。偶然と区別できないギャップについては、その原因を説明してはならない。

対応のあるt検定でp値を求める

最終変更:版2026.11.8

対応のあるt検定は、リサンプリングの代わりに公式を用いて、同じ問いに答える。クエリごとの差の平均を標準誤差で割る。標準誤差とは、差の標準偏差をクエリ数の平方根で割った値であり、クエリの標本が変わるたびに平均がどの程度動くかを推定するものである。二つのランカーの性能が等しく、差がおおむね正規分布に従うならば、この比tはt分布に従う。t分布は釣り鐘型で、正規分布よりも裾が重く、形状は自由度によって決まる。ここでの自由度はクエリ数より1小さい値である。p値は、tが0から正負いずれかの方向に少なくともその値だけ離れる確率である(Sakai, 2014, section 3.1.1)。

t = mean(d) / (sd(d) / sqrt(n))      d: the per-query differences, n: the number of queries

クエリごとのnDCGの差は−1から1の範囲に収まり、outdoor light fixturesでの改善のような外れ値も含むため、正規分布には従わない。それでも実際には、t検定は十分に頑健である。Smuckerらは、50トピックについて平均適合率(MAP、もう一つのランキング指標)で採点したTRECの実行結果を調べ、ランダム化検定、ブートストラップ検定、t検定の間に実用上の差はほとんどないことを見いだした。ここでランダム化検定とは並べ替え検定のことである(Smucker et al., 2007)。Urbanoらは、TRECのデータから構成したシミュレーションで25、50、100トピックの集合を用い、「t検定と並べ替え検定はほぼ同一にふるまう」ことを見いだした(Urbano et al., 2019)。どちらの研究も、この目的にはWilcoxonの符号順位検定や符号検定を用いないよう勧めている。また、SciPyのwilcoxonは、既定のzero_method='wilcox'では、差がちょうど0のクエリをすべて除外する(SciPy documentation)。二つの実行結果の差がわずかな場合には、多くのクエリが同点になる。

公式とリサンプリングは、第1章で見た差について一致するだろうか。そのうちの二つ、すなわちBM25に対する意味検索と意味検索に対するハイブリッドを取り上げる。公式から手計算で求めたtは、SciPyのttest_relと一致するはずである。

paired-t-test-by-hand.py Python 3.12.15 · bm25s 0.3.16 · numpy 2.5.5 · pandas 3.1.1 · scipy 1.18.1 合格
"""Computes the paired t statistic and its p-value by hand for two gaps, and checks each p-value against SciPy's ttest_rel. The prose's point rests on the t and p lines printed for each gap."""import mathfrom scipy.stats import t, ttest_relfrom lib.fusion import reciprocal_rank_fusionfrom lib.lexical import LexicalSearchfrom lib.metrics import evaluatefrom lib.semantic import SemanticSearchfrom lib.store import load_products, load_queries, qrelsqueries, judgments = load_queries("test"), qrels("test")bm25 = LexicalSearch(load_products()).run(queries, k=100)semantic = SemanticSearch().run(queries, k=100)runs = {"bm25": bm25, "semantic": semantic, "hybrid": reciprocal_rank_fusion([bm25, semantic])}ndcg = {name: evaluate(run, judgments)["ndcg@10"] for name, run in runs.items()}   # per test queryfor after, before in [("semantic", "bm25"), ("hybrid", "semantic")]:    difference = ndcg[after] - ndcg[before]    n = len(difference)    # ddof=1 divides by n - 1, the sample standard deviation the t-test uses    standard_error = difference.std(ddof=1) / math.sqrt(n)      # how much the mean would move between samples    statistic = difference.mean() / standard_error    p_value = 2 * t.sf(abs(statistic), df=n - 1)               # both tails of the t distribution    print(f"{after} minus {before}: {difference.mean():.3f}")    print(f"{after} minus {before} t by hand: {statistic:.3f}")    print(f"{after} minus {before} p by hand: {p_value:.3f}")    print(f"{after} minus {before} p from ttest_rel: {ttest_rel(ndcg[after], ndcg[before]).pvalue:.3f}")
出力python paired-t-test-by-hand.py
semantic minus bm25: 0.105
semantic minus bm25 t by hand: 3.294
semantic minus bm25 p by hand: 0.003
semantic minus bm25 p from ttest_rel: 0.003
hybrid minus semantic: -0.018
hybrid minus semantic t by hand: -1.590
hybrid minus semantic p by hand: 0.123
hybrid minus semantic p from ttest_rel: 0.123

BM25に対する意味検索では、平均差0.105からt = 3.294、p値0.003が得られ、これはttest_relの結果と一致する。偶然ではめったに生じない差である。

意味検索に対するハイブリッドでは、t = -1.590、p値は0.123である。これは同じ差に対する並べ替え検定の0.125に近い。

実践ルール: 対応のあるt検定(scipy.stats.ttest_rel)を、リサンプリングを要しない確認として、並べ替え検定と並べて報告する。二つの結果が閾値の異なる側に分かれた場合は、その旨を明記し、並べ替え検定の結果を採用する。平均スコアの比較には、Wilcoxonの符号順位検定や符号検定を用いてはならない。

差の大きさを報告する

最終変更:版2026.11.10

p値は差がどれほど意外であるかを示すものであり、差がどれほど大きいかを示すものではない。標本が大きければ、ほぼどのような変更でも、有意ではあるがごく小さな差が生じる(Fuhr, 2017, section 2.8)。Sakaiは、すべてのp値に効果量と信頼区間を添えて報告するよう勧めている(Sakai, 2014)。信頼区間とは、真の平均差がとりうる妥当な値の範囲である。ここでいう真の平均差とは、これらのクエリに似たすべてのクエリについて、これらの判定で採点したときの平均であり、ストアの検索トラフィックについての平均ではない。95%区間は、その値を95%の確率で覆うよう設計された手続きから得られる。

ブートストラップは、リサンプリングによって信頼区間を構成する。手元のクエリから、手元にある数と同じ数だけ復元抽出する。このため、同じクエリが2回現れることもあれば、まったく現れないクエリもある。平均差を計算し、これを数千回繰り返す。パーセンタイル区間は、リサンプリングで得た平均の中央95%である。対応のある比較の効果量は、平均差を差の標準偏差で割ったものである(Sakai, 2014, section 3.1.2)。これは、差の大きさを、クエリごとのばらつきと比べて表したものである。これは、対応のない標本に対する効果量であるCohenのdとは異なる。Sakaiは両者を直接比較しないよう注意している。

手作業で構成したパーセンタイル区間は、SciPyのbootstrapにmethod="percentile"を指定した結果と一致するだろうか。意味検索とBM25の比較、およびハイブリッドと意味検索の比較について、手作業で区間を構成し、それぞれをSciPyの結果と照合する。そのうえで、SciPyの既定の方法を実行する。

bootstrap-interval-by-hand.py Python 3.12.15 · bm25s 0.3.16 · numpy 2.5.5 · pandas 3.1.1 · scipy 1.18.1 合格
"""Builds a 95% percentile interval by hand from 9,999 resampled means, checks it against SciPy's percentile method, then reads SciPy's default BCa interval and the effect size for each gap. The prose's point rests on the BCa low and high lines and on the line that says whether each interval includes 0."""import numpy as npfrom scipy.stats import bootstrapfrom lib.fusion import reciprocal_rank_fusionfrom lib.lexical import LexicalSearchfrom lib.metrics import evaluatefrom lib.semantic import SemanticSearchfrom lib.store import load_products, load_queries, qrelsqueries, judgments = load_queries("test"), qrels("test")bm25 = LexicalSearch(load_products()).run(queries, k=100)semantic = SemanticSearch().run(queries, k=100)runs = {"bm25": bm25, "semantic": semantic, "hybrid": reciprocal_rank_fusion([bm25, semantic])}ndcg = {name: evaluate(run, judgments)["ndcg@10"] for name, run in runs.items()}   # per test queryfor after, before in [("semantic", "bm25"), ("hybrid", "semantic")]:    difference, name = (ndcg[after] - ndcg[before]).to_numpy(), f"{after} minus {before}"    # choice draws with replacement, so a query can appear twice in one set and not at all in another    resampled = np.random.default_rng(2026).choice(difference, size=(9999, len(difference)))  # 9,999 sets of queries    # 2.5% in each tail leaves the middle 95%    low, high = np.percentile(resampled.mean(axis=1), [2.5, 97.5])      # the middle 95% of their means    print(f"{name}: {difference.mean():.3f}")    print(f"{name} interval by hand: {low:.3f} to {high:.3f}")    percentile = bootstrap((difference,), np.mean, method="percentile", rng=np.random.default_rng(2026))    print(f"{name} percentile interval from scipy: "          f"{percentile.confidence_interval.low:.3f} to {percentile.confidence_interval.high:.3f}")    # BCa is SciPy's default method, so no method argument is given    bca = bootstrap((difference,), np.mean, rng=np.random.default_rng(2026)).confidence_interval    print(f"{name} bca low: {bca.low:.3f}\n{name} bca high: {bca.high:.3f}")    print(f"{name} bca interval and 0: {'includes 0' if bca.low <= 0 <= bca.high else 'excludes 0'}")    # ddof=1: the standard deviation of the differences, with n - 1 in the denominator    print(f"{name} effect size: {difference.mean() / difference.std(ddof=1):.3f}")
出力python bootstrap-interval-by-hand.py
semantic minus bm25: 0.105
semantic minus bm25 interval by hand: 0.049 to 0.172
semantic minus bm25 percentile interval from scipy: 0.049 to 0.172
semantic minus bm25 bca low: 0.055
semantic minus bm25 bca high: 0.185
semantic minus bm25 bca interval and 0: excludes 0
semantic minus bm25 effect size: 0.601
hybrid minus semantic: -0.018
hybrid minus semantic interval by hand: -0.041 to 0.003
hybrid minus semantic percentile interval from scipy: -0.041 to 0.003
hybrid minus semantic bca low: -0.042
hybrid minus semantic bca high: 0.002
hybrid minus semantic bca interval and 0: includes 0
hybrid minus semantic effect size: -0.290

SciPyのパーセンタイル区間は手作業で構成したものと一致する。それぞれ0.049 to 0.172と-0.041 to 0.003である。既定の方法であるBCa(bias-corrected and accelerated、バイアス補正・加速法)は、同じリサンプリング平均から別のパーセンタイルを読み取る。リサンプリング平均が観測平均からどれだけ中心を外れているかに応じてパーセンタイルをずらし、クエリを1件ずつ除外して推定した歪度に応じて区間を広げる(SciPy source)。本書のハーネスはBCaを報告する。BCaは、ここで扱うような歪んだリサンプリング平均を想定して設計されている。

意味検索とBM25の比較では、BCa区間は0.055から0.185に及び、excludes 0。効果量は0.601である。

ハイブリッドと意味検索の比較では、区間は-0.042から0.002に及ぶ。includes 0。効果量は-0.290である。この区間は、数%程度(百分の数)の悪化から、最大でも0.002の改善までのあらゆる値を許す。つまり、得る価値のある改善はない。

ブートストラップ区間は水準を近似するにすぎず、数十件程度のクエリでは水準に届かない。これを確かめるために、ハイブリッドと意味検索の30件のクエリごとの差を、存在するすべてのクエリであるかのように扱う。こうすれば真の差が既知となる。次に、そこから同じ大きさの新しい集合を1000組抽出し、それぞれに区間を構成して、真の差を覆う頻度を数える。

interval-coverage-check.py Python 3.12.15 · bm25s 0.3.16 · numpy 2.5.5 · pandas 3.1.1 · scipy 1.18.1 合格
"""Draws new samples from the test queries' differences and counts how often a BCa or a t interval covers the known gap, at two levels. The prose's point rests on the four coverage lines and the standard-error line."""import numpy as npfrom scipy.stats import bootstrap, ttest_1sampfrom lib.fusion import reciprocal_rank_fusionfrom lib.lexical import LexicalSearchfrom lib.metrics import evaluatefrom lib.semantic import SemanticSearchfrom lib.store import load_products, load_queries, qrelsqueries, judgments = load_queries("test"), qrels("test")semantic = SemanticSearch().run(queries, k=100)hybrid = reciprocal_rank_fusion([LexicalSearch(load_products()).run(queries, k=100), semantic])population = (evaluate(hybrid, judgments)["ndcg@10"] - evaluate(semantic, judgments)["ndcg@10"]).to_numpy()true_gap = population.mean()            # known, because these differences stand in for every query there is# a fixed seed, so the coverage counts repeat on every runrng, trials = np.random.default_rng(2026), 1000print("trials:", trials)# binomial standard error of a proportion near 0.95, over the trialsprint(f"standard error of a coverage near 0.95: {(0.95 * 0.05 / trials) ** 0.5:.3f}")for level in [0.95, round(1 - 0.05 / 3, 4)]:          # the usual level, and the level for three comparisons    covered = {"bca": 0, "t": 0}    for _ in range(trials):        sample = rng.choice(population, size=len(population))      # another set of 30 queries like these        # 1,999 resamples per interval, fewer than SciPy's default, to keep 1,000 trials quick        bca = bootstrap((sample,), np.mean, confidence_level=level, n_resamples=1999, rng=rng).confidence_interval        t = ttest_1samp(sample, 0).confidence_interval(level)     # the interval that matches the t-test        covered["bca"] += bca.low <= true_gap <= bca.high        covered["t"] += t.low <= true_gap <= t.high    for method, count in covered.items():        print(f"{method} coverage at {level}: {count / trials:.3f}")
出力python interval-coverage-check.py
trials: 1000
standard error of a coverage near 0.95: 0.007
bca coverage at 0.95: 0.927
t coverage at 0.95: 0.945
bca coverage at 0.9833: 0.955
t coverage at 0.9833: 0.975

名目95%では、BCaは真の差を0.927の割合で覆い、t検定の区間は0.945の割合で覆う。ハーネスが計画した比較に用いる水準である0.9833では、BCaは0.955、t区間は0.975を覆う。

どの数値も、上下におよそ0.007の不確かさを含む。BCaはどちらの水準でも名目水準に届かず、t区間は自らの水準により近い。したがって、0をかろうじて除外するだけのブートストラップ区間は、慎重に扱う必要がある。シミュレーションでは、同じリサンプリングに基づくブートストラップ・シフト検定が「小さなp値へ向かう系統的なバイアスを示す」と報告されている(Urbano et al., 2019)。

差が重要かどうかは、どの検定も代わりに判断してくれない。precision@10について、Fuhrは「0.02の差は、5クエリにつき関連文書が1件増えることに相当する」と述べている(Fuhr, 2017, section 2.8)。nDCG@10については、変更のコストに見合うのはどれほどの差かを、検定の前に決めておく。

実践ルール: すべての比較について、平均差、そのブートストラップ区間、効果量、p値を併せて示す。区間が0を含むなら、その比較は改善を示していない。区間が0を除外していても、変更のコストに見合う最小の差を下回るなら、その差は実在しても、出荷する価値はないかもしれない。区間は、差が存在するかどうかを決めるためではなく、差の大きさを述べるために用いる。

何をもって確立とするかを事前に決める

最終変更:版2026.11.8

有意水準 0.05 の検定は、差が単なるノイズである場合に 5% の確率で偽陽性を生む。複数の検定を行う章では、そのリスクを複数回負うことになる。10 個のシステムのすべての組を同じ方法で比較すると、すべての差がノイズで、かつ検定が互いに独立であるとしても、少なくとも 1 つが偽の「有意」となる確率は約 0.90 になる(Sakai, 2014, section 3)。Bonferroni 補正は単純で保守的な対処法である。m 個の仮説を検定するときは、それぞれを 0.05 を m で割った水準で検定する(Fuhr, 2017, section 2.7)。これにより、検定が独立であるか否かにかかわらず、いずれかが偽陽性となる確率を 0.05 以下に抑えられる。ただし、この方法が機能するのは、m 個の比較が結果を見る前に固定されている場合に限られる。Fuhr は、これが崩れる典型的な場合を挙げている。著者がまずデータ上で最も性能の良い競合手法を見つけ、その後で自分の手法をその 1 つとだけ比較するという場合である(Fuhr, 2017, section 2.6)。

そこで本書では、すべての章で次の 1 つの規則を用いる。

  1. テストクエリ上で計画した比較を一覧にする。 結果を 1 つでも報告する前に行う。
  2. 差が確立されたとみなす条件は、 対応のある順列検定の p 値が、その章の Bonferroni 閾値を下回ることである。閾値は、0.05 を計画した比較の数で割った値である。
  3. 対応のある t 検定と、ブートストラップ区間を併せて報告する。 区間の水準は閾値に対応させ、1 から閾値を引いた値とする。どちらかが順列検定と食い違う場合は、その旨を明記する。
  4. テスト結果を見たあとで選んだ比較は探索的なものである。 そのように明示し、確立されたとは決して呼ばない。
  5. 訓練クエリ上の比較はチューニングのためのものであり、 証拠にはならない。

判定を順列検定に委ねるのは、この検定が差の分布の形について何も仮定せず、帰無仮説のもとで各クエリの符号がコイン投げのように決まるということだけを仮定するからである。Urbano らは、両者がほぼ同じように振る舞うことを見いだしており(Urbano et al., 2019)、このことから t 検定は良い確認手段となる。数十件程度のクエリに対するブートストラップ区間は、その水準よりも低い頻度でしか真値を含まない(被覆率の確認)。したがって、区間は差を記述するものであっても、それを判定するものではない。

第 1 章では、ストアのパイプラインを 1 段階ずつ構築する。この順序だけで計画した比較が定まり、それは各段階をその直前の段階と比べるものとなる。すなわち、BM25 に対する意味検索、意味検索に対するハイブリッド、ハイブリッドに対するリランク付きハイブリッドであり、計画した比較は全部で 3 である。閾値は 0.0167 であり、区間の水準は 0.9833 を用いる。リランク付きハイブリッドと意味検索の比較は探索的である。意味検索が打ち負かすべきランカーとなったのは、これと同じテストクエリで最高得点を取ったからである。

実践ルール: テストクエリで何かをスコアリングする前に、計画した比較の一覧を書き、それを短く保つこと。比較が 1 つ増えるごとに、他の比較の基準が厳しくなるからである。多数のランカーを一度に比較する必要がある場合、Bonferroni は厳しくなりすぎる。Sakai は、ランカーの間に何らかの差があるかどうかを検定する分散分析を行い、その後に、いずれかが偽陽性となる確率を有意水準に保ったまますべての組を比較するランダム化 Tukey HSD 検定を行うことを勧めている(Sakai, 2014)。

この部分はまだ翻訳されていないため、英語で表示している。

Compare runs in an evaluation harness

最終変更:版2026.11.8

The book applies that rule in an evaluation harness, which holds everything fixed except the ranker: the same queries, judgments, metrics and tests, so that two runs differ only in their rankings. lib.metrics.evaluate returns one row per query, which is the shape the paired tests need. compare in lib.significance, a short module that collects this chapter's code, runs the tests on one metric's column from two runs. It returns the mean difference, the bootstrap interval, the permutation and t-test p-values, the effect size, and the wins, losses and ties. Its verdict function applies the book's rule to a result. Keep the per-query frames, and average only at the end.

So run chapter 1's four rankers through it, then make the 3 planned comparisons and the exploratory one:

compare-chapter-one-rankers.py Python 3.12.15 · bm25s 0.3.16 · numpy 2.5.5 · pandas 3.1.1 · scipy 1.18.1 合格
"""Runs chapter 1's four rankers through the harness and applies the Bonferroni threshold to the three planned comparisons and one exploratory comparison. The prose's point rests on the judged@10 lines, the established lines, and the exploratory comparison's p-value and agreement lines."""from lib.fusion import reciprocal_rank_fusionfrom lib.lexical import LexicalSearchfrom lib.metrics import evaluatefrom lib.recorded import cross_encoder_scoresfrom lib.semantic import SemanticSearchfrom lib.significance import compare, verdictfrom lib.store import load_products, load_queries, qrelsqueries, judgments = load_queries("test"), qrels("test")bm25 = LexicalSearch(load_products()).run(queries, k=100)semantic = SemanticSearch().run(queries, k=100)hybrid = reciprocal_rank_fusion([bm25, semantic])score = {(query_id, product_id): value for query_id, product_id, value in cross_encoder_scores().itertuples(index=False)}# chapter 1's rerank: only the top 50 are reordered; the rest keep their hybrid orderreranked = {query_id: sorted(ranking[:50], key=lambda product_id: score[(query_id, product_id)], reverse=True)            + ranking[50:] for query_id, ranking in hybrid.items()}runs = {"bm25": bm25, "semantic": semantic, "hybrid": hybrid, "reranked": reranked}scores = {name: evaluate(run, judgments) for name, run in runs.items()}       # one row per test queryfor name, frame in scores.items():    print(f"{name} ndcg@10: {frame['ndcg@10'].mean():.3f}\n{name} judged@10: {frame['judged@10'].mean():.3f}")planned = [("semantic", "bm25"), ("hybrid", "semantic"), ("reranked", "hybrid")]    # each stage against the lastexploratory = [("reranked", "semantic")]                       # chosen after chapter 1 saw the test meansthreshold = 0.05 / len(planned)                                # Bonferroni, over the planned comparisons onlyprint(f"\nplanned comparisons: {len(planned)}\np-value threshold: {threshold:.4f}\ninterval level: {1 - threshold:.4f}")# each planned test has a 0.95 chance of no false positive, if its gap is noiseprint(f"chance of a false positive, all gaps noise, tests independent: {1 - 0.95 ** len(planned):.3f}")established, disagreements = 0, 0for after, before in planned + exploratory:    result, name = compare(scores[after]["ndcg@10"], scores[before]["ndcg@10"], confidence=1 - threshold), f"{after} minus {before}"    # verdict runs on the exploratory one too, only for its agreement checks; it is never counted as established    checks, kind = verdict(result, threshold), "planned" if (after, before) in planned else "exploratory"    print(f"\n{name}: {result['mean difference']:.3f}\n{name} kind: {kind}")    print(f"{name} interval: {result['ci low']:.3f} to {result['ci high']:.3f}")    print(f"{name} permutation p: {result['permutation p']:.3f}\n{name} t-test p: {result['t-test p']:.3f}")    print(f"{name} effect size: {result['effect size']:.3f}\n{name} wins, losses, ties: {result['wins']} / {result['losses']} / {result['ties']}")    # only a planned comparison can be established; the exploratory one is labelled and never called so    print(f"{name} established: {'yes' if checks['established'] and kind == 'planned' else 'no'}")    for method in ["t-test", "interval"]:        print(f"{name} {method} agrees: {'yes' if checks[method + ' agrees'] else 'no'}")    if kind == "planned":        established += checks["established"]        # a planned comparison where the t-test or the interval disagrees with the permutation test        disagreements += not (checks["t-test agrees"] and checks["interval agrees"])print(f"\nplanned comparisons established: {established}\nplanned comparisons with a disagreement: {disagreements}")
出力python compare-chapter-one-rankers.py
bm25 ndcg@10: 0.725
bm25 judged@10: 0.927
semantic ndcg@10: 0.830
semantic judged@10: 0.990
hybrid ndcg@10: 0.812
hybrid judged@10: 0.980
reranked ndcg@10: 0.798
reranked judged@10: 0.980

planned comparisons: 3
p-value threshold: 0.0167
interval level: 0.9833
chance of a false positive, all gaps noise, tests independent: 0.143

semantic minus bm25: 0.105
semantic minus bm25 kind: planned
semantic minus bm25 interval: 0.047 to 0.205
semantic minus bm25 permutation p: 0.001
semantic minus bm25 t-test p: 0.003
semantic minus bm25 effect size: 0.601
semantic minus bm25 wins, losses, ties: 21 / 7 / 2
semantic minus bm25 established: yes
semantic minus bm25 t-test agrees: yes
semantic minus bm25 interval agrees: yes

hybrid minus semantic: -0.018
hybrid minus semantic kind: planned
hybrid minus semantic interval: -0.048 to 0.006
hybrid minus semantic permutation p: 0.125
hybrid minus semantic t-test p: 0.123
hybrid minus semantic effect size: -0.290
hybrid minus semantic wins, losses, ties: 9 / 14 / 7
hybrid minus semantic established: no
hybrid minus semantic t-test agrees: yes
hybrid minus semantic interval agrees: yes

reranked minus hybrid: -0.014
reranked minus hybrid kind: planned
reranked minus hybrid interval: -0.053 to 0.020
reranked minus hybrid permutation p: 0.382
reranked minus hybrid t-test p: 0.375
reranked minus hybrid effect size: -0.165
reranked minus hybrid wins, losses, ties: 11 / 12 / 7
reranked minus hybrid established: no
reranked minus hybrid t-test agrees: yes
reranked minus hybrid interval agrees: yes

reranked minus semantic: -0.032
reranked minus semantic kind: exploratory
reranked minus semantic interval: -0.078 to -0.003
reranked minus semantic permutation p: 0.048
reranked minus semantic t-test p: 0.048
reranked minus semantic effect size: -0.377
reranked minus semantic wins, losses, ties: 9 / 16 / 5
reranked minus semantic established: no
reranked minus semantic t-test agrees: yes
reranked minus semantic interval agrees: no

planned comparisons established: 1
planned comparisons with a disagreement: 0

Unjudged products weigh most on BM25, whose judged@10 is 0.927 against 0.990 for semantic retrieval, 0.980 for the hybrid and 0.980 for the reranked hybrid.

With 3 tests at 0.05 each, the chance of at least one false positive would be 0.143 if every gap were noise and the tests were independent. The Bonferroni correction caps it at 0.05 either way. On nDCG@10 over the test queries, with intervals at the 0.9833 level:

Measure Semantic minus BM25 Hybrid minus semantic Reranked minus hybrid Reranked minus semantic
Kind planned planned planned exploratory
Mean difference 0.105 -0.018 -0.014 -0.032
Interval 0.047 to 0.205 -0.048 to 0.006 -0.053 to 0.020 -0.078 to -0.003
Permutation p 0.001 0.125 0.382 0.048
t-test p 0.003 0.123 0.375 0.048
Effect size 0.601 -0.290 -0.165 -0.377
Wins / losses / ties 21 / 7 / 2 9 / 14 / 7 11 / 12 / 7 9 / 16 / 5
Established yes no no no

Of the 3 planned comparisons, 1 is established: semantic retrieval's lead over BM25, with a permutation p-value of 0.001. The hybrid's deficit against semantic retrieval and the reranker's against the hybrid are not established: on these queries neither change shows an improvement, and neither is shown to be worse. The harness checks the t-test and the interval against the permutation test: 0 planned comparisons have a disagreement.

The exploratory comparison is where the checks start to disagree. Its permutation p-value is 0.048, to set against 0.05 without a correction and 0.0167 with one, and its interval runs from -0.078 to -0.003.

The t-test sides with the permutation test, but the interval, which excludes 0, does not. Asked whether each check agrees with the permutation test, the harness answers yes for the t-test and no for the interval: an interval that excludes 0 beside a p-value above the threshold is the kind of disagreement the coverage check warns about. Whatever its numbers, this comparison can't be established, because it was chosen after seeing the test means. At most it raises a question for new queries: does this reranker trail semantic retrieval?

Chapter 1's decision stands, by a rule that doesn't depend on which ranker scored highest: the ranker to beat is the simplest pipeline that no planned comparison has shown to be beaten. Semantic retrieval beat BM25, and neither later stage beat the stage before it.

Working rule: For every change, report the mean nDCG@10 and judged@10 of each run, then a table like this one, with a column for each comparison and the exploratory ones labelled. A change ships only when it is established against the ranker to beat.

本番環境で何が問題になるか

最終変更:版2026.11.8

クエリの標本が一つだけでは、誤った結論に導かれることがある。 テストクエリでの結果は、どのクエリがテスト側に入ったかに左右される。Fuhr は、単純なホールドアウト法は結果が分割に大きく依存しうるため信頼できないと論じ、代わりに交差検証を求めている(Fuhr, 2017, section 2.5)。Sakai も「訓練・検証・テストの分割が異なれば、結果も異なりうる」と述べている(Sakai, 2020)。本書では、すべての章が同じテストクエリで報告できるよう、分割を一つに固定している。差がどこまで動きうるかを確かめるには、ハーネスの探索的な比較を訓練クエリでも実行すればよい。ただし訓練クエリはチューニング用であり(ルールが定めるとおりである)、これは証拠ではなく例示として扱う。

split-changes-the-verdict.py Python 3.12.15 · bm25s 0.3.16 · numpy 2.5.5 · pandas 3.1.1 · scipy 1.18.1 合格
"""Runs the reranked-minus-semantic comparison on the test queries and on the train queries, so the verdict can be compared across the two samples. The prose's point rests on the two gap lines and the higher-scoring-run lines."""from lib.fusion import reciprocal_rank_fusionfrom lib.lexical import LexicalSearchfrom lib.metrics import evaluatefrom lib.recorded import cross_encoder_scoresfrom lib.semantic import SemanticSearchfrom lib.significance import comparefrom lib.store import load_products, load_queries, qrelslexical, embeddings = LexicalSearch(load_products()), SemanticSearch()score = {(query_id, product_id): value for query_id, product_id, value in cross_encoder_scores().itertuples(index=False)}for split in ["test", "train"]:                      # the same comparison on another sample of the store's queries    queries, judgments = load_queries(split), qrels(split)    semantic = embeddings.run(queries, k=100)    hybrid = reciprocal_rank_fusion([lexical.run(queries, k=100), semantic])    # as in chapter 1: rerank the top 50 and keep the rest in hybrid order    reranked = {query_id: sorted(ranking[:50], key=lambda product_id: score[(query_id, product_id)], reverse=True)                + ranking[50:] for query_id, ranking in hybrid.items()}    result = compare(evaluate(reranked, judgments)["ndcg@10"], evaluate(semantic, judgments)["ndcg@10"])    gap = result["mean difference"]    print(f"{split} queries:", len(judgments))    print(f"{split} reranked minus semantic: {gap:.3f}")    print(f"{split} higher-scoring run:", "reranked" if gap > 0 else "semantic" if gap < 0 else "neither")    if split == "test":        print(f"test permutation p: {result['permutation p']:.3f}")
出力python split-changes-the-verdict.py
test queries: 30
test reranked minus semantic: -0.032
test higher-scoring run: semantic
test permutation p: 0.048
train queries: 50
train reranked minus semantic: 0.014
train higher-scoring run: reranked

スコアの高い実行は、テストクエリでは semantic、訓練クエリでは reranked であり、どちらの実行のスコアが高いかは分割によって入れ替わる。

30 件のテストクエリでは、リランク済みハイブリッド検索からセマンティック検索を引いた差は -0.032 である(並べ替え検定の p = 0.048)。50 件の訓練クエリでは 0.014 である。一つの標本で p 値が 0.05 にこれほど近い場合、それを土台に判断を積み上げるのは心許ない。第11章では、あらゆる選択にテストクエリを関与させない方法を扱う。

テストクエリを再利用することは、多数の仮説を検定することである。 同じクエリで変更を試すたびに、数か月を隔てていても比較が一つ増える。Fuhr は「コレクションの再利用も、多重仮説検定の一例である」と指摘している(Fuhr, 2017, section 2.7)。テストクエリで行った比較の記録を残し、閾値を定めるときにはその数を数えに入れる。

同点のスコアは、実行の再現性を損なう。 スコアが同じ二つの製品は、どちらの順序でも返りうる。マルチスレッドでのインデックス作成では、スコアが同点のとき順序が非決定的になることがある(Lin and Yang, 2019)。順序が再現できても、それが恣意的であることはある。同点の順序は、ライブラリの上位 k 件の選択や、安定ソートへの入力がたまたま残した順序に落ち着くからである。そこで本書のモジュールは、同点を product_id で解消している。LexicalSearch と lib.fusion は等しいスコアをこの値で並べ、SemanticSearch は product_id の順に保存されたベクトルに対して安定ソートを行う。すべてのバージョンを固定したうえで、re-check examples が各例を記録された出力と突き合わせて再実行するため、これらの順序のいずれかが変われば検出できる。自分のシステムでは、スコアを算出する前に、product_id など情報を持たない固定の順序で同点を解消する。

未判定の製品は、ランカーのスコアを下げる。 誰も判定していない製品を上位に出すランカーは、それらが良い製品であっても nDCG を失う。検定の前に judged@10 を確認し、値が下がったら新しい製品に判定を付ける。

実践ルール: テストクエリで行った比較はすべて記録し、境界的な結果や探索的な結果は新しいクエリに対する問いとして扱い、スコアの同点は固定した順序で解消し、すべての nDCG@10 に並べて judged@10 を報告する。

この章で決めたこと

最終変更:版2026.11.8

以下の各選択は、ここから先の本書の既定である。後の章がそのうちの一つを変えるのは、その章が理由を述べた場合に限る。

  • 主要指標: 線形ゲインの nDCG@10(グレード 2、1、0)、割引は log2(i + 1)、理想ランキングは判定済みの全商品から作る。precision@10 と MRR を併せて報告する。関連ありとは、exact(完全一致)のみを意味する。
  • 自前の指標を基準とする。 本書はlib.metricsの値を報告し、各行に判定済みの全商品を含めたうえで、scikit-learn のndcg_scoreで検算する。
  • すべての比較でクエリごとの差を示す。 平均と中央値、勝ち・負け・引き分けの数、最も大きな損失、そして最も大きく動いたクエリの judged@10 を示す。
  • 差が確立されたとみなす規則: まず、テストクエリに対する計画済みの比較を列挙しておく。差が確立されたとするのは、9,999 回のランダムな符号反転による並べ替え検定の p 値が、0.05 を計画済みの比較の数で割った値を下回る場合である。対応のある t 検定と、それに対応する水準の BCa ブートストラップ区間を併せて報告し、結果が食い違うときはその旨を述べる。テスト結果を見た後で選んだ比較は探索的と明記し、確立されたとは決して呼ばない。train クエリはチューニングにのみ使う。
  • 確立されていない差は「改善は示されていない」と報告する。 損失として報告してはならず、その理由を説明してもならない。
  • リサンプリングはすべて、シードを固定したrngを用い、lib.significanceを通して行う。
  • 計画済みの比較から得られたこと: 第 1 章の比較のうち、意味検索の BM25 に対する優位は確立されたが、他の二つは確立されなかった。したがって、意味検索が引き続き打ち負かすべきランカーである。以後の変更はすべて、変更対象のランカーを相手にハーネスで検証し、打ち負かすべきランカーを上回った場合にのみ採用する。

この版における本章

第2026.11.10版2026年11月19日時点で例が通過この章の12 例件のうち12件が合格

英語版の書籍(版2026.11.10)から翻訳した。

この節を引用する

形式

いずれの形式も、本訳書が従う英語版の書籍を出典として示す。

いずれの形式もこの版を明示している。そのリンクは現行版を開き、節の見出しには本文が最後に変更された日付が示される。アクセス日と取得日は、これを開いた日である。

このページの内容

全11章中の第3章: 検索の測定

  1. Count the relevant products in the top k
  2. Score the first relevant result with reciprocal rank
  3. 割引利得から nDCG を組み立てる
  4. scikit-learn の ndcg_score と照合する
  5. 比較する前に指標を選ぶ
  6. 平均だけでなく、クエリごとの差を読む
  7. 順列検定でギャップを検定する
  8. 対応のあるt検定でp値を求める
  9. 差の大きさを報告する
  10. 何をもって確立とするかを事前に決める
  11. Compare runs in an evaluation harness
  12. 本番環境で何が問題になるか
  13. この章で決めたこと

ページの先頭に戻るすべての章