# Logistic Regression using R

Logistic Regression is one among the machine learning algorithms used for solving classification problems. it’s wont to estimate probability whether an instance belongs to a category or not. If the estimated probability is bigger than threshold, then the model predicts that the instance belongs thereto class, alternatively it predicts that it doesn’t belong to the category as shown in fig 1. This makes it a binary classifier. Logistic regression is employed where the worth of the variable is 0/1, true/false or yes/no.
Image for post

1. Why Logistic Regression, Not rectilinear regression Linear Regression models the connection between variable and independent variables by fitting a line as shown in Fig 4. Image for post In rectilinear regression , the worth of predicted Y exceeds from 0 and 1 range. As discussed earlier, Logistic Regression gives us the probability and therefore the value of probability always lies between 0 and 1. Therefore, Logistic Regression uses sigmoid function or logistic function to convert the output between [0,1]. The logistic function is defined as: 1 / (1 + e^-value) Where e is that the base of the natural logarithms and value is that the actual numerical value that you simply want to rework . The output of this function is usually 0 to 1. The equation of rectilinear regression is Y=B0+B1X1+…+BpXp Logistic function is applied to convert the output to 0 to 1 range P(Y=1)=1/(1+exp(?(B0+B1X1+…+BpXp))) We need to reformulate the equation in order that the linear term is on the proper side of the formula. log(P(Y=1)/1?P(Y=1))= B0+B1X1+…+BpXp where log(P(Y=1)/1?P(Y=1)) is named odds ratio. Resources Box:- This article is inspired by Logistic Regression explained  by  Excelr Solutions.