Logistic Regression Loss Function Python