**Logistic Regression**

- A popular Binary Classification algorithm based on Supervised Learning.
- Based on a given set of independent variable(s), the algorithm is used to predict the probability of a categorical (binary) dependent variable. The dependent variable holds values (0, failure) or (1, success)
- The logistic regression model predicts P(Y=1) as a function of X. The probability of outcome Y being a success or failure is the result.
- Instead of fitting a best line through the data (like linear regression), we fit an “S” shaped logistic function through the data. The curve tells you the likelihood of the outcome.
- Logistic regression works better on large sample sizes.
- Can also used for solving the multi-classification problems.
- Trains a data model on known input and output data so that it can predict future outputs.

**Logistic Regression Equation**

**log — odds**or

**odds ratio**or

**logit**function and is the link function for Logistic Regression.

**Interpreting the Link Function**

- Link function follows a sigmoid (shown below) function which limits its range of probabilities between 0 and 1.
- We can interpret the regression equation as, a unit increase in variable x results in multiplying the odds ratio by
**ε to power β**. - In other words, the regression coefficients explain the change in log(odds) in the response for a unit change in predictor.
- However, since the relationship between p(X) and X is not straight line, a unit change in input feature doesn’t really affect the model output directly but it affects the odds ratio.

**R squared in logistic regression**

**McFadden’s R squared is one popular metric used.**

**Algorithm Implementation**

**trial data set**(historical data of dependent ‘y’ and independent ‘x’ variable values).

**Run the logistic regression function**(R or Python) on the trial data set. The result of the function would be calculated value of probability distribution function for y.

**test data set**(again with both x and y values). This data set is to test the accuracy of prediction.

**Applications**

- Medical preventive diagnosis, predict mortality in injured patients, risk of developing a disease.
- Election prediction based on voter characteristics.
- Preventive maintenance and prediction of failure in automotive industry.
- Geographic image processing.
- Measuring success rates of marketing campaigns based on customer feedback.
- Earthquake, weather abnormalities prediction based on atmospheric parameters.

**Thank you and Keep Learning**