Now, we will evaluate the model using training and test data to obtain the loss, accuracy, and confusion matrices. Our objective is to obtain a model that can classify sentiment contained in movie reviews as either positive or negative.
Model evaluation and prediction
Evaluation using training data
The code to obtain the loss and accuracy values from the training data is as follows:
model %>% evaluate(train_x, train_y)
$loss
[1] 0.3745659
$acc
[1] 0.83428
As we can see, for training data, the loss and accuracy are 0.375 and 0.834, respectively. To look deeper into the model's sentiment classification performance, we need to develop a confusion matrix. To do so, use the following code:
pred <- model %>% predict_classes...