Logistic regression implementation