A table that summarizes the performance of a classification model.
The Confusion Matrix is a powerful tool for evaluating the performance of a classification model. It provides a more detailed breakdown of a model's successes and failures than a single metric like accuracy. It is a square matrix where the rows represent the actual classes and the columns represent the predicted classes. For a binary classification problem (with classes Positive and Negative), the matrix has four cells: True Positives (TP): The number of positive instances that were correctly classified as positive. True Negatives (TN): The number of negative instances that were correctly classified as negative. False Positives (FP): The number of negative instances that were incorrectly classified as positive (also known as a 'Type I error'). False Negatives (FN): The number of positive instances that were incorrectly classified as negative (also known as a 'Type II error'). From these four values, you can calculate all the other classification metrics. For example, Accuracy is (TP + TN) / Total. Precision is TP / (TP + FP). Recall is TP / (TP + FN). Visualizing the confusion matrix helps you quickly see where your model is getting confused. For example, a high number of false negatives might be critical in a medical diagnosis context (failing to detect a disease), while a high number of false positives might be more of an issue in a spam filter (classifying legitimate emails as spam).