Is there a reason you take the transpose of X in line 18 first. instead of directly going to the next line? Is it due to how python compute its matrix multiplication? Or?
Great question! It's due to the way we generated the X matrix using numpy (we could also have reshaped the X matrix on generation). If we don't transpose the X matrix it won't be the correct shape to compute the intercept and slope coefficient!