Least Squares Method Python