Cohens Kappa Calculator: Formula and Worked Example

This free Cohens kappa calculator measures how much two raters agree on a yes/no label once you remove the agreement they would reach by pure chance. Type the four counts from your 2×2 agreement table, press the button and you get kappa, the observed and expected agreement, and the full working.

κ = (po − pe) / (1 − pe)
Items rated (n)—
Observed agreement po—
Chance agreement pe—
Cohen’s kappa—
Rater A Yes rate—
Rater B Yes rate—
Landis and Koch—
McHugh—
Working appears here.
Your 2×2 agreement table
B: YesB: NoRow total
A: Yes———
A: No———
Column total———
Example loaded. Press Calculate kappa.

What is Cohen's kappa? The formula

Cohen's kappa (κ) is a score for agreement between two raters who each sort the same items into categories. It compares the agreement you actually see with the agreement you would expect if both raters labelled at random with their own habits. Jacob Cohen proposed it in 1960 in Educational and Psychological Measurement.

\[ \kappa = \frac{p_o - p_e}{1 - p_e} \]

For a 2×2 table with cells \( a \) (both Yes), \( b \) (A Yes, B No), \( c \) (A No, B Yes), \( d \) (both No) and \( n = a + b + c + d \):

\[ p_o = \frac{a + d}{n}, \qquad p_e = \frac{(a+b)(a+c) + (c+d)(b+d)}{n^2} \]

\( p_o \) is the share of items where the raters match. \( p_e \) multiplies each rater's Yes rate together, does the same for No, and adds the two: that is the agreement two independent raters would reach by luck. Kappa is 1 for perfect agreement, 0 when agreement is exactly what chance predicts, and negative when the raters agree less often than chance.

cohens kappa calculator chart

Cohens kappa calculator: how to use it

Cross-tabulate the two sets of labels first. This is the same layout as a confusion matrix, except that neither rater is treated as the ground truth. Then enter the four cells:

  • a: items both raters called Yes.
  • b and c: the two kinds of disagreement.
  • d: items both raters called No.

The Cohens kappa calculator shows \( p_o \), \( p_e \), each rater's Yes rate, kappa, a working line, and where kappa falls on two published interpretation scales. Swapping \( b \) and \( c \) gives the same kappa, because the formula treats the two raters symmetrically.

Worked example: two annotators labelling spam

Two people label the same 100 emails as spam or not spam for a training set. Their table is \( a = 40 \), \( b = 10 \), \( c = 5 \), \( d = 45 \) (the calculator's default).

  1. Observed agreement. \( p_o = (40 + 45) / 100 = 0.85 \). They match on 85% of emails.
  2. Each rater's Yes rate. Rater A says spam for \( 50/100 = 0.5 \); rater B for \( 45/100 = 0.45 \).
  3. Chance agreement. \( p_e = 0.5 \times 0.45 + 0.5 \times 0.55 = 0.225 + 0.275 = 0.5 \).
  4. Kappa. \( \kappa = (0.85 - 0.5) / (1 - 0.5) = 0.35 / 0.5 = 0.7 \).

So 85% raw agreement turns into a kappa of 0.7: the raters close 70% of the gap between chance agreement and perfect agreement.

How good is 0.7? The most quoted bands come from Landis and Koch (1977): below 0 poor, 0 to 0.20 slight, 0.21 to 0.40 fair, 0.41 to 0.60 moderate, 0.61 to 0.80 substantial, and 0.81 to 1 almost perfect. On that scale 0.7 is substantial. McHugh (2012) argued those bands are too lenient for health research and proposed stricter ones (0.60 to 0.79 moderate, 0.80 to 0.90 strong, above 0.90 almost perfect), which would call the same 0.7 only moderate. The authors chose these cut-offs by judgement, so state which scale you used.

When to use Cohen's kappa (and when not to)

Use it when:

  • Exactly two raters label the same items, such as two annotators building a dataset.
  • The labels are nominal categories (two or more).
  • You want to check label quality before training. Noisy labels cap any model and can hide bias in machine learning.

Avoid or adjust it when:

  • You have three or more raters: use Fleiss' kappa or Krippendorff's alpha.
  • The categories are ordered (1 to 5 stars): use weighted kappa, so a 4-versus-5 disagreement costs less than 1-versus-5.
  • One category is very rare. Kappa then depends heavily on prevalence, as the next section shows; this is the same trap that affects imbalanced datasets.

Press Try the prevalence paradox in the Cohens kappa calculator above: \( a = 90 \), \( b = 5 \), \( c = 5 \), \( d = 0 \). The raters agree on 90% of items, yet \( p_e = 0.905 \) and kappa comes out at −0.0526. The chart above shows the same effect: with observed agreement fixed at 90%, kappa is 0.8 when Yes and No are equally common and falls below zero as Yes approaches 95% of items.

Cohen's kappa vs percent agreement

The nearest alternative is plain percent agreement, \( p_o \). When kappa is used to score a classifier against true labels, it also sits beside the Matthews correlation coefficient, which looks at the same 2×2 table.

Percent agreementCohen's kappaMCC
Formula\( (a+d)/n \)\( (p_o - p_e)/(1 - p_e) \)\( \frac{ad - bc}{\sqrt{(a+b)(a+c)(b+d)(c+d)}} \)
Range0 to 1−1 to 1−1 to 1
Corrects for chanceNoYesYes (correlation)
Spam example0.850.7about 0.70
Typical useQuick sanity checkInter-rater reliabilityClassifier evaluation

Percent agreement rises as one class dominates, because two raters who say "No" to almost everything match by default. Kappa removes that free agreement. For more options, see classification metrics, along with precision and recall and the F1 score.

Common mistakes

  • Reporting only percent agreement. 90% agreement can mean a kappa near zero when one label dominates.
  • Comparing kappas across datasets with different class balance. A lower kappa on a rarer label does not by itself mean worse raters.
  • Treating the bands as tests. "Substantial" is a convention, not a significance result. With few items, kappa is noisy; report \( n \) and, if you can, a confidence interval.
  • Expecting kappa to reach 1. If the raters' Yes rates differ, the highest possible kappa is below 1.
  • Using unweighted kappa on ordinal scores, which throws away how far apart the disagreements are.

In Python, scikit-learn computes it from two label lists with sklearn.metrics.cohen_kappa_score, which also accepts weights="linear" or "quadratic" for weighted kappa. Background and the multi-class formula are on Wikipedia's Cohen's kappa page. For the probability ideas behind \( p_e \), see statistics for machine learning.

Frequently asked questions

What is a good Cohen's kappa value?

It depends on the field and the scale. Under Landis and Koch, above 0.60 is substantial; McHugh's stricter scale needs 0.80 before calling agreement strong. No single threshold is universal.

Can Cohen's kappa be negative?

Yes. A negative kappa means the raters agree less often than chance would predict. Total disagreement with balanced classes, for example \( a = d = 0 \) and \( b = c = 10 \), gives exactly −1.

Why is my kappa low when agreement is high?

Usually because one category dominates. That pushes \( p_e \) close to 1, leaving little room above chance. Report percent agreement and each rater's class rates alongside kappa so readers can see why.

Is the Cohens kappa calculator only for 2×2 tables?

This Cohens kappa calculator handles two categories. For more categories, use the same formula with \( p_o \) as the sum of the diagonal divided by \( n \) and \( p_e \) as the sum over classes of the two raters' rates multiplied together; scikit-learn's function does this automatically.

When is kappa undefined?

When both raters put every item in the same single category, \( p_e = 1 \) and the formula divides by zero. The calculator reports this case instead of a number.

Scroll to Top