Calculate True Negative From Confusion Matrix
A true negative (TN) in a confusion matrix represents the number of negative cases that were correctly identified by a classification model. This metric is crucial for evaluating the performance of binary classification models, particularly in medical testing, spam detection, and other binary outcome scenarios.
What is a True Negative?
A true negative occurs when a classification model correctly predicts the negative class. For example, in a medical test:
- True Negative: A healthy person is correctly identified as not having the disease.
- False Positive: A healthy person is incorrectly identified as having the disease.
- False Negative: A sick person is incorrectly identified as not having the disease.
- True Positive: A sick person is correctly identified as having the disease.
True negatives are particularly important in scenarios where false positives could lead to unnecessary treatments or actions. A high number of true negatives indicates that the model is good at correctly identifying negative cases.
Understanding the Confusion Matrix
A confusion matrix is a table that describes the performance of a classification model. It shows the counts of:
| Predicted Positive | Predicted Negative | |
|---|---|---|
| Actual Positive | True Positive (TP) | False Negative (FN) |
| Actual Negative | False Positive (FP) | True Negative (TN) |
The true negative value is found in the bottom-right cell of the matrix. This value represents the number of negative cases that were correctly identified by the model.
How to Calculate True Negative
To calculate the true negative from a confusion matrix, follow these steps:
- Identify the actual negative cases in your dataset.
- Count how many of these actual negative cases were correctly predicted as negative by your model.
- This count is your true negative value.
Formula: True Negative (TN) = Number of correctly predicted negative cases
In practical terms, this means looking at the bottom-right cell of your confusion matrix and noting the value there.
Worked Example
Consider a spam detection model with the following confusion matrix:
| Predicted Spam | Predicted Not Spam | |
|---|---|---|
| Actual Spam | 45 | 5 |
| Actual Not Spam | 10 | 90 |
To find the true negative:
- Identify the actual not spam cases (90 + 10 = 100).
- Count the correctly predicted not spam cases (90).
- Therefore, the true negative is 90.
This means the model correctly identified 90 non-spam emails out of 100.