Loss, accuracy, and confusion matrices for test data

We can now obtain loss and accuracy values for the test data and then create a confusion matrix using the following code:

# Loss and accuracy
model %>% evaluate(testx, testLabels)

OUTPUT
6/6 [==============================] - 0s 194us/step
$loss
[1] 0.5517520905

$acc
[1] 0.8333333

# Confusion matrix
pred <- model %>% predict_classes(testx)
table(Predicted=pred, Actual=testy)

OUTPUT
Actual
Predicted 0 1 2
0 2 0 0
1 0 1 0
2 0 1 2

As you can see from the preceding output, the loss and accuracy values for the images in the test data are 0.552 and 0.833 respectively. These results are slightly inferior to the numbers that we saw for the training data; however, some amount of performance deterioration is expected when a model is assessed based on unseen data. The confusion matrix indicates one incorrectly classified image, where an image of a car is mistaken for an image of an airplane. Therefore, with five out of six correct classifications, the model accuracy based on the test data is 83.3%. Let's now look more deeply into the model's prediction performance by investigating the probability values based on images in 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