A confusion matrix evaluates a binary classification model by cross-classifying observed outcomes against predicted outcomes. In an NBA playoff example, it counts teams correctly and incorrectly predicted to qualify for postseason play. section 14.6.2
The four cells describe the model’s decisions:
- True positive: the model correctly predicts playoff qualification; the example contains 40. section 14.6.2
- True negative: the model correctly predicts that a team will miss the postseason; the example contains 19. section 14.6.2
- False positive: the model predicts qualification when the team does not qualify; the example contains 11. section 14.6.2
- False negative: the model predicts non-qualification when the team qualifies; the example contains 10. section 14.6.2
Building the matrix in R
Convert predicted probabilities into binary labels before comparing them with binary actual outcomes. With a 0.50 cutoff, table(actuals$actual_values, predictions$predicted_values2) returns rows and columns for 0 and 1: 19 true negatives, 11 false positives, 10 false negatives, and 40 true positives. These counts yield sensitivity of 0.80, specificity of 0.6333, misclassification error of 0.2625, and accuracy of 0.7375. section 14.6.2
confusion_matrix <- table(actuals$actual_values, predictions$predicted_values2) print(confusion_matrix) ## 0 1 ## 0 19 11 ## 1 10 40
View the executable R output showing the confusion-matrix layout and its four cell counts. section 14.6.2













