Model evaluation with test data

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 [1] 0.3997277$acc [1] 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 ...

Get Advanced Deep Learning with R now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.