pearson_cc()

audmetric.pearson_cc(truth, prediction)[source]

Pearson correlation coefficient.

ρ=cov(prediction,truth)σpredictionσtruth\rho = \frac{\text{cov}(\text{prediction}, \text{truth})}{ \sigma_\text{prediction}\sigma_\text{truth}}

where σ\sigma is the standard deviation, and cov\text{cov} is the covariance.

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

  • prediction (Sequence[float]) – predicted values

Return type

float

Returns

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

Raises

ValueError – if truth and prediction differ in length

Examples

>>> pearson_cc([0, 1, 2], [0, 1, 1])
0.8660254037844385