fuse_by_rank#

scikitplot.corpus.fuse_by_rank(results, *, rrf_k=60, weights=None, top_k=10)[source]#

Combine leg results by weighted reciprocal rank fusion.

Parameters:
resultsiterable of LegResult

One entry per leg. Failed legs contribute nothing but are harmless.

rrf_kint, optional

The standard RRF constant, at least 1. Default 60.

weightsdict, optional

Per-leg weight, finite and non-negative; unlisted legs weigh 1.0. A weight-0 leg contributes nothing and adds no document.

top_kint, optional

Number of fused hits to return.

Returns:
list of (hit, fused_score, contributions)

Descending fused score; ties by ascending identity (doc_id or node_id). hit is the first hit seen for that identity.

Raises:
ValueError

If a hit has neither a doc_id nor a node_id, or a weight or rrf_k is out of range.

TypeError

If a weight or rrf_k has the wrong type.

Parameters:
Return type:

list[tuple[Any, float, tuple[LegContribution, …]]]

Notes

Developer. R2-1: the arithmetic and the tie-break are FusionPolicy, the one rule shared with RetrievalIndex.search and the MCP hybrid retriever. Rank fusion is the default combiner because score-space fusion needs a validated normalization that does not exist for most metrics (ADR-R07-003). Each hit’s contributions are returned, so the fused score can be recomputed and explained from the result.

Fusion keys on doc_id, never on a row offset – the property that kept F-R01-07’s positional coupling out of the fusion path. A hit without an identity is refused: an object address is not stable across processes.