Compute Cohen’s kappa for two raters. It corrects observed agreement for agreement expected from each rater’s label frequencies.
κ=1−pepo−pe po=nmatching labels pe=k∑nc1,knc2,kHere, n is the number of rated items, k ranges over every label used by either rater, and c1,k and c2,k are the raters’ counts for label k. If pe=1, return 1.0. Otherwise return the kappa score as a Python float.
Input: rater1 = [0, 1, 0, 1], rater2 = [0, 1, 0, 1]
Output: 1
Explanation: Every paired rating agrees, so kappa indicates perfect agreement.
Input: rater1 = [0, 0, 1, 1], rater2 = [0, 1, 1, 0]
Output: 0
Build the label set with set(rater1) | set(rater2).
For each label, multiply its two separate frequency fractions and add them to p_e.
Sign in to take notes on this problem
Accepts: array
Accepts: array
Compute Cohen’s kappa for two raters. It corrects observed agreement for agreement expected from each rater’s label frequencies.
κ=1−pepo−pe po=nmatching labels pe=k∑nc1,knc2,kHere, n is the number of rated items, k ranges over every label used by either rater, and c1,k and c2,k are the raters’ counts for label k. If pe=1, return 1.0. Otherwise return the kappa score as a Python float.
Input: rater1 = [0, 1, 0, 1], rater2 = [0, 1, 0, 1]
Output: 1
Explanation: Every paired rating agrees, so kappa indicates perfect agreement.
Input: rater1 = [0, 0, 1, 1], rater2 = [0, 1, 1, 0]
Output: 0
Build the label set with set(rater1) | set(rater2).
For each label, multiply its two separate frequency fractions and add them to p_e.
Sign in to take notes on this problem
Accepts: array
Accepts: array