Machine learning course, homework 2, Logistic Regression (from Andrew Ng's Coursera course)