Skip to content

Instantly share code, notes, and snippets.

@perborgen
Created January 8, 2016 16:53
Show Gist options
  • Save perborgen/328415f094b0ee3d4f4b to your computer and use it in GitHub Desktop.
Save perborgen/328415f094b0ee3d4f4b to your computer and use it in GitHub Desktop.
def Cost_Function_Derivative(X,Y,theta,j,m,alpha):
sumErrors = 0
for i in xrange(m):
xi = X[i]
xij = xi[j]
hi = Hypothesis(theta,X[i])
error = (hi - Y[i])*xij
sumErrors += error
m = len(Y)
constant = float(alpha)/float(m)
J = constant * sumErrors
return J
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment