Skip to content
induwara.lk
Premium
induwara.lkStatistics · Inter-rater reliability

Weighted Kappa Calculator (Quadratic & Linear)

Compute Cohen's weighted kappa (κw) from a confusion matrix or two lists of ordinal ratings. Quadratic (QWK) and linear weighting, the unweighted κ for reference, and the Landis & Koch agreement band — matching scikit-learn, all in your browser.

By Induwara AshinsanaUpdated Jul 13, 2026
Weighted kappa (κw)Cohen · ordinal
Matches sklearn

Quadratic (QWK) penalises far-apart disagreements more; it is the Kaggle default.

Ordered categories, e.g. grades 1–5 or Low/Med/High.

Load a sample
Edit the header cells to rename categories
A \ B

Diagonal cells (highlighted) are exact agreements. Off-diagonal cells are disagreements the weights penalise by ordinal distance.

Weighted κ (quadratic)
0.5514
Moderate
Unweighted κ
0.3917
Binary agreement reference
Observed agreement
60%
Chance: 34.24%
Total observations (N)
50
3 categories

Weighted disagreement

Observed Σ wᵢⱼ Oᵢⱼ
6.5
Expected Σ wᵢⱼ Eᵢⱼ
14.49

Verified: an independent agreement-form calculation gives 0.5514 — identical to κw.

Weight matrix used

A \ B012
000.2501.000
10.25000.250
21.0000.2500

Disagreement weight wᵢⱼ per cell (0 on the diagonal).

Expected (chance) matrix

A \ B012Total
0104.4857.3614.1616
135.32128.7444.9419
214.266.983.915
Total142313

Eᵢⱼ = Rᵢ·Cⱼ / N under the independence assumption. Top number = observed count, bottom = expected.

Runs entirely in your browser — no data leaves your device. Formulas: Cohen (1968) weighted kappa; Landis & Koch (1977) agreement bands; cross-checked against sklearn.metrics.cohen_kappa_score. Sources cited below the tool.

How it works

Weighted kappa measures how much two raters agree on an ordinalscale — grades 1–5, severity Low/Medium/High, or a model's predicted class versus the true label — while giving partial credit for near misses. It follows Cohen's 1968 definition and reproduces scikit-learn's cohen_kappa_score to the digit.

  1. Arrange your data as a k×k count matrix O, where Oij is the number of items rater A put in category i and rater B in category j. N is the grand total.
  2. Compute the row totals Ri and column totals Cj, then the expected matrix Eij = Ri·Cj / N. This is what the counts would look like if the two raters were independent.
  3. Build the disagreement weight matrix, which is zero on the diagonal and grows with the distance between categories:
    • Linear: wᵢⱼ = |i − j| / (k − 1)
    • Quadratic: wᵢⱼ = (i − j)² / (k − 1)²
  4. Take the weighted sums of the observed and expected matrices, then apply Cohen's formula:

    κw = 1 − (Σ wᵢⱼ Oᵢⱼ) / (Σ wᵢⱼ Eᵢⱼ)

    A κw of 1 means perfect agreement, 0 means chance-level, and negatives mean worse than chance.

The (k − 1) normalisation in the weights cancels in the ratio, so this form is identical to the unnormalised weights scikit-learn uses. The unweighted κ shown alongside is the same calculation with binary weights (0 on the diagonal, 1 everywhere else), which reduces to the familiar κ = (po − pe) / (1 − pe). Because weighting hands out partial credit for near-misses, you will normally see quadratic κ ≥ linear κ ≥ unweighted κ on the same matrix — a quick sanity check that the numbers are right.

To label the strength of agreement, the tool uses the Landis & Koch (1977) bands: below 0 is poor (worse than chance), up to 0.20 is slight, 0.40 fair, 0.60 moderate, 0.80 substantial, and above that almost perfect. Every result is verified internally by recomputing κw through an equivalent agreement-weight form; the two paths must produce the same number.

Worked examples

All three examples use the same 3×3 matrix (k = 3, N = 50), rows = Rater A, columns = Rater B: [[10, 5, 1], [3, 12, 4], [1, 6, 8]]. Expected diagonal: E₀₀ = 4.48, E₁₁ = 8.74, E₂₂ = 3.90.

Example 1 — Quadratic (QWK)

κw = 0.5514 · Moderate

  1. Weights wᵢⱼ = (i − j)²/4 → off-by-one = 0.25, off-by-two = 1
  2. Observed Σ w·O = 2.25 + 1.75 + 2.50 = 6.50
  3. Expected Σ w·E = 6.00 + 2.565 + 5.925 = 14.49
  4. κw = 1 − 6.50 / 14.49 = 0.5514

Example 2 — Linear (same matrix)

κw = 0.4665 · Moderate

  1. Weights wᵢⱼ = |i − j|/2 → off-by-one = 0.5, off-by-two = 1
  2. Observed Σ w·O = 3.5 + 3.5 + 4.0 = 11.00
  3. Expected Σ w·E = 7.84 + 5.13 + 7.65 = 20.62
  4. κw = 1 − 11.00 / 20.62 = 0.4665
  5. Unweighted κ for reference = 0.3917 (Fair) — confirms quadratic ≥ linear ≥ unweighted

Example 3 — Edge case: systematic disagreement

κw = −1.0000 · Poor

  1. Matrix [[0, 10], [10, 0]] — raters always pick opposite categories (k = 2, N = 20)
  2. Quadratic weight for the single off-diagonal pair = 1; expected matrix is all 5s
  3. Observed Σ w·O = 20, Expected Σ w·E = 10
  4. κw = 1 − 20 / 10 = −1.0000 → worse than chance
  5. If instead every item fell in one category, Σ w·E = 0 and κw is reported as "Not defined".

Frequently asked questions

Sources & references

Related tools

Rate this tool
Be the first to rate

Comments & feedback

Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.

Found a bug, edge case, or want to suggest an improvement?

Email me at [email protected] — most fixes ship within 24 hours.