The difference between linear regression and logistic regression lies in what happens after the above linear function has been calculated. In linear regression, we’re done and the linear function is the output. In logistic regression, we take the result of the linear function and apply a special non-linear function called the sigmoid function to it.
\(s(z)=1÷(1+exp(−z))\)
The mathematical formula for the sigmoid function (see below) may look a bit intimidating but it serves a simple purpose: it converts any number to value between 0 and 1. For example, 0 is converted to 0.5, 10 is converted to 0.9999546, -10 to 0.0000454. This is useful to interpret an outout as a probability (remember, porbabilities are calculated values betewween 0 and 1) adn use this to predict the probability of something happening.
The sigmoid formula is tehn used get the probability of something happening or not, or a mail to be spam or not. There is a simple generalization of the sigmoid function to multiple class labels, which is called softmax.