We will now use the test data to obtain loss and accuracy values for the model using the following code:
# Evaluatemodel %>% evaluate(test_x, test_y)$loss  0.3997277$acc  0.81992
As seen from the preceding output, for the test data, we obtain a loss value of 0.399 and an accuracy of about 0.819. These values, as expected, are slightly inferior to those obtained for the train data. However, they are close enough to results based on the train data to consider this model behavior consistent.
The code to obtain a confusion matrix using test data is as follows:
# Confusion Matrixpred1 <- model %>$ predict_classes(text_x)table(Predicted=pred1, Actual=imdb$test$y) Actual Predicted 0 1 0 9159 1161 1 3341 11339 ...