---
title: "Confusion matrix and performance measures"
subject: "Data Mining"
chapter: 3
key: "semester_7/data_mining:confusion-matrix-measures"
source: https://www.bctengineer.com/q/semester_7/data_mining/confusion-matrix-measures
site: BCT Engineering
---

# Confusion matrix and performance measures

Data Mining · Chapter 3: Classification

- Asked in: year not given
- Video: [Confusion Matrix Solved Example Accuracy Precision Recall F1 Score Prevalence by Mahesh Huddar](https://www.youtube.com/watch?v=_CGTbkHwUHQ) — Mahesh Huddar
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_7/data_mining/confusion-matrix-measures
- Whole chapter: https://www.bctengineer.com/md/semester_7/data_mining/chapter-3

## Question

Describe Confusion Matrix with example. Define Accuracy, Error rate, Sensitivity, Specificity, Precision, Recall, Positive Predictive Value and Negative Predictive Value, TPR, TNR, FPR, FNR of the classifier model.

## Short answer

A confusion matrix compares actual vs predicted classes. Measures include accuracy, sensitivity (TPR), specificity (TNR), precision, NPV, FPR, FNR, and error rate, calculated from TP, FN, FP, TN.

## Answer

A **confusion matrix** (contingency table) summarises the performance of a classifier on test data by comparing actual classes with predicted classes. For two classes (positive = class of interest):

| Actual \ Predicted | Positive | Negative |
| --- | --- | --- |
| Positive | TP | FN |
| Negative | FP | TN |

- **TP** (true positives): positives correctly predicted
- **TN** (true negatives): negatives correctly predicted
- **FP** (false positives): negatives wrongly predicted positive
- **FN** (false negatives): positives wrongly predicted negative

*Example* (cancer test, 1000 records): TP = 90, FN = 60, FP = 40, TN = 810.

#### Measures
| Measure | Formula | Example |
| --- | --- | --- |
| Accuracy | (TP + TN)/(TP + TN + FP + FN) | 900/1000 = 0.90 |
| Error rate | (FP + FN)/total = 1 − accuracy | 0.10 |
| Sensitivity = Recall = TPR | TP/(TP + FN) | 90/150 = 0.60 |
| Specificity = TNR | TN/(TN + FP) | 810/850 = 0.953 |
| Precision = PPV | TP/(TP + FP) | 90/130 = 0.692 |
| NPV | TN/(TN + FN) | 810/870 = 0.931 |
| FPR | FP/(FP + TN) = 1 − TNR | 40/850 = 0.047 |
| FNR | FN/(FN + TP) = 1 − TPR | 60/150 = 0.40 |

**Meaning**: accuracy is the overall fraction correct; sensitivity/recall is how many real positives are found; specificity is how many real negatives are found; precision (positive predictive value) is how many predicted positives are really positive; NPV is how many predicted negatives are really negative. Accuracy alone is misleading on imbalanced classes, so sensitivity, specificity and precision are also reported.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Sensitivity (recall, TPR) =
   A. TP/(TP + FN)
   B. TP/(TP + FP)
   C. TN/(TN + FP)
   D. FP/(FP + TN)
   Answer: A. It is the fraction of real positives found. (Key point: Sensitivity)

2. Precision (PPV) =
   A. TP/(TP + FN)
   B. TP/(TP + FP)
   C. TN/(TN + FN)
   D. (TP + TN)/total
   Answer: B. Of predicted positives, how many are truly positive. (Key point: Precision)

3. How is FPR related to specificity?
   A. FPR = specificity
   B. FPR = 1 - precision
   C. FPR = 1 - specificity
   D. FPR = FN/(FN + TP)
   Answer: C. FPR = FP/(FP + TN) = 1 - TNR. (Key point: Specificity vs FPR)

4. With TP=90, FN=60, FP=40, TN=810, accuracy is:
   A. 0.60
   B. 0.85
   C. 0.69
   D. 0.90
   Answer: D. (90 + 810)/1000 = 0.90. (Key point: Example accuracy)

## Close variants set in other exams

- [Measures from confusion matrix (152, 130)](https://www.bctengineer.com/question.md?key=semester_7%2Fdata_mining%3Aconfusion-matrix-152-130) — Data Mining, chapter 3
- [Measures from cancer confusion matrix](https://www.bctengineer.com/question.md?key=semester_7%2Fdata_mining%3Aconfusion-matrix-cancer) — Data Mining, chapter 3

## Related in Data Mining

- [Inverse relation of precision and recall](https://www.bctengineer.com/question.md?key=semester_7%2Fdata_mining%3Aprecision-recall-inverse) — Data Mining, chapter 3

## Related in other subjects

- [Accuracy, precision, sensitivity, resolution](https://www.bctengineer.com/question.md?key=semester_4%2Finstrumentation_and_measurement%3Aaccuracy-precision-sensitivity-resolution) — Instrumentation and Measurement, chapter 3
