In this function, we want to go through all of the
x values and all of the
y values and compute
x*(y - (m*x+b)) for each of them.
Create a variable called
diff that has the sum of all of these values, and return it from the function.
#This is the code I wrote. Can someone explain why it is not correct?
def get_gradient_at_m(x, y, m, b):
diff = 0
N = len(x)
for i in range(N):
y_val = y[i]
x_val = x[i]
diff += (y_val - ((m * x_val) + b))
m_gradient = -2/N * diff