INNER CODE UNIT · Python
KendallVariants
linzhiqiu/t2v_metrics · dataset.py:69
def KendallVariants(
gold_scores,
metric_scores,
variant: str = 'acc23',
epsilon: float = 0.0,
) -> Tuple[float, float]:
"""Lightweight, optionally factored versions of variants on Kendall's Tau.
This function calculates the sufficient statistics for tau in two different
ways, either using a Fenwick Tree (`_FenwickTreeSufficientStatistics`) when
`epsilon` is 0 or NumPy matrices (`_MatrixSufficientStatistics`) otherwise.
Note that the latter implementation has an O(n^2) space requirement, which
can be significant for long vectors.
This implementation makes several changes to the SciPy implementation of
Kendall's tau:
1) For the Fenwick tree version, the cython function for computing discordant
pairs is replaced by inline python. This works up to 2x faster for small