Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Matplotlib for Python Developers

You're reading from   Matplotlib for Python Developers Effective techniques for data visualization with Python

Arrow left icon
Product type Paperback
Published in Apr 2018
Publisher Packt
ISBN-13 9781788625173
Length 300 pages
Edition 2nd Edition
Languages
Arrow right icon
Authors (3):
Arrow left icon
Claire Chung Claire Chung
Author Profile Icon Claire Chung
Claire Chung
Aldrin Yim Aldrin Yim
Author Profile Icon Aldrin Yim
Aldrin Yim
Allen Yu Allen Yu
Author Profile Icon Allen Yu
Allen Yu
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Introduction to Matplotlib 2. Getting Started with Matplotlib FREE CHAPTER 3. Decorating Graphs with Plot Styles and Types 4. Advanced Matplotlib 5. Embedding Matplotlib in GTK+3 6. Embedding Matplotlib in Qt 5 7. Embedding Matplotlib in wxWidgets Using wxPython 8. Integrating Matplotlib with Web Applications 9. Matplotlib in the Real World 10. Integrating Data Visualization into the Workflow

Evaluating prediction results with visualizations


We have specified the callbacks that store the loss and accuracy information for each epoch to be saved as the variable history. We can retrieve this data from the dictionary history.history. Let's check out the dictionary keys:

print(history.history.keys())

This will output dict_keys(['loss', 'acc']).

Next, we will plot out the loss function and accuracy along epochs in line graphs:

import pandas as pd
import matplotlib
matplotlib.style.use('seaborn')

# Here plots the loss function graph along Epochs
pd.DataFrame(history.history['loss']).plot()
plt.legend([])
plt.xlabel('Epoch')
plt.ylabel('Loss')
plt.title('Validation loss across 100 epochs',fontsize=20,fontweight='bold')
plt.show()

# Here plots the percentage of accuracy along Epochs
pd.DataFrame(history.history['acc']).plot()
plt.legend([])
plt.xlabel('Epoch')
plt.ylabel('Accuracy')
plt.title('Accuracy loss across 100 epochs',fontsize=20,fontweight='bold')
plt.show()

Upon training, we can...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image