A confusion matrix is a performance measurement for machine learning classification models. It is a table that visually describes the performance of an algorithm. Each row of the matrix represents the instances in an actual class while each column represents the instances in a predicted class.
Key Components of a Confusion Matrix
- True Positives (TP): The number of correct positive predictions.
- True Negatives (TN): The number of correct negative predictions.
- False Positives (FP): The number of incorrect positive predictions.
- False Negatives (FN): The number of incorrect negative predictions.
Example
Here's a simple confusion matrix example:
Predicted Positive | Predicted Negative | |
---|---|---|
Actual Positive | 80 (TP) | 20 (FN) |
Actual Negative | 10 (FP) | 90 (TN) |
How to Use a Confusion Matrix
A confusion matrix can be used to calculate several performance metrics, such as accuracy, precision, recall, and F1 score.
- Accuracy: The ratio of correctly predicted observations to the total observations.
- Precision: The ratio of correctly predicted positive observations to the total predicted positive observations.
- Recall: The ratio of correctly predicted positive observations to the all observations in actual class.
- F1 Score: The weighted average of Precision and Recall.
For more information on these metrics, you can visit our Machine Learning Metrics page.
Conclusion
The confusion matrix is a powerful tool for evaluating the performance of machine learning models. By understanding the different components and how to interpret the matrix, you can gain valuable insights into the effectiveness of your model.