Skip to content

Instantly share code, notes, and snippets.

@ramonrosa
Last active March 11, 2020 18:16
Show Gist options
  • Save ramonrosa/a6279fe81d30a7f511cde1f468a1ddcd to your computer and use it in GitHub Desktop.
Save ramonrosa/a6279fe81d30a7f511cde1f468a1ddcd to your computer and use it in GitHub Desktop.
def funcao_custo(theta, X, y):
m = len(y)
y_pred = X.dot(theta).flatten()
J = (1/m)*np.sum((y-y_pred)**2)
gradiente = -(2/m)*((X.T).dot(y - y_pred)).flatten()
return J, gradiente
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment