machine learning ex2 in python