Model evaluation with train data

We will first evaluate the model performance with train data using the following code:

# Evaluate
model %>% evaluate(train_x, train_y)
$loss
[1] 0.3749587
$acc
[1] 0.82752

As seen from the preceding output, for the training data, we obtain a loss value of 0.375 and an accuracy of about 0.828. This is a decent performance considering a relatively simple LSTM architecture. We next use this model to make predictions for the movie review sentiment and summarize the results by developing a confusion matrix using the following code:

# Confusion Matrix
pred <- model %>% predict_classes(train_x)
table(Predicted=pred, Actual=imdb$train$y)
Actual
Predicted 0 1
0 9258 1070
1 3242 11430

We can make the following observations from the confusion matrix:

  • It is observed that this model seems to be more accurate in predicting positive movie reviews (11,430 correct predictions) compared to negative movie reviews (9,258 correct predictions). In other words, this model correctly classifies positive reviews at the rate of about 91.4% (also called the sensitivity of the model) for the training data.
  • Similarly, this model correctly classifies negative reviews at the rate of about 74.1% (also called specificity of the model) for the training data.
  • It is also observed that the negative movie reviews are being misclassified as a positive review at the rate of about three times (3,242 reviews) more compared to a positive review being misclassified as negative (1,070 reviews).
  • Hence, although overall, this model seems to perform well for the training data, looking deeper, we observe some bias toward correctly classifying positive movie reviews at the cost of lower accuracy in correctly classifying negative reviews.

It will be interesting to see whether the model performance observed, based on training data, results in similar behavior for the test data or not.

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

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