Created
August 7, 2018 14:56
-
-
Save marciok/fbbf27c8a6f7dee41d11eae8d428ea01 to your computer and use it in GitHub Desktop.
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 calculate_error(points, m, b): | |
# Error is calculated by the average distance from the points to the line | |
error = 0 | |
for i in range(0, len(points)): | |
x = points[i, 0] | |
y = points[i, 1] | |
# Moving y to the other side of the equation | |
# y = mx + b -> = mx + b - y | |
error += (y - (m*x + b))**2 | |
# Calculating average | |
return error / float(len(points)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment