Implement Cohen's kappa, an inter-rater agreement metric that corrects for chance agreement.
Signature: def cohen_kappa(rater1: list, rater2: list) -> float
Where:
p_o = observed agreement = fraction of items both raters agree onp_e = expected agreement by chance, computed from the marginals (sum_k p1_k * p2_k)kappa = (p_o - p_e) / (1 - p_e)Returns 1.0 for perfect agreement, 0.0 for chance-level, negative for worse-than-chance.
Math
Asked at
import numpy as np
def cohen_kappa(...):
pass
Premium problem
Free accounts include problems #1–20. Upgrade to unlock the editor, hidden test cases, and reference solutions for every problem.
Already premium?