Heatmap for Confusion Matrix in Python | by Michał Marcińczuk, Ph.D. | Sep, 2024


One image can be worth thousands of words.

Towards Data Science
Image by author

A confusion matrix is a convenient way to present the types of mistakes a machine learning mode makes. It is an N by N grid with numbers, where the value in the [n, m] cell represents the number of examples annotated with the n-th class recognized as the m-th class. In this tutorial, I will focus on creating a confusion matrix and a heatmap. The color palette will be used to display the sizes of different groups, making it easy to notice similarities or significant differences in group sizes. This kind of visualization is handy when you deal with numerous categories.

Here is a visual explanation of the elements of the confusion matrix.

Recent Articles

Related Stories

Leave A Reply

Please enter your comment!
Please enter your name here