Last active
September 22, 2021 12:41
-
-
Save antondevv/fef481b01868f4c0b1cee39e33b67ee6 to your computer and use it in GitHub Desktop.
cost_function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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