Evaluating the recommendation engine's accuracy
We can now calculate the accuracy rate of our deep learning model built on Keras.
Getting ready
Evaluating a Sequential
model for accuracy requires using the model.evaluate()
function within Keras.
How to do it...
We can simply calculate the accuracy score, accuracy_rate
, by executing the following script:
score = model.evaluate(xtest_array, ytest_OHE, batch_size=128) accuracy_rate = score[1]*100 print('accuracy is {}%'.format(round(accuracy_rate,2)))
How it works...
Our model performance is based on evaluating our test features, xtest_array
, with our test labels, ytest_OHE
. We can use model.evaluate()
and set the batch_size
for evaluation at 128
elements. We can see that our accuracy is around 39%, as seen in the following screenshot:
This means that we are able to determine the rating by a user between 0 and 5 and at nearly a 39% accuracy rate.
See also
To learn more about model performance with Keras metrics, visit the following website: