Classification with logistic regression
In the previous chapter, we saw how linear regression produces a predicted value, ŷ, from an input vector x and a vector of coefficients β:
Here, Å· can be any real number. Logistic regression proceeds in a very similar way, but adjusts the prediction to guarantee an answer only between zero and one:
Zero and one represent two different classes. The change is a simple one; we simply wrap the prediction in a function g that constrains the output between zero and one:
Where g is called the sigmoid function. This seemingly minor change is enough to transform linear regression into logistic regression and turn real-valued predictions into classes.
The sigmoid function
The sigmoid function is also referred to as the logistic function and is shown next:
For positive inputs, the logistic function rises quickly to one while, for negative inputs, it falls quickly to zero. These outputs correspond to the predicted classes. For values close to zero, the logistic function...