calculate logistic regression cost