Sub topic 13
Attribute Agreement Analysis and Cohen's Kappa
Prerequisites and purpose
This chapter assumes that you understand probability, contingency tables, process specifications, and the basic MSA terms repeatability and reproducibility. It also assumes that measurements may be categorical rather than numeric.
An attribute measurement system assigns categories such as pass/fail, defect type, or severity level. Attribute agreement analysis checks whether inspectors make consistent decisions and whether those decisions match a trusted reference standard.
A system can show high agreement between inspectors while still being wrong. For example, two inspectors may consistently accept defective parts. Therefore, evaluate both:
- Within-appraiser agreement: whether one inspector gives the same result on repeated trials.
- Between-appraiser agreement: whether inspectors agree with one another.
- Agreement with the standard: whether the result matches a known reference or expert classification.
Designing an attribute agreement study
Select parts that represent the actual range of conditions. Include clear examples, borderline examples, and, when possible, examples from each important defect category. Randomize the presentation order so that inspectors cannot remember their previous answers.
A typical study uses several inspectors, multiple trials, and a reference classification. Each inspector evaluates every part independently in each trial.
| Study element | Practical choice | Reason |
|---|---|---|
| Parts | 20–50 | Covers normal and borderline conditions |
| Inspectors | 2–3 or more | Estimates reproducibility |
| Trials | 2 or 3 | Estimates repeatability |
| Reference result | Expert or validated test | Measures correctness |
Control the inspection conditions. Use the same instructions, lighting, fixtures, and decision rules that inspectors use in production. Do not coach inspectors during the study.
flowchart TD
A[Select representative parts] --> B[Establish reference classifications]
B --> C[Randomize part order]
C --> D[Each inspector evaluates each part]
D --> E[Repeat evaluations]
E --> F[Compare within, between, and reference agreement]
F --> G[Improve rules or inspection method]Cohen's kappa
Percent agreement is easy to understand, but it does not account for agreement that could occur by chance. Cohen's kappa corrects observed agreement using the category proportions of two raters.
The formula is:
kappa = (observed agreement - expected agreement) / (1 - expected agreement)
Observed agreement is the fraction of identical ratings. Expected agreement is the agreement predicted from each rater's marginal category frequencies. A kappa of 1 means perfect agreement, 0 means no more agreement than expected by chance, and a negative value means agreement is worse than chance.
def cohens_kappa(rater_a, rater_b):
"""Return Cohen's kappa for two categorical raters."""
if len(rater_a) != len(rater_b) or not rater_a:
raise ValueError("Ratings must be nonempty and have equal length")
n = len(rater_a)
categories = set(rater_a) | set(rater_b)
observed = sum(a == b for a, b in zip(rater_a, rater_b)) / n
expected = sum(
(rater_a.count(c) / n) * (rater_b.count(c) / n)
for c in categories
)
if expected == 1:
return 1.0
return (observed - expected) / (1 - expected)
a = ["pass", "pass", "fail", "pass", "fail", "fail", "pass", "pass"]
b = ["pass", "fail", "fail", "pass", "fail", "pass", "pass", "pass"]
print(round(cohens_kappa(a, b), 3))This example prints approximately 0.467. The raters agree on 75% of items, but the kappa is lower after correcting for chance.
Interpreting the result
Common descriptive guidelines classify kappa below 0.40 as weak, 0.40 to 0.75 as moderate to good, and above 0.75 as strong. These are screening guidelines, not universal acceptance rules. Use the risk of a false accept or false reject, customer requirements, and the process decision when setting limits.
Kappa can be misleading when one category is very common. Two raters may have high percent agreement but a low kappa because chance agreement is already high. Always review the contingency table and the false-accept and false-reject counts.
For ordered categories such as minor, moderate, and severe, use weighted kappa so that a one-level disagreement is treated differently from a major disagreement. Cohen's kappa is for two raters. Fleiss' kappa or another multi-rater method is needed for several raters.
Exercise
Two inspectors agree on 90 of 100 parts, but both disagree with the validated reference on 15 of those parts. Is the system adequate based only on between-inspector agreement?
Show answer
No. Between-inspector agreement is high, but agreement with the reference is only 75%. Investigate the decision rules, training, and inspection conditions before accepting the system.