balanced_accuracy_pairs: Balanced Accuracy of Linked Pairs

View source: R/measures_pairs.R

balanced_accuracy_pairsR Documentation

Balanced Accuracy of Linked Pairs

Description

Computes the balanced accuracy of a set of predicted coreferent (linked) pairs given a set of ground truth coreferent pairs.

Usage

balanced_accuracy_pairs(true_pairs, pred_pairs, num_pairs, ordered = FALSE)

Arguments

true_pairs

set of true coreferent pairs stored in a matrix or data.frame, where rows index pairs and columns index the ids of the constituents. Any pairs not included are assumed to be non-coreferent. Duplicate pairs (including equivalent pairs with reversed ids) are automatically removed.

pred_pairs

set of predicted coreferent pairs, following the same specification as true_pairs.

num_pairs

the total number of coreferent and non-coreferent pairs, excluding equivalent pairs with reversed ids.

ordered

whether to treat the element pairs as ordered—i.e. whether pair (x, y) is distinct from pair (y, x) for x \neq y. Defaults to FALSE, which is appropriate for clustering, undirected link prediction, record linkage etc.

Details

The balanced accuracy is defined as:

\frac{\frac{|T \cap P|}{|P|} + \frac{|T' \cap P'|}{|P'|}}{2}

where:

  • T is the set of true coreferent pairs,

  • P is the set of predicted coreferent pairs,

  • T' is the set of true non-coreferent pairs, and

  • P' is the set of predicted non-coreferent pairs.

Examples

true_pairs <- rbind(c(1,2), c(2,3), c(1,3)) # ground truth is 3-clique
pred_pairs <- rbind(c(1,2), c(2,3))         # prediction misses one edge
num_pairs <- 3                              # assuming 3 elements
balanced_accuracy_pairs(true_pairs, pred_pairs, num_pairs)


clevr documentation built on Sept. 16, 2023, 5:06 p.m.