Loss, accuracy, and confusion matrix with the training data

The code for obtaining the loss, accuracy, and confusion matrix for the training data is as follows:

# Loss and accuracy
model %>% evaluate(trainx, trainy)
$loss
[1] 1.954347
$acc
[1] 0.8785

# Confusion matrix
pred <- model %>% predict_classes(trainx)
table(Predicted=pred, Actual=data$train$y[1:2000,])
Actual
Predicted 0 1 2 3 4 5 6 7 8 9
0 182 0 5 2 3 0 2 0 10 1
1 1 156 1 1 1 0 2 0 4 0
2 2 0 172 3 4 0 4 0 1 0
3 0 0 1 133 2 12 2 1 0 0
4 1 0 8 4 188 3 4 2 0 0
5 1 0 4 22 3 162 1 3 0 0
6 0 0 3 9 3 0 192 1 1 0
7 3 0 5 10 10 5 0 188 0 0
8 5 0 3 3 0 1 0 1 182 0
9 7 35 1 8 0 0 0 3 5 202

# Accuracy for each category
100*diag(tab)/colSums(tab)
0 1 2 3 4
90.09901 81.67539 84.72906 68.20513 87.85047
5 6 7 8 9
88.52459 92.75362 94.47236 89.65517 99.50739

From the preceding output, we can make the following observations:

  • The loss and accuracy based on the training data are 1.954 and 0.879, respectively.
  • Both of these numbers are an improvement over the corresponding results based on the previous model.
  • The confusion matrix shows a decent image classification performance.
  • The best image classification performance is seen for category 9 (truck), where only one image is misclassified as category-0 (airplane) and provides an accuracy of 99.5%.
  • This model is the most confused regarding category-3 (cat), which is mostly classified as category-5 (dog) or category-7 (horse) and provides an accuracy of only 68.2% for this category.
  • Among the misclassifications, the highest case (35 images) is when category-1 (automobile) is misclassified as category-9 (truck).

Next, we will assess the model's performance using the test data.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset