Training a logistic regression model
Logistic regression is really close to linear regression conceptually. Once linear regression is fully understood, logistic regression is just a couple of tricks away. But unlike linear regression, logistic regression is most commonly used for classification tasks.
Let’s first explain what logistic regression is, and then train a model on the breast cancer dataset using scikit-learn.
Getting ready
Unlike linear regression, logistic regression’s output is limited to a range of 0
to 1
. The first idea is exactly the same as linear regression, having for each feature a parameter :
There is one more step to limit the range to 0
to 1
, which is to apply the logistic function to this output z. As a reminder, the logistic function (also called the sigmoid function, although it’s a more generic function) is the following:
The logistic function has an S-shape, with values...