Skip to content

Specificity (True Negative Rate)

Formula

\[ \mathrm{Specificity}=\frac{TN}{TN+FP} \]

Parameters

  • \(TN\): true negatives
  • \(FP\): false positives

What it means

Specificity measures how well a classifier correctly rejects negative cases.

What it's used for

  • Medical screening and fraud detection when false positives are costly.
  • ROC analysis (specificity = 1 - FPR).

Key properties

  • Range is \([0,1]\).
  • Threshold-dependent metric.

Common gotchas

  • High specificity can come with low sensitivity if threshold is too strict.
  • Undefined if there are no actual negatives.

Example

A spam filter with low false positives has high specificity on legitimate email.

How to Compute (Pseudocode)

Input: confusion-matrix counts
Output: specificity

compute the required numerator/denominator from TP, FP, FN, TN
if denominator == 0:
  return undefined (or use a task-specific convention)
return numerator / denominator

Complexity

  • Time: \(O(1)\) once confusion-matrix counts are available
  • Space: \(O(1)\)
  • Assumptions: Binary classification formula shown; computing the confusion matrix itself is typically \(O(n)\)

See also