Testing the data

The code to obtain the loss and accuracy values is as follows:

# Loss and accuracy
model %>% evaluate(test_x, test_y)
$loss
[1] 0.4669374

$acc
[1] 0.77852

Here, we can see that the loss and accuracy based on the test data are 0.467 and 0.778, respectively. These results are slightly inferior to what we observed for the train data.

Next, we'll predict the classes for the test data and use the results to obtain a confusion matrix, as shown in the following code:

# Prediction and confusion matrix
pred1 <- model %>% predict_classes(test_x)
table(Predicted=pred1, Actual=imdb$test$y)
Actual
Predicted 0 1
0 9134 2171
1 3366 10329

Apart from the overall results being slightly inferior to the ones that we obtained from the train data, we can't see any major differences between the train and test data.

In the next section, we will explore a few strategies to improve model performance.

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

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