First, we will evaluate the model based on the train data for loss and accuracy. We will also obtain a confusion matrix based on the train data. The same process shall be repeated with the test data.
Model evaluation and prediction
Training the data
We will use the evaluate function to obtain the loss and accuracy values, as shown in the following code:
# Loss and accuracy
model %>% evaluate(train_x, train_y)
$loss
[1] 0.4057531
$acc
[1] 0.8206
As seen from the preceding output, the loss and accuracy values based on the training data are 0.406 and 0.821, respectively.
Predictions using training data are used for developing a confusion matrix, as shown in the following code:
# Prediction and confusion matrix
pred <- model ...