Specificity

Machine Learning
Introduced by
Historical statistical foundations
Year
20th century
Type
Evaluation metric
Family
Classification Metric

What does it do?

Specificity, also called the true negative rate, is the proportion of actual negative cases that the classifier correctly labels as negative.

It answers the question: 'Of all the cases that were truly negative, how many did we correctly reject?' It is the counterpart of recall for the negative class, and it matters most when false positives are costly.

The intuition behind the method

Specificity measures how reliably a classifier identifies negative cases. A high-specificity classifier produces few false positives, and its complement (1 minus specificity) is the false positive rate. Read alongside recall, which measures how well positive cases are found, specificity shows how the classifier performs on each class. In medical testing, it answers: 'If someone is healthy, will the test correctly say they are healthy?'

History

Specificity is used in medical diagnostic testing as the true negative rate, and it is also a standard term in statistics and binary classification. Its use in machine learning evaluation follows from the same two-class framework that defines recall.

When to use it

Choose specificity when false positives are costly, for example when a positive prediction triggers an unnecessary treatment, investigation or block. In medical screening, high specificity reduces the chance that healthy people are labelled as sick. In spam filtering, it reduces the chance that legitimate mail is discarded. Do not rely on specificity alone when missing positive cases is the main concern; in that situation, recall should be the primary metric and specificity a secondary check. When reporting results, give specificity together with recall and the number of actual negative cases, because specificity alone does not show how the positive class is handled. 1 - specificity is the false positive rate and can be reported under that name.

Limitations and considerations

  • Ignores false negatives: a model can have high specificity while missing many positive cases.
  • Can look high when the model is very conservative and rarely predicts the positive class.
  • Does not reflect class prevalence or the relative costs of different error types; it is computed only within the actual negatives.
  • On its own it gives an incomplete picture of classifier performance and should be reported with recall.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Directly measures how well the classifier identifies negative cases, so a high value means few false positives.
  • Easy to interpret: a value of 1.0 means that no actual negative case was flagged as positive.
  • Useful in applications where false positives lead to costly downstream decisions.
  • Complements recall, which covers the positive class, so that the two together describe both classes.

Applications

  • Medical screening tests, where high specificity reduces the number of healthy individuals who are wrongly diagnosed and treated.
  • Spam detection, where high specificity reduces the chance that legitimate emails are wrongly flagged.

How it works

How it works

1

Count the true negatives (actual negative cases correctly predicted as negative) and the false positives (actual negative cases incorrectly predicted as positive).

2

Divide the number of true negatives by the sum of true negatives and false positives: specificity = TN / (TN + FP). The denominator is the total number of actual negative cases.

3

Specificity lies between 0 and 1. A value of 1.0 means every actual negative case was labelled negative, and a value of 0 means every actual negative case was labelled positive. Because the false positive rate equals 1 minus specificity, higher specificity means a lower false positive rate. There is no universal cut-off for an acceptable value. The required level depends on the application and on how costly false positives are relative to missed positive cases, so it should be set from that comparison rather than from a fixed threshold.

Formula
\text{FPR} = 1 - \text{Specificity}

Common pitfalls

  • Reporting specificity without recall can hide a model that rarely predicts positive and therefore appears accurate for the negative class.
  • Confusing specificity with precision: specificity is computed over actual negatives, whereas precision is computed over predicted positives.
  • Interpreting specificity on heavily imbalanced data without checking the number of negative cases, since a high value may say little about how the rare positive class is handled.
  • Assuming that high specificity guarantees useful positive predictions when positives are rare. With sensitivity and specificity held fixed, positive predictive value (precision) falls as prevalence falls, so a highly specific classifier can still produce many false alarms on rare-positive data.

Frequently asked questions

What is the relationship between specificity and precision?

They answer different questions. Specificity is computed over actual negative cases and asks how many of them were correctly rejected. Precision is computed over positive predictions and asks how many of those predictions are correct. The negative-side analogue of precision is negative predictive value, which is computed over negative predictions.

How does specificity relate to recall and balanced accuracy?

Recall is the true positive rate and specificity is the true negative rate, so they are counterparts that measure each class. In binary classification, balanced accuracy is the average of recall and specificity: (recall + specificity) / 2. This gives equal weight to correct predictions for both classes, whatever the class sizes.

Why might a model have high specificity but low recall?

Such a model correctly rejects most actual negative cases, so it has few false positives, but it misses many positive cases, so it has many false negatives. This typically happens when the model predicts positive only when it is very confident. The trade-off is acceptable only when false positives are much more costly than missed positive cases.

Related methods

Sources

  1. Fawcett, T. (2006). An introduction to ROC analysis. Pattern Recognition Letters, 27(8), 861-874.

    Open DOI reference
  2. Powers, D. M. (2011). Evaluation: From Precision, Recall and F-Measure to ROC, Informedness, Markedness and Correlation. Journal of Machine Learning Technologies, 2(1), 37-63.

    Open publication reference
  3. 2013_Book_AppliedPredictiveModeling, Section 11.2 'Evaluating Predicted Classes', p. 265 (library page field is '?'; page taken from the library page marker s.265)