Cost function


  • Squared error function: J(a, b) = (sum of (h(xi) - yi)^2)/2m where h(x) = ax^2 + b
  • It is probably the most common used for linear regression problems because it seems to work the best in most cases.
  • We would like to find a and b so J(a, b) is minimal.
  • If we assume b=0 then we are looking at min(J(a, 0)) which is a 2D function
  • In the general case though min(J(a, b)) is a 3D function for which we need to find the minimum