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