# Cohen's kappa in plain English

I am reading a data mining book and it mentioned the Kappa statistic as a means for evaluating the prediction performance of classifiers. However, I just can't understand this. I also checked Wikipedia but it didn't help too: https://en.wikipedia.org/wiki/Cohen's_kappa.

How does Cohen's kappa help in evaluating the prediction performance of classifiers? What does it tell?

I understand that 100% kappa means that the classifier is in total agreement with a random classifier, but I don't understand how does this help in evaluating the performance of the classifier?

What does 40% kappa mean? Does it mean that 40% of the time, the classifier is in agreement with the random classifier? If so, what does that tell me or help me in evaluating the classifier?

Introduction

The Kappa statistic (or value) is a metric that compares an Observed Accuracy with an Expected Accuracy (random chance). The kappa statistic is used not only to evaluate a single classifier, but also to evaluate classifiers amongst themselves. In addition, it takes into account random chance (agreement with a random classifier), which generally means it is less misleading than simply using accuracy as a metric (an Observed Accuracy of 80% is a lot less impressive with an Expected Accuracy of 75% versus an Expected Accuracy of 50%). Computation of Observed Accuracy and Expected Accuracy is integral to comprehension of the kappa statistic, and is most easily illustrated through use of a confusion matrix. Lets begin with a simple confusion matrix from a simple binary classification of Cats and Dogs:

Computation

     Cats Dogs
Cats| 10 | 7  |
Dogs| 5  | 8  |


Assume that a model was built using supervised machine learning on labeled data. This doesn't always have to be the case; the kappa statistic is often used as a measure of reliability between two human raters. Regardless, columns correspond to one "rater" while rows correspond to another "rater". In supervised machine learning, one "rater" reflects ground truth (the actual values of each instance to be classified), obtained from labeled data, and the other "rater" is the machine learning classifier used to perform the classification. Ultimately it doesn't matter which is which to compute the kappa statistic, but for clarity's sake lets say that the columns reflect ground truth and the rows reflect the machine learning classifier classifications.

From the confusion matrix we can see there are 30 instances total (10 + 7 + 5 + 8 = 30). According to the first column 15 were labeled as Cats (10 + 5 = 15), and according to the second column 15 were labeled as Dogs (7 + 8 = 15). We can also see that the model classified 17 instances as Cats (10 + 7 = 17) and 13 instances as Dogs (5 + 8 = 13).

Observed Accuracy is simply the number of instances that were classified correctly throughout the entire confusion matrix, i.e. the number of instances that were labeled as Cats via ground truth and then classified as Cats by the machine learning classifier, or labeled as Dogs via ground truth and then classified as Dogs by the machine learning classifier. To calculate Observed Accuracy, we simply add the number of instances that the machine learning classifier agreed with the ground truth label, and divide by the total number of instances. For this confusion matrix, this would be 0.6 ((10 + 8) / 30 = 0.6).

Before we get to the equation for the kappa statistic, one more value is needed: the Expected Accuracy. This value is defined as the accuracy that any random classifier would be expected to achieve based on the confusion matrix. The Expected Accuracy is directly related to the number of instances of each class (Cats and Dogs), along with the number of instances that the machine learning classifier agreed with the ground truth label. To calculate Expected Accuracy for our confusion matrix, first multiply the marginal frequency of Cats for one "rater" by the marginal frequency of Cats for the second "rater", and divide by the total number of instances. The marginal frequency for a certain class by a certain "rater" is just the sum of all instances the "rater" indicated were that class. In our case, 15 (10 + 5 = 15) instances were labeled as Cats according to ground truth, and 17 (10 + 7 = 17) instances were classified as Cats by the machine learning classifier. This results in a value of 8.5 (15 * 17 / 30 = 8.5). This is then done for the second class as well (and can be repeated for each additional class if there are more than 2). 15 (7 + 8 = 15) instances were labeled as Dogs according to ground truth, and 13 (8 + 5 = 13) instances were classified as Dogs by the machine learning classifier. This results in a value of 6.5 (15 * 13 / 30 = 6.5). The final step is to add all these values together, and finally divide again by the total number of instances, resulting in an Expected Accuracy of 0.5 ((8.5 + 6.5) / 30 = 0.5). In our example, the Expected Accuracy turned out to be 50%, as will always be the case when either "rater" classifies each class with the same frequency in a binary classification (both Cats and Dogs contained 15 instances according to ground truth labels in our confusion matrix).

The kappa statistic can then be calculated using both the Observed Accuracy (0.60) and the Expected Accuracy (0.50) and the formula:

Kappa = (observed accuracy - expected accuracy)/(1 - expected accuracy)


So, in our case, the kappa statistic equals: (0.60 - 0.50)/(1 - 0.50) = 0.20.

As another example, here is a less balanced confusion matrix and the corresponding calculations:

     Cats Dogs
Cats| 22 | 9  |
Dogs| 7  | 13 |


Ground truth: Cats (29), Dogs (22)
Machine Learning Classifier: Cats (31), Dogs (20)
Total: (51)
Observed Accuracy: ((22 + 13) / 51) = 0.69
Expected Accuracy: ((29 * 31 / 51) + (22 * 20 / 51)) / 51 = 0.51
Kappa: (0.69 - 0.51) / (1 - 0.51) = 0.37

In essence, the kappa statistic is a measure of how closely the instances classified by the machine learning classifier matched the data labeled as ground truth, controlling for the accuracy of a random classifier as measured by the expected accuracy. Not only can this kappa statistic shed light into how the classifier itself performed, the kappa statistic for one model is directly comparable to the kappa statistic for any other model used for the same classification task.

Interpretation

There is not a standardized interpretation of the kappa statistic. According to Wikipedia (citing their paper), Landis and Koch considers 0-0.20 as slight, 0.21-0.40 as fair, 0.41-0.60 as moderate, 0.61-0.80 as substantial, and 0.81-1 as almost perfect. Fleiss considers kappas > 0.75 as excellent, 0.40-0.75 as fair to good, and < 0.40 as poor. It is important to note that both scales are somewhat arbitrary. At least two further considerations should be taken into account when interpreting the kappa statistic. First, the kappa statistic should always be compared with an accompanied confusion matrix if possible to obtain the most accurate interpretation. Consider the following confusion matrix:

     Cats Dogs
Cats| 60 | 125 |
Dogs| 5  | 5000|


The kappa statistic is 0.47, well above the threshold for moderate according to Landis and Koch and fair-good for Fleiss. However, notice the hit rate for classifying Cats. Less than a third of all Cats were actually classified as Cats; the rest were all classified as Dogs. If we care more about classifying Cats correctly (say, we are allergic to Cats but not to Dogs, and all we care about is not succumbing to allergies as opposed to maximizing the number of animals we take in), then a classifier with a lower kappa but better rate of classifying Cats might be more ideal.

Second, acceptable kappa statistic values vary on the context. For instance, in many inter-rater reliability studies with easily observable behaviors, kappa statistic values below 0.70 might be considered low. However, in studies using machine learning to explore unobservable phenomena like cognitive states such as day dreaming, kappa statistic values above 0.40 might be considered exceptional.

So, in answer to your question about a 0.40 kappa, it depends. If nothing else, it means that the classifier achieved a rate of classification 2/5 of the way between whatever the expected accuracy was and 100% accuracy. If expected accuracy was 80%, that means that the classifier performed 40% (because kappa is 0.4) of 20% (because this is the distance between 80% and 100%) above 80% (because this is a kappa of 0, or random chance), or 88%. So, in that case, each increase in kappa of 0.10 indicates a 2% increase in classification accuracy. If accuracy was instead 50%, a kappa of 0.4 would mean that the classifier performed with an accuracy that is 40% (kappa of 0.4) of 50% (distance between 50% and 100%) greater than 50% (because this is a kappa of 0, or random chance), or 70%. Again, in this case that means that an increase in kappa of 0.1 indicates a 5% increase in classification accuracy.

Classifiers built and evaluated on data sets of different class distributions can be compared more reliably through the kappa statistic (as opposed to merely using accuracy) because of this scaling in relation to expected accuracy. It gives a better indicator of how the classifier performed across all instances, because a simple accuracy can be skewed if the class distribution is similarly skewed. As mentioned earlier, an accuracy of 80% is a lot more impressive with an expected accuracy of 50% versus an expected accuracy of 75%. Expected accuracy as detailed above is susceptible to skewed class distributions, so by controlling for the expected accuracy through the kappa statistic, we allow models of different class distributions to be more easily compared.

That's about all I have. If anyone notices anything left out, anything incorrect, or if anything is still unclear, please let me know so I can improve the answer.

Includes a succinct description of kappa: http://standardwisdom.com/softwarejournal/2011/12/confusion-matrix-another-single-value-metric-kappa-statistic/

Includes a description of calculating expected accuracy: http://epiville.ccnmtl.columbia.edu/popup/how_to_calculate_kappa.html

• The calculation of the Expected accuracy's second term (for dogs) seems to be wrong to me?... Isn't it ((5 + 8) + (7 + 8)) / 28 ? – Hakim Jul 18 '15 at 22:04
• Adding some background as to why the expected frequency of a cell is equal to rowsum * colsum / N, as this is the reduced version and it is not obvious in the beginning why the equation holds. This is used in Chi-Square testing as well: en.wikipedia.org/wiki/… – Berkan Dec 23 '15 at 8:13
• this is a great answer but i'm wondering if you could shed anymore light (or links!) on how a very dominant class may affect interpretation of kappa. For eg, I have a conf matrix of 7 land cover classes and one of them is dominant (~70% of all data). I presume this 'watering down' the overall error? – Sam May 26 '16 at 12:10
• Just a random comment: your description is much clearer than the Wikipedia page :) – R.Falque Jul 22 '16 at 1:57
• For expected accuracy, note that it may be simpler to think of as follows: (15/30) is the expected proportion of times the "ground truth" classifies something a cat, and (15/30) is the expected proportion of times the "ground truth" classifies something a dog. Likewise, for the ML classifier (17/30) expected proportion cats, (13/30) expected proportion dogs. Assume uncorrelated classifiers, then we have percentage of time classifiers agree by chance as (15/30)*(17/30)+(15/30)*(13/30) = .5 (either they agree and classify as dog or as cat). Hence, .5 of time agreement is by chance. – ClownInTheMoon Apr 13 '18 at 17:55

rbx has a great answer. However, it is a little bit verbose. Here is my summary and intuition behind the Kappa metric.

Kappa is an important measure on classifier performance, especially on imbalanced data set.

For example, in credit card fraud detection, the marginal distribution of the response variable is high skewed, that using accuracy as a measure will not be useful. In other words, for given fraud detection example, 99.9% of the transactions will be non-fraud transactions. We can have a trivial classifier that always says non-fraud to every transaction, and we will still have 99.9% of the accuracy.

On the other hand, Kappa will "fix" this problem by consider the marginal distribution of the response variable. Using Kappa, the aforementioned trivial classifier will have a very small Kappa.

In plain English, it measures how much better the classier is comparing with guessing with the target distribution.

• I have a feeling the last paragraph should read "In plain English, it measures how much better the classifier is compared with guessing with the target distribution." – Silverfish Mar 20 '17 at 19:11

What value of Cohen's kappa is strong depends on several factors including for example, the number of categories or codes that are used affects kappa$^1$ and the probability that each code will be populated.

"For example, given equiprobable codes and observers who are 85% accurate:

value of kappa   number of codes
0.49             2
0.60             3
0.66             5
0.69             10"


Now, what if we do not have equiprobable codes but have different "base rates"?

For two codes the kappa plots from Bruckner et al. would look like

...Nonetheless (... continuing Wikipedia quote), magnitude guidelines have appeared in the literature. Perhaps the first was Landis and Koch, who characterized values

 <0 as indicating no agreement
0.00–0.20 as slight,
0.21–0.40 as fair,
0.41–0.60 as moderate,
0.61–0.80 as substantial, and
0.81–1 as almost perfect agreement.


This set of guidelines is however by no means universally accepted; Landis and Koch supplied no evidence to support it, basing it instead on personal opinion. It has been noted that these guidelines may be more harmful than helpful. Fleiss's equally arbitrary guidelines characterize kappas over

>0.75 as excellent,
0.40 to 0.75 as fair to good, and
<0.40 as poor."


For a (hard to find) upgrade of the FalliObs Windows program to account for the number of codes originally offered by Bakeman et al.$^1$ follow link to ComKappa3. The program description$^2$ relates that the standard error of kappa can be estimated, allowing the obtained kappa to be tested for significance against a null distribution (Bakeman & Gottman, 1997; Fleiss, Cohen, & Everitt, 1969). For further reading for other kappa measures see ANALYSIS OF BEHAVIORAL STREAMS.

Also see Using Cohen's kappa statistic for evaluating a binary classifier for a similar question.

1 Bakeman, R.; Quera, V.; McArthur, D.; Robinson, B. F. (1997). "Detecting sequential patterns and determining their reliability with fallible observers". Psychological Methods. 2: 357–370. doi:10.1037/1082-989X.2.4.357

2 Robinson BF, Bakeman R. ComKappa: A Windows’ 95 program for calculating kappa and related statistics. Behavior Research Methods. 1998;30:731-2.

How does Kappa help in evaluating the prediction performance of classifiers? What does it tell?!!

You should consider the kappa as a measure of agreement between 2 individuals such that the result can be interpreted as:

Poor agreement = 0.20 or less
Fair agreement = 0.20 to 0.40
Moderate agreement = 0.40 to 0.60
Good agreement = 0.60 to 0.80
Very good agreement = 0.80 to 1.00

• Don't apply this scale blindly, read the answer from rbx: "There is not a standardized interpretation of the kappa statistic. ...Landis and Koch considers 0-0.20 as slight, 0.21-0.40 as fair, 0.41-0.60 as moderate, 0.61-0.80 as substantial, and 0.81-1 as almost perfect. Fleiss considers kappas > 0.75 as excellent, 0.40-0.75 as fair to good, and < 0.40 as poor. It is important to note that both scales are somewhat arbitrary. At least two further considerations should be taken into account when interpreting the kappa statistic." These considerations are explained in rbx's answer – joelostblom Feb 14 '17 at 14:49

## protected by Community♦Oct 20 '16 at 8:50

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).