Cost function - Intuition using Contour plot
A contour plot is a graphical technique for representing a 3-dimensional surface by plotting constant z slices, called contours, on a 2-dimensional format. That is, given a value for z, lines are drawn for connecting the (x,y) coordinates where that z value occurs
In previous post, we simplified h(x) by setting a0 = 0. We can see that J will be a parabola.
In general, cost function J for linear regression h(x) = a0 + a1x will be in 3 dimensions which makes sense because it is a function of 2 variables a0 and a1
Contour plot for above graph of cost function J look like this:
- Contour plot: http://www.itl.nist.gov/div898/handbook/eda/section3/contour.htm
A contour plot is a graphical technique for representing a 3-dimensional surface by plotting constant z slices, called contours, on a 2-dimensional format. That is, given a value for z, lines are drawn for connecting the (x,y) coordinates where that z value occurs
In previous post, we simplified h(x) by setting a0 = 0. We can see that J will be a parabola.
In general, cost function J for linear regression h(x) = a0 + a1x will be in 3 dimensions which makes sense because it is a function of 2 variables a0 and a1
Contour plot for above graph of cost function J look like this:
Intuition:
Imagine looking at horizontal cross sections of the bowl shape. The point in red in contour plot for J corresponds to a0 = 800 and a1 = -0.15, so the hypothesis function h(x) = 800 - 0.15x. In this example, this specific values (800, -0.15) is not a good hypothesis function. The closer it is to the center of the contour plot, the better (smaller) cost function JReference:
- https://www.coursera.org/learn/machine-learning/supplement/9SEeJ/cost-function-intuition-ii- Contour plot: http://www.itl.nist.gov/div898/handbook/eda/section3/contour.htm
Comments
Post a Comment