Sensitivity Calculator

Sensitivity Calculator

A medical test, a spam filter, and a machine learning classifier all face the same question: how good are its yes-or-no decisions? The answer is never a single number. A test can be excellent at catching real cases yet terrible at avoiding false alarms, or vice versa. The confusion matrix, a simple two-by-two table of correct and incorrect predictions, captures the full picture, and sensitivity is one of the key metrics derived from it.

Sensitivity answers a specific question: of all the truly positive cases, what fraction did the test correctly identify? But it is only one of six standard metrics. Specificity measures the equivalent for negative cases, predictive values tell you how much to trust a positive or negative result, accuracy gives the overall hit rate, and the F1 score balances precision against recall. This calculator computes all six from your four confusion-matrix counts.

This article explains what sensitivity is and how the confusion matrix works, why these metrics matter, how to use the calculator step by step, two fully worked examples, a deeper look at the formulas and the tradeoffs between metrics, guidance on choosing the right metric for your situation, practical tips, and answers to fifteen frequently asked questions.

What Is Sensitivity?

Sensitivity, also called recall or the true positive rate, is the proportion of actual positive cases that a test correctly identifies. Its formula is Sensitivity = TP / (TP + FN), where TP (true positives) are positive cases the test caught and FN (false negatives) are positive cases the test missed. A sensitivity of 90 percent means the test finds 9 out of every 10 real cases and misses 1.

The four counts come from the confusion matrix. Rows represent reality (actually positive or actually negative); columns represent the test’s verdict (predicted positive or predicted negative). The four cells are: true positives (right alarms), false negatives (missed cases), true negatives (correct rejections), and false positives (false alarms). Every classification metric is some ratio of these four numbers.

A concrete illustration makes the matrix tangible. Suppose 200 patients are tested for a condition: 100 truly have it and 100 do not. The test correctly identifies 90 of the sick patients (TP = 90) but misses 10 (FN = 10); it correctly clears 85 of the healthy patients (TN = 85) but falsely flags 15 (FP = 15). Sensitivity is 90 / 100 = 90 percent. Specificity is 85 / 100 = 85 percent. Accuracy is (90 + 85) / 200 = 87.5 percent. Each metric spotlights a different corner of the same table.

Why Sensitivity and Related Metrics Matter

They matter first in medicine, where the costs of errors are asymmetric. A false negative on a serious disease test means a sick patient goes untreated, so screening tests prioritize high sensitivity even at the cost of false positives. A false positive on the same test means a healthy patient faces anxiety and follow-up testing, which is why confirmatory tests prioritize high specificity. No single threshold serves both goals, so both metrics must be reported.

They matter second in machine learning and engineering, where classifiers are tuned and compared using these exact numbers. A fraud detection model with 99 percent accuracy can still be useless if fraud is rare: predicting “not fraud” every time achieves 99 percent accuracy while catching zero fraudsters. Sensitivity (recall), precision, and the F1 score expose this failure, which is why they dominate model evaluation for imbalanced problems.

Third, they matter for decision-making under uncertainty. Predictive values translate test characteristics into personal risk: given your positive result, what is the probability you actually have the condition? That probability depends not only on the test but on how common the condition is, a relationship governed by Bayes’ theorem. Understanding the full metric panel prevents the common error of treating a positive result as a diagnosis.

How to Use the Sensitivity Calculator

Follow these steps to evaluate a test or classifier.

Step 1: Count your true positives (TP). Enter the number of positive cases the test correctly identified, for example 90.

Step 2: Count your false negatives (FN). Enter the number of positive cases the test missed, for example 10.

Step 3: Count your true negatives (TN). Enter the number of negative cases the test correctly cleared, for example 85.

Step 4: Count your false positives (FP). Enter the number of negative cases the test wrongly flagged, for example 15.

Step 5: Click Calculate. The results show sensitivity, specificity, positive and negative predictive values, accuracy, and the F1 score, all as percentages.

Step 6: Interpret the panel. Compare sensitivity against specificity to see the test’s bias, and check predictive values to understand what results mean for individuals.

Step 7: Click Reset to evaluate another test. The Reset button reloads the page for fresh counts.

Worked Example 1: Disease Screening Test

A clinic evaluates a rapid screening test on 200 patients: 100 have the disease and 100 do not. The test catches 90 cases (TP = 90), misses 10 (FN = 10), clears 85 healthy patients (TN = 85), and falsely flags 15 (FP = 15). The inputs are 90, 10, 85, and 15.

Sensitivity is 90 / (90 + 10) = 90.00 percent. Specificity is 85 / (85 + 15) = 85.00 percent. Positive predictive value is 90 / (90 + 15) = 85.71 percent: a positive result means an 85.7 percent chance of actually having the disease in this population. Negative predictive value is 85 / (85 + 10) = 89.47 percent. Accuracy is (90 + 85) / 200 = 87.50 percent. The F1 score is 2×90 / (2×90 + 15 + 10) = 180 / 205 ≈ 87.80 percent.

The final result: a well-balanced screening test with 90 percent sensitivity and 85 percent specificity. The 10 missed cases are the concern for a screening role, suggesting a lower threshold or a confirmatory follow-up test for negatives in high-risk patients.

Worked Example 2: Spam Filter Evaluation

An email provider tests a spam filter on 1,000 messages: 100 are spam and 900 are legitimate. The filter catches 95 spam messages (TP = 95), misses 5 (FN = 5), correctly passes 891 legitimate emails (TN = 891), and wrongly flags 9 (FP = 9). Inputs: 95, 5, 891, 9.

Sensitivity is 95 / 100 = 95.00 percent. Specificity is 891 / 900 = 99.00 percent. PPV is 95 / (95 + 9) = 91.35 percent. NPV is 891 / (891 + 5) = 99.44 percent. Accuracy is (95 + 891) / 1000 = 98.60 percent. F1 is 2×95 / (190 + 9 + 5) = 190 / 204 ≈ 93.14 percent.

The final result: the filter looks stellar at 98.6 percent accuracy, but the metric panel tells a richer story. The 9 false positives, legitimate emails sent to spam, are the real cost, since missed spam is merely annoying while blocked real mail can be critical. This is why spam filters are tuned for extreme specificity even at some cost to sensitivity.

Understanding the Formulas and Tradeoffs

The six metrics form two natural pairs plus two summaries. Sensitivity = TP/(TP+FN) and specificity = TN/(TN+FP) describe the test’s intrinsic behavior on each class, independent of how common the classes are. PPV = TP/(TP+FP) and NPV = TN/(TN+FN) describe what results mean, and these depend heavily on prevalence: the same test has a much lower PPV in a rare-disease population because most positives are false alarms, a direct consequence of Bayes’ theorem.

Accuracy = (TP+TN)/total is the overall fraction correct, intuitive but dangerous with imbalanced classes, as the spam example showed. The F1 score = 2TP/(2TP+FP+FN) is the harmonic mean of precision (PPV) and recall (sensitivity); it punishes extreme imbalance between the two, making it the preferred single number for imbalanced classification tasks. The harmonic mean is used instead of the arithmetic mean precisely because it drops sharply when either component is poor.

The fundamental tradeoff is controlled by the decision threshold. Lowering the threshold for calling a result positive catches more real cases (higher sensitivity) but also flags more healthy cases (lower specificity). Plotting sensitivity against false positive rate across all thresholds produces the ROC curve, and its area (AUC) summarizes the test’s discriminative power in one number. Every real deployment is a choice of operating point on this curve, balancing the costs of the two error types.

Choosing the Right Metric

The right metric follows from the cost of each error type. For screening (disease tests, security screening, fraud alerts), false negatives are expensive, so maximize sensitivity and accept false positives that follow-up testing will resolve. For confirmation (a second-stage diagnostic, a final hiring decision), false positives are expensive, so maximize specificity and PPV.

For imbalanced machine learning problems like fraud or rare-disease detection, lead with precision, recall, and F1 rather than accuracy, which the majority class dominates. For balanced problems with symmetric error costs, accuracy is a fine summary. When communicating with non-experts, predictive values are the most meaningful: “a positive result means an 86 percent chance” is understood instantly, while “sensitivity is 90 percent” is routinely misinterpreted.

Always report metrics with their context: the population prevalence, the decision threshold, and the sample size. A sensitivity of 95 percent measured on 20 positive cases has a wide confidence interval and deserves less trust than the same figure from 2,000 cases. Numbers without context invite overconfidence; numbers with context enable decisions.

Tips for Evaluating Tests and Classifiers

  1. Always start from the four confusion-matrix counts; every metric is derived from them.
  2. Never judge an imbalanced problem by accuracy alone; check sensitivity, precision, and F1.
  3. Remember that predictive values depend on prevalence, so a test’s PPV changes between populations.
  4. Choose your decision threshold by weighing the real costs of false positives against false negatives.
  5. Report sensitivity and specificity together; either one alone tells half the story.
  6. Use the F1 score when you need one number that balances catching cases against false alarms.
  7. Validate metrics on fresh data, not the data used to build or tune the classifier.
  8. Consider confidence intervals when sample sizes are small; percentages from tiny counts are noisy.
  9. For medical tests, distinguish screening (favor sensitivity) from confirmation (favor specificity).
  10. Document the threshold and population with every metric so others can interpret and reproduce your results.

Frequently Asked Questions

1. What is sensitivity in simple terms?
It is the percentage of real positive cases that a test correctly catches. A 90 percent sensitive test finds 9 out of 10 true cases and misses 1.

2. What is the difference between sensitivity and specificity?
Sensitivity measures correct detection of positive cases (TP/(TP+FN)), while specificity measures correct detection of negative cases (TN/(TN+FP)). Good tests need both.

3. What is a false positive versus a false negative?
A false positive is a negative case wrongly flagged as positive; a false negative is a positive case wrongly missed. Their costs differ by application.

4. What is positive predictive value?
PPV is the probability that a positive test result is truly positive: TP/(TP+FP). It answers “my test is positive, so how likely am I actually positive?”

5. Why does prevalence affect predictive values?
Because when a condition is rare, most positive results come from the large healthy group as false alarms. Bayes’ theorem shows PPV falling as prevalence falls, even with an excellent test.

6. What is the F1 score?
The harmonic mean of precision and recall: 2TP/(2TP+FP+FN). It balances catching positive cases against avoiding false alarms in a single number.

7. When is accuracy misleading?
When classes are imbalanced. A test that always predicts the majority class can show high accuracy while being completely useless for the rare class of interest.

8. What is the confusion matrix?
A two-by-two table crossing actual status (positive/negative) with predicted status (positive/negative), producing the TP, FN, TN, and FP counts all metrics derive from.

9. What is recall in machine learning?
Recall is the machine learning term for sensitivity: the fraction of actual positives the model retrieves. Precision is the ML term for positive predictive value.

10. How do I choose a decision threshold?
Weigh the costs: lower thresholds raise sensitivity but lower specificity. Plot the ROC curve and pick the operating point where the tradeoff matches your error costs.

11. What is a good sensitivity value?
It depends on the stakes. Screening tests often target 95 percent or higher because missing cases is dangerous; in low-stakes applications, lower values are acceptable.

12. Can sensitivity and specificity both be 100 percent?
Only for a perfect test with zero errors of either type. Real tests always trade one against the other via their threshold.

13. What sample size do I need?
Enough positive and negative cases to estimate each metric precisely. Dozens per class is a minimum; hundreds per class give trustworthy percentages.

14. What is the ROC curve?
A plot of sensitivity versus false positive rate across all possible thresholds. Its area (AUC) summarizes overall discriminative ability from 0.5 (useless) to 1.0 (perfect).

15. Should I report one metric or several?
Several. No single metric captures a test’s behavior; report at least sensitivity, specificity, and predictive values, with the population and threshold documented.

CONCLUSION

Sensitivity tells you what fraction of real cases a test catches, but the full story needs its companions: specificity for the negative cases, predictive values for what results mean, accuracy for the overall hit rate, and the F1 score for the balanced summary. The calculator above derives all six from four simple counts in the confusion matrix.

The single most important takeaway is to match the metric to the mistake you fear most. Screening demands sensitivity, confirmation demands specificity, and imbalanced problems demand precision, recall, and F1 instead of accuracy. Enter your TP, FN, TN, and FP counts, read the whole panel rather than one number, and let the complete picture guide your threshold, your trust, and your decisions.