completed cost function for logistic regression.
completed prediction function.