Evaluate a Keras Model with Test Data

Chris Achard
InstructorChris Achard
Share this video with your friends

Social Share Links

Send Tweet
Published 6 years ago
Updated 5 years ago

Once we have a model with good training and validation accuracy, we will create some test data and evaluate the model’s accuracy on the new data set using the evaluate method on the Keras model.

Instructor: [00:01] Make another set of data called X Test and Y Test. This data will be used to test the neural network after training is fully complete. The format should match the train and validation data sets.

[00:13] In this case, there is four input numbers per line in a single output value, which is the correct answer for what we're asking the neural network to predict. For this example case, it's the mean of the four inputs.

[00:27] We can evaluate the loss of our trained network by calling the evaluate method on the model and passing in the x- and the y-values that we just created. The output will be an array of one or more numbers, which represents the metrics that we told our neural network to optimize for.

[00:43] We can print those metric names by calling them Metric Names Method on the model and then print the output to see the actual values. When we run that, we see the hundred epochs like normal with our training loss and validation loss.

[01:01] We also see a single run with the three-new test data points. Finally, we see that our metric is loss. This value represents the loss on the as yet unseen data, which is the test set that we created.

[01:17] In a well-trained and well-tuned, neural network, the training loss, validation loss, and test loss should be similar, which means there is on under or overfitting issues. Also, notice that we've only checked the test set after we fully trained the network.

[01:31] It's a best practice to reserve the test set until the very end of training and validation. Otherwise, it isn't as effective at telling you the actual performance of your network on future unseen data.

egghead
egghead
~ an hour ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today