What is happening is that python is computing the list zip(x,y)
, then each iteration of your for loop is overwriting (x,y)
with the corresponding element of zip(x,y)
. When your for loop terminates (x,y)
contains zip(x,y)[-1]
.
Try
theta[0] = theta[0] - alpha*1/m*sum([((theta[0]+theta[1]*xi) - yi)**2 for (xi,yi) in zip(x,y)])