Data visualization and interpretation are very important to understand the data and its property. Making decisions from raw data is really difficult especially in machine learning, deep learning, accuracy comparison, etc.

Using python it is very easy to plot a graph, and using a library is easier. we will use the matplotlib library which is widely used and easier to learn and implement.

I hope you have already installed matplotlib library in your system. First, we need to import the library-

import matplotlib.pyplot as plt

Now we need some data to visualize. It might be huge data, but for sake of simplicity, we are considering a very small data point.

batch_size=[16,32,64,128,512,1024]
accuracy=[96.12,97.38,97.41,95.02,96.22,97.01]

Here, batch_size and accuracy are a set of data point that would be plotted in x- and y-axis, respectively.

plt.plot(batch_size,accuracy,'b-o',label='Accuracy over batch size for 1000 iterations');

This is the main code block for plotting the data. The plot function required some arguments. The first parameter (batch size) and the second parameter (accuracy) will be plotted on the x and y-axis, respectively. ‘b-o’ is the formatting option. Here ‘b’ is the color blue and ‘o’ is the type of datapoint. It could be cross, star or something else you like.

plt.xlabel('Batch Size')
plt.ylabel('Accuracy')

This is the label, the parameter is a string.

plt.legend()
plt.show()

Finally, plt.show() display the graph. The graph is –