All problems
Cohen Kappa from Counts
Problem
Cohen's kappa is (p_o - p_e) / (1 - p_e), where p_o is observed agreement and p_e the agreement expected from the margins.
Given p_o and p_e, return kappa. Return 0.0 when p_e equals one.
Hint
The correction removes agreement achievable by chance.
Test cases
case 1
in: [0.8,0.5]
expected: 0.6000000000000001
case 2
in: [0.6,0.6]
expected: 0
case 3
in: [1,0.5]
expected: 1
Starter codePython
def cohen_kappa_from_counts(p_observed, p_expected):
# Your code here
pass3 test cases · run your code against them in the editor