The number of positive cases correctly identified.
The number of positive cases incorrectly identified as negative.
Sensitivity Rate
0.00%
function calculateSensitivity() {
// Get input values using 'var'
var tpInput = document.getElementById("truePositives");
var fnInput = document.getElementById("falseNegatives");
var resultBox = document.getElementById("resultBox");
var sensitivityDisplay = document.getElementById("sensitivityResult");
var summaryText = document.getElementById("summaryText");
// Parse values
var tp = parseFloat(tpInput.value);
var fn = parseFloat(fnInput.value);
// Validation
if (isNaN(tp) || isNaN(fn)) {
alert("Please enter valid numbers for both fields.");
return;
}
if (tp < 0 || fn < 0) {
alert("Values cannot be negative.");
return;
}
// Calculation Logic
var totalPositives = tp + fn;
// Handle divide by zero edge case
if (totalPositives === 0) {
resultBox.style.display = "block";
sensitivityDisplay.innerHTML = "0.00%";
summaryText.innerHTML = "No positive cases recorded (TP + FN = 0). Sensitivity cannot be calculated.";
return;
}
var sensitivityRate = (tp / totalPositives);
var sensitivityPercentage = sensitivityRate * 100;
// Update UI
resultBox.style.display = "block";
sensitivityDisplay.innerHTML = sensitivityPercentage.toFixed(2) + "%";
summaryText.innerHTML =
"Out of " + totalPositives + " actual positive cases, " +
"" + tp + " were correctly identified. " +
"This means the test captures " + sensitivityPercentage.toFixed(2) + "% of all positive cases.";
}
How to Calculate Sensitivity Rate (True Positive Rate)
Sensitivity rate, often referred to simply as Sensitivity, Recall, or the True Positive Rate (TPR), is a crucial statistical measure used in various fields such as medical diagnostics, machine learning, and quality control. It measures the ability of a test or model to correctly identify positive instances.
In simple terms, sensitivity answers the question: "If a person actually has the disease, how likely is the test to detect it?" A high sensitivity rate means there are very few false negatives, making it ideal for screening processes where missing a positive case is dangerous.
The Sensitivity Formula
To calculate the sensitivity rate, you need two specific data points from your confusion matrix or test results:
True Positives (TP): The number of positive cases correctly identified as positive.
False Negatives (FN): The number of positive cases incorrectly identified as negative (missed cases).
The denominator (True Positives + False Negatives) represents the Total Actual Positives.
Step-by-Step Calculation Example
Scenario: Medical Screening
Imagine a new screening test for a specific virus is evaluated on 100 patients who are known to have the virus.
True Positives (TP): The test correctly returns a positive result for 92 patients.
False Negatives (FN): The test incorrectly returns a negative result for 8 patients.
Calculation:
Find the Total Positives: 92 (TP) + 8 (FN) = 100.
Divide TP by Total Positives: 92 / 100 = 0.92.
Convert to Percentage: 0.92 × 100 = 92%.
The sensitivity rate of this test is 92%. This means the test successfully identifies 92% of infected individuals but misses 8%.
Sensitivity vs. Specificity
While sensitivity measures the ability to identify positives, it is often paired with Specificity (True Negative Rate), which measures the ability to identify negatives.
High Sensitivity: Good for ruling out diseases. If a highly sensitive test is negative, you can be confident the patient does not have the condition (Mnemonics: SNOUT – Sensitive, Negative, Out).
High Specificity: Good for ruling in diseases. If a highly specific test is positive, you can be confident the patient actually has the condition (Mnemonics: SPIN – Specific, Positive, In).
When is Sensitivity Most Important?
Calculating the sensitivity rate is critical in scenarios where the cost of missing a positive case is very high:
Medical Diagnosis: For life-threatening but treatable conditions (e.g., cancer screening), doctors prefer high sensitivity to ensure no sick patients are sent home untreated.
Airport Security: Metal detectors are set to high sensitivity to ensure no weapons are missed, even if it causes some false alarms.
Fraud Detection: Banks often use sensitive algorithms to flag potential fraud, accepting that they might block some legitimate transactions to ensure no actual theft occurs.
Understanding the Results
Using the calculator above provides a quick percentage. Here is how to interpret the numbers:
100% Sensitivity: The test identifies every single positive case. There are zero False Negatives.
50% Sensitivity: The test is no better than a coin flip at detecting positive cases (assuming a balanced dataset).
0% Sensitivity: The test failed to identify any positive cases correctly.