For this recipe, we will implement logistic regression to predict the probability of low birth weight in our sample population.
Implementing logistic regression
Getting ready
Logistic regression is a way to turn linear regression into a binary classification. This is accomplished by transforming the linear output into a sigmoid function that scales the output between zero and one. The target is a zero or one, which indicates whether a data point is in one class or another. Since we are predicting a number between zero and one, the prediction is classified into class value 1 if the prediction is above a specified cutoff value, and class 0 otherwise. For the purpose of this example, we will specify that cutoff to be 0.5, which...