logistic regression loss function python