Here is the explanation of the preceding code:
- The first two steps are self-explanatory.
- X, Y = np.meshgrid(theta0_vals, theta1_vals) creates x and y coordinates for the theta0 and theta1 variables. Please refer to Chapter 2, Getting Started with Basic Plots, for a detailed explanation of meshgrid.
- cset = ax.contour(X, Y, Loss, np.logspace(-2,3,100), cmap=cm.coolwarm) plots the contour graph. It plots the contour of the Loss variable for various values of X and Y. Each contour has a fixed value of Loss (z axis), so that contours are placed vertically along the z axis, and the lowest-valued contour is at the bottom:
- np.logspace(-2,3,100) specifies the range of loss values for which contours are to be plotted. They range in ...