Cohen kappa numerator denominator

Write codeMedium16 minAnthropic and OpenAI style

Your task

Cohen's kappa corrects raw annotator agreement for agreement that would happen by chance. For two equal-length binary label lists a and b of length n, let agree be the count of positions where a[i] == b[i], let pp = (count of 1s in a) * (count of 1s in b), and nn = (count of 0s in a) * (count of 0s in b). Kappa equals (n * agree - (pp + nn)) / (n * n - (pp + nn)). Return the exact integer pair [n * agree - (pp + nn), n * n - (pp + nn)] without dividing. Example: a = [1, 1, 0, 0], b = [1, 0, 0, 0] gives [4, 8].

Examples

kappa_parts(a: list[int], b: list[int]) -> list[int]
Example 1
Inputkappa_parts([1, 1, 0, 0], [1, 0, 0, 0])
Output[4, 8]