Wrong iterating variable in the nested for loop. y is used as an iterator as well as an iterated sequence. So after this loop, y is just a scalar(the last element of the initial array y) and not a vector. After that, SSE is computed by subtracting a scalar from a vector:
np.sum((pred_happiness-y)**2. After changing the iterating variable name SSE is computed correctly, so the original y vector is subtracted from the pred_happiness vector.
Oh yeah, great catch! And thanks for letting me know. It doesn't change the pattern or the conclusion, although it does mean the SSE's were wrong. Code is now fixed.
Wrong iterating variable in the nested for loop.
y
is used as an iterator as well as an iterated sequence. So after this loop, y is just a scalar(the last element of the initial array y) and not a vector. After that, SSE is computed by subtracting a scalar from a vector:np.sum((pred_happiness-y)**2
. After changing the iterating variable name SSE is computed correctly, so the originaly
vector is subtracted from thepred_happiness
vector.