concordance_cc()

audmetric.concordance_cc(truth, prediction, *, ignore_nan=False)[source]

Concordance correlation coefficient.

ρc=2ρσpredictionσtruthσprediction2+σtruth2+(μpredictionμtruth)2\rho_c = \frac{2\rho\sigma_\text{prediction}\sigma_\text{truth}} {\sigma_\text{prediction}^2 + \sigma_\text{truth}^2 + ( \mu_\text{prediction}-\mu_\text{truth})^2}

where ρ\rho is the Pearson correlation coefficient, μ\mu the mean and σ2\sigma^2 the variance.1

1

Lawrence I-Kuei Lin. A concordance correlation coefficient to evaluate reproducibility. Biometrics, 45:255–268, 1989. doi:10.2307/2532051.

Parameters
  • truth (Sequence[float]) – ground truth values

  • prediction (Sequence[float]) – predicted values

  • ignore_nan (bool) – if True all samples that contain NaN in truth or prediction are ignored

Return type

float

Returns

concordance correlation coefficient [1,1]\in [-1, 1]

Raises

ValueError – if truth and prediction differ in length

Examples

>>> concordance_cc([0, 1, 2], [0, 1, 1])
0.6666666666666665