Skip to content

Instantly share code, notes, and snippets.

@MyRibbonApps
Last active Sep 22, 2021
Embed
What would you like to do?
cost_function
def cost_function(m, b, points):
the_total_error = 0
sum_error = 0
for i in range(len(points)):
x = points.iloc[i].weight
y = points.iloc[i].height
the_total_error += (y - (m * x + b)) ** 2
sum_error += the_total_error
print(sum_error)
return sum_error
for i in range(-2, 2):
cost_function(i, i, data)
#What we get when it prints:
#645
#324
#113
#12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment