# 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            |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://machine-learning.paperspace.com/wiki/confusion-matrix.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
