Interpretation of confusion matrix

Interpretation of confusion matrix

by Kate Chirikova -
Number of replies: 0

Hi everyone! I got a question from a student asking how we should interpret confusion matrix when we have more than one predicting variable. Here's my answer below in case anyone else is having the same question. 

In short, it doesn't matter how many predictors we have in the model, confusion matrix is interpreted in the same manner. You will always get a 2x2 table if the outcome is dichotomous. The numbers in the cells will vary depending on the predictors in the model, but the layout of the matrix and its interpretation will remain the same.

For example, in the Lab 3 we tried to predict CHD using a logistic regression and including a variety of predictors. Our outcome is dichotomous -- CHD-/CHD+. So, in the confusion matrix in rows we can see the actual distribution of the outcome in our data. And in columns we can see the distribution of the outcome as predicted by our model. How do we get these numbers in columns (predicted CHD-/CHD+)? When we fit a logistic regression as a result we get a probability of CHD+ for each subject in our sample. Let's imagine someone is having a 70% chance of CHD+. By default, our model will classify this person as CHD+, because the default threshold for CHD+ is 50%. If someone is having a 30% chance of CHD+, they will be classified as CHD-. That's how these numbers in columns are derived. Depending on the predictors in the model and the threshold (50% or any other that you consider sensible) the numbers in the matrix will vary. But you will always be able to calculate sensitivity, specificity, accuracy, and AUC in the same manner.

So, you might conclude that sensitivity of your logistic regression model in predicting CHD+ is 3% based on sex, age, blood pressure, BMI, and heart rate. But sensitivity is 5% when based on all of these mentioned predictors and additionally -- education, diabetes status, smoking habits etc. Again, the numbers are different, but they are calculated from a 2x2 confusion matrix in the same manner. You can play around with changing the predictors in our model (in Select Columns widget) and analyzing the confusion matrix results.

Hope this helps!