INNER CODE UNIT · Python
calc_pearson
linzhiqiu/t2v_metrics · dataset.py:14
def calc_pearson(metric1_scores, metric2_scores):
pearson = 100*np.corrcoef(metric1_scores, metric2_scores)[0, 1]
return pearson
# The original Kendall-Tau is not robust against ties.
# We adopt the pairwise accuracy with tau optimization as proposed in EMNLP'23 Best paper
# Code borrowed from:
# https://github.com/google-research/mt-metrics-eval/blob/main/mt_metrics_eval/ties_matter.ipynb
def _MatrixSufficientStatistics(
x,
y,
epsilon: float,
) -> Tuple[int, int, int, int, int]:
"""Calculates tau sufficient statistics using matrices in NumPy.
An absolute difference less than `epsilon` in x pairs is considered to be
a tie.