Created
June 24, 2020 04:00
-
-
Save Jargon4072/a7b19614c9a9f23338641d2bb3981bc3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
from numpy import * | |
# y = mx + b | |
# m is slope, b is y-intercept | |
# point is tuple of x,y value at a given step with data as points[i]= [xi, yi] | |
def compute_error_for_line_given_points(b, m, points): | |
totalError = 0 | |
for i in range(0, len(points)): | |
x = points[i, 0] | |
y = points[i, 1] | |
totalError += (y - (m * x + b)) ** 2 | |
return totalError / float(len(points)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment