Matplotlib is a comprehensive library for creating static, animated, and interactive visualizations in Python.
The following is an example of pyplot based on the actual and predic dataset in the NumPy post.
import matplotlib.pyplot as plt x=[1,2,3,4,5,6,7] actual=[12, 13, 14, 15, 15, 22, 27] predic=[11, 13, 14, 14, 15, 16, 18] sqrerr=[1,0,0,1,0,36,81] #calculate sum of all items in sqrerr sum_sqrerr=reduce(lambda acc,elm:acc+elm, sqrerr,0) #calculate sum_sqrerr/count-of-x mse=sum_sqrerr/len(x) print("MSE:{}".format(mse)) plt.plot(x,actual,'b--', x, predic, 'g--',x,sqrerr,'rs--') plt.show()
Read Further:
0 Comments