Logistic Regression: Implementing regularized gradient.