Cohen's Kappa

easy
Unit 2 · Metrics0/3 to milestone

Cohen's kappa measures agreement between two raters beyond what chance would give:

κ=po−pe1−pe\kappa = \frac{p_o - p_e}{1 - p_e}

where pop_o is observed agreement and pe=∑kpa,k pb,kp_e = \sum_k p_{a,k}\, p_{b,k} uses each rater's label frequencies.

Implement cohens_kappa(a, b) for any label set. If pe=1p_e = 1 (both raters always say the same single label), return 1.0.

#metrics#agreement2 visible + 1 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Cohen's Kappa · TechGradify