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
MatchErrorinresult.errors) are excluded from tp/fp/fn and surfaced asLinkageMetrics.n_errors. Everygoldpair 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, forlink) pairs compare by order as(left_id, right_id); withdirected=False(fordedupe) both sides canonicalize to an unordered key (frozenset({a, b})), since left/right is arbitrary within one source. The verb is not recoverable fromresultalone, so the caller supplies it —dedupecallers passdirected=False.