least squares from scratch python