Logistic Regression: Implementing regularized cost function J(θ) and gradient.