Logistic Regression in a Supervised Machine Learning algorithm, which is used where the response variable is categorical.
- Types of Logistic Regression
- Assumptions of Logistic Regression
- Why Logistic Over Linear?
- Odds Ratio and Logit
- Logistic Regression Model
- Cost function
- Evaluation Metrics
Logistic Regression make the use of logit function, which helps to find the relationship between independent variable and the dependent variables by predicting the probability of their outcome.
Different types of Logistic Regression are :-
- Binomial Logistic Regression :- In this target variables can have only two possible outcome. ex :- Yes/No or Pass/fail etc.
- Multinomial Logistic Regression :- In this target variables can have three or more possible outcome ( outcomes don’t have any quantitative significance ). ex :- diseases A, diseases B and diseases C etc.
- Ordinal Logistic Regression :- It deals with the target variables with ordered categories. ex :-“poor”, “good”, “very good” etc.
Assumptions of Logistic Regression :-
Logistic regression don’t make any key assumptions of linear Regression like based on linearity, normality, homoscedasticity etc.
But following are the assumption still apply :-
- Binary logistic regression requires the dependent variables to be binary while the ordinal logistic regression requires the dependent variables to be ordinal.
- Observations should not come from repeated measurements or matched data.
- It requires no or little multicollinearity within independent variables which means that independent variables should not be too highly correlated with each other.
- It assumes linearity of independent variables and log odds.
- Logistic Regression typically requires a large sample size.
Reason why linear Regression is not suitable for Classification problem :-
- In Linear Regression predicted value is continuous, they are not probabilistic like Logistic Regression.
- Linear regression is sensitive to outliers or imbalance data.
- Linear regression can predict the probability from negative to positive infinity, but the probability can only lies between 0 and 1. To tackle such problem we use logit function or log-odds function.
Odds Ratio and Logit
The logit function maps probabilities from the range (0,1) to the entire real number range (−∞,∞). It is written as
Here we have L.H.S as logit function and the R.H.S as odds.
The inverse form of the logit function is also called the logistic function, and as we know that logistic function is also called sigmoid function due to its characteristic of S-shaped curve.
It always gives the probability between 0 to 1 as outcome.
The Logistic Model
Like all other regression analyses, the logistic regression is a predictive analysis.
Logistic regression uses the sigmoid function which will restrict the value of logistic regression between 0 and 1.
In logistic regression we have threshold value and value of logistic regression above that threshold value is considered as 1 and below that value below that threshold value will be considered as 0.
Cost function in Logistic Regression
Cost function quantifies the error between predicted value and the expected value. It also helps us to evaluate the performance of the machine learning model for a given dataset.
The cost function used in Logistic Regression is Log Loss.
Evaluation of Logistic Regression Model
Following are few major metrics using which we can evaluate the performance of the logistic regression :-
- Akaike Information Criteria (AIC) :- AIC is the measure of fit which penalizes model for the number of model coefficients. Therefore, a model having minimum AIC value should always be considered.
- Confusion Matrix :- Confusion matrix shows us the tabular representation of the actual and predicted value. Using this we can find the accuracy and it also helps us in avoiding overfitting.
- Receiver Operating Characteristic ( ROC Curve ) :- Higher the area under curve, better the prediction power of the model.
- Analytics Vidhya Blogs
- Few other sources