liveBook · Manning

Specificity

As explained in Grokking Machine Learning

A classification metric equal to the proportion of actual negative examples correctly identified, also called the true negative rate.

Specificity measures how well a classifier identifies actual negative examples. Divide the true negatives by the total actual negatives: true negatives / (true negatives + false positives). It is also called the true negative rate. Specificity is not the same as precision. section 7.3

Specificity is considered alongside sensitivity when evaluating a model with a receiver operating characteristic (ROC) curve. Raising the classification threshold increases specificity while decreasing sensitivity. section 7.3

Thresholds change the trade-off

A health test can classify people as healthy or sick, and a spam detector can classify emails as ham or spam. In a simple example with five actual negatives, correctly identifying four gives a specificity of 4/5, or 0.8. Raising the threshold can increase specificity while reducing sensitivity. section 7.3

Figure 7.3 The effects of moving the threshold on the sensitivity and the specificity. On the left, we have a model with a low threshold; in the middle, we have one with a medium threshold; and on the right, we have one with a high threshold. For each of the models, there are five positive and five negative points. Each model is represented by the vertical line. The model predicts that the points to the right of the line are positive and those to the left are negative. For each of the models, we’ve counted the number of true positives and true negatives, that is, the number of positive and negative points that have been correctly predicted. We have used those to calculate the sensitivity and the specificity. Note that as we increase the threshold (i.e., as we move the vertical line from left to right), the sensitivity goes down and the specificity goes up.

Compare low, medium, and high thresholds to see how specificity and sensitivity change. section 7.3

How Grokking Machine Learning covers it

How deep it goes
Defines the metric with a ratio and illustrates how changing the threshold affects specificity and sensitivity in ROC analysis.
Examples
Uses health-test and spam-detection examples, a five-negative threshold illustration, and an exercise calculating specificity from a medical confusion matrix.
What it assumes
Builds on understanding false positives, false negatives, and the confusion matrix before defining specificity.
What you can do after
Evaluate classification models by calculating specificity and comparing its threshold trade-off with sensitivity on an ROC curve.
How it connects
Connects specificity with sensitivity, recall, precision, classification thresholds, and the receiver operating characteristic curve.

Also explained in

Compare how 6 books explain specificity →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Machine Learning. The section links point to the parts of the book it draws on.