Matplotlib 3.0 Cookbook
上QQ阅读APP看书,第一时间看更新

There's more...

The previous screenshot only represents various contours of the Loss function for a given set of theta0 and theta1. We can also plot the optimal values of theta0 and theta1 on the same plot to represent minimum loss:

# Plot the minimum point(Theta at Minimum cost)
plt.plot(theta[0], theta[1], 'rx', markersize=15, linewidth=2)
plt.show()

Here is how the plot looks. The red cross position depicts the optimal theta that gives lowest error for this regression problem: