denselinkage.metrics.linkage_metrics

denselinkage.metrics.linkage_metrics(result: LinkageResult, *, gold: LabeledPairs, directed: bool = True) LinkageMetrics[source]

Precision/recall/F1 over all candidate pairs against gold.

Errored pairs (a MatchError in result.errors) are excluded from tp/fp/fn and surfaced as LinkageMetrics.n_errors. Every gold pair not predicted a match counts as a false negative — including gold pairs the blocker never surfaced — so recall is honest end-to-end. (A gold pair that errored is excluded rather than charged as a false negative.)

Pair identity (D1): with directed=True (the default, for link) pairs compare by order as (left_id, right_id); with directed=False (for dedupe) both sides canonicalize to an unordered key (frozenset({a, b})), since left/right is arbitrary within one source. The verb is not recoverable from result alone, so the caller supplies it — dedupe callers pass directed=False.