> For the complete documentation index, see [llms.txt](https://machine-learning.paperspace.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://machine-learning.paperspace.com/wiki/confusion-matrix.md).

# Confusion Matrix

![](/files/-LvHIIphhNcOOkLBgk9j)

A confusion matrix, typically represented as a table, is a popular [evaluation metric](/wiki/metrics-in-machine-learning.md) used to **describe the performance of a classification model** (or "classifier").  The table compares predicted and actual values.  The basic components of the table are as follows:

* **True positives (TP):** The prediction was yes, and the true value is yes
* **True negatives (TN):** The prediction was no, and the true value is no
* **False positives (FP):** The prediction was yes, but the true value was no
* **False negatives (FN):** The prediction was no, but the the true value is yes

### Related Metrics

The confusion matrix is closely related to other metrics like Precision, Recall/Sensitivity, Specificity, and F1 Score. Those definitions are as follows:

| **Metric**         | **Formula**           | **Definition**                                        |
| ------------------ | --------------------- | ----------------------------------------------------- |
| Accuracy           | (TP+TN)/(TP+TN+FP+FN) | Percentage of total items classified correctly        |
| Precision          | TP/(TP+FP)            | How accurate the positive predictions are             |
| Recall/Sensitivity | TP/(TP+FN)            | True positive rate (eg to asses false positive rate)  |
| Specificity        | TN/(TN+FP)            | True negative rate (eg to assess false negative rate) |
| F1 score           | 2TP/(2TP+FP+FN)       | A weighted average of precision and recall            |
