*How to evaluate your image classification model* – Here is one of the trained model for MNIST image classification. As a response to the common criticism that machine learning models are not interpretable, Let’s have a closer look at the trained model parameters. Each line here represents one model parameter, for all the parameters connected to one output, we could transform them into a 2D image.

For example, here is a 2D image for all the model parameters connected to the first output, which represent the digit zero. Here the yellow color represents the weights have large values and the blue color represents the weights have small values. The following figures shows the weights visualization for each digit from 0-9.

It is pretty clear to see how each figure highlights or actives different parts of the images corresponding to different digit classes. Using this model, for each input image in the test dataset, we can calculate the logit score for each digit class with the linear weighted sum of the model weights W and input X. In this way we can classify the input image into one of the classes with the highest logit score.

Here, let’s also record the prediction result for each test image in a confusion matrix. For the first example, we have the input image as eight. and the prediction is 8. And for the second example, we have the input image as five, and the prediction is six. The confusion matrix is a tabular way of visualizing the performance of the image classification model. Each entry in the confusion matrix denotes the number of predictions that were made by the model where it classify the image correctly or incorrectly.

After iterating through all the test dataset, we can derive recall precision and F1 score for each class. Here I will not dive deep into how to calculate them, where the details can be found in our Confucian Matrix article. This is the code block to do the evaluation. The results looks very good for this simple classification problems with a simple softmax regression model.

It is a relatively easy task in image classification. In the future article, we will show you how to extend this model and pipeline to solve more difficult problems with more complicated models, such as convolutional neural network.

**Useful links:**

reference – *How to evaluate your image classification model*

Web enthusiast. Thinker. Evil coffeeaholic. Food specialist. Reader. Twitter fanatic. Music maven. AI and Machine Learning!