Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jainanchit51/55cb48ade62314fbbba2de356e472d3b to your computer and use it in GitHub Desktop.
Save jainanchit51/55cb48ade62314fbbba2de356e472d3b to your computer and use it in GitHub Desktop.
def cost_calculation(self,X,y,theta):
inner = np.power(((X @ theta.T) - y), 2) # @ means matrix multiplication of arrays. If we want to use * for multiplication we will have to convert all arrays to matrices
return np.sum(inner) / (2 * len(X))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment