Function to calculate error in regularized logistic regression