# What is a confusion matrix? Explain in detail with the help of an example.

What is a confusion matrix? Explain in detail with the help of an example.

Select the correct answer from above options

by (1.8m points)

Confusion Matrix: A Confusion Matrix is a table that is often used to describe the performance of a classification model (or "classifier") on a set of test data for which the true values are known.

(or)

A 2x2 matrix denoting the right and wrong predictions might help us analyse the rate of success. This matrix is termed the Confusion Matrix.

Evaluation of the performance of a classification model is based on the counts of test records correctly and incorrectly predicted by the model.

Therefore, Confusion Matrix provides a more insightful picture which is not only the performance of a predictive model, but also which classes are being predicted correctly and incorrectly, and what type of errors are being made.

The confusion matrix is useful for measuring Recall (also known as Sensitivity), Precision, Accuracy and F1 Score.

The following confusion matrix table illustrates how the 4-classification metrics are calculated (TP, FP, FN, TN), and how our predicted value compared to the actual value in a confusion matrix.

Let’s decipher the matrix:

The target variable has two values: Positive or Negative

The columns represent the actual values of the target variable

The rows represent the predicted values of the target variable

True Positive, True Negative, False Positive and False Negative in a Confusion Matrix.

True Positive (TP)

The predicted value matches the actual value

The actual value was positive and the model predicted a positive value

True Negative (TN)

The predicted value matches the actual value

The actual value was negative and the model predicted a negative value

False Positive (FP) – Type 1 error

The predicted value was falsely predicted

The actual value was negative but the model predicted a positive value Also known as the Type 1 error

False Negative (FN) – Type 2 error

The predicted value was falsely predicted

The actual value was positive but the model predicted a negative value also known as the Type 2 error

Example:

Case: Loan (Good loan & Bad loan)

The result of TP will be that bad loans are correctly predicted as bad loans.

The result of TN will be that good loans are correctly predicted as good loans.

The result of FP will be that (actual) good loans are incorrectly predicted as bad loans.

The result of FN will be that (actual) bad loans are incorrectly predicted as good loans. The banks would lose a bunch of money if the actual bad loans are predicted as good loans due to loans not being repaid. On the other hand, banks won't be able to make more revenue if the actual good loans are predicted as bad loans. Therefore, the cost of False Negatives is much higher than the cost of False Positives.