Implementing linear regression with Python