# Logistic Regression in less than 5 minutes using Python

Original article was published on Artificial Intelligence on Medium

Logistic regression is one of the most important Machines learning algorithms after Linear regression.

Suppose we are interested in the factors that influence whether a political candidate wins an election or not. The outcome (response) variable is binary (0/1); win or lose. The predictor variables of interest are the amount of money spent on the campaign, the amount of time spent campaigning negatively, and whether or not the candidate is an incumbent. These are the explanatory or independent variables.

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.

Logistic Regression gives the probability associated with each category or each individual outcome. The probability function is joined with the linear equation using a probability distribution. In Logistic Regression, we use binomial distribution where we work on two category problems types of logistic regression

1- Binary: The categorical response has only two 2 possible outcomes(Pass/Fail)
2- Multi: Three or more categories without ordering(Cats, Dogs, Sheep)
3- Ordinal: Three or more categories with ordering (Low, Medium, High)

Sigmoid activation
In order to map predicted values to probabilities, we use the sigmoid function. The function maps any real value into another value between 0 and 1. In machine learning, we use sigmoid to map predictions to probabilities.