Logistic Regression

Logistic regression models a binary output as a probability generated by a linear function of the inputs . Given a dataset , where and , we assume the model

where is the sigmoid (logistic) function that squashes real values into .

One way to estimate the optimal parameters is by maximizing the likelihood of the observed binary (Bernoulli) labels under this probabilistic model. For each observation, it follows that

where . We minimize the negative log-likelihood, also known as the cross-entropy loss. Note here since the points are independent, the joint likelihood is just a product of the individual probabilities:

This loss is convex, ensuring a unique global minimum. Unlike linear regression, there is no closed-form solution for logistic regression, because depends nonlinearly on .

Derivation

To reason about logistic regression, we need to think in terms of probabilities. Take in the following sentence: logistic regression models the log-odds of class versus as a linear model. Essentially, we have

which when solved yields the sigmoid function , and looks like this: