Linear regression compute theta
p1 = (X.dot(X.T))**-1 needs to be p1 = np.linalg.inv((X.T.dot(X))) 

X**-1 doesn't invert a matrix, this is equivalent to 1/X (elementwise) and you need to transpose the first not the second matrix.