What is logistic regression?

Logistic regression is a supervised classification algorithm. It is a discriminative algorithm, meaning it tries to find boundaries between two classes. It models the probabilities of one class.

In linear regression (y=mx + c) our output(y) can be from -inf to +inf , but in logistic we want our output to be probabilities ( between 0 to 1 ).

Here comes the logistic function(sigmoid function), y = 1/(1+e^(-x))

Output of linear regression:
main-qimg-a7ee7c1907628a364d6baadd0d2c3fee

Output of logistic regression(sigmoid curve):

main-qimg-d4c4b6257629b275f4af3d504f1bb40a

The equation for simple logistic regression is:

y = e^(mx+c)/(1 + e^(mx+c))

The loss function used in logistic regression is log loss

log_loss = $\sum_{i=0}^{n} (-y_ilog(y_i’)) - (1-y_i)(log(1-y_i’)))$

here, n is the number of training instances, y is the actual value and y’ is the predicted value.