Logistic Regression in Machine Learning

Harasis Singh
Analytics Vidhya
Published in
3 min readSep 23, 2020

Logistic Regression is a technique that can be used for traditional statistics as well as machine learning.

Logistic Regression is similar to Linear Regression except Logistic Regression predicts whether something is True or False, instead of predicting something continuous like the size.

Also, instead of fitting line to the data , Logistic Regression fits an “S” shaped logistic finction.

The curve goes from 0 to 1, ie the curve tells us the probability of that specific point on the curve.

Logistic Regression generally used for Classification.

Just like Linear Regression, logistic regression can work with continuous data (like weight and age) and discrete data (like genome and astrological sign).

Logistic Regression uses Maximum Likelyhood Estimation (MLE) to fit the line. MLE is a technique used for estimating the parameters of a given distribution, using some observed data.

  • It calculate the likelihoods of all the points and then multiply all those likelihoods together. That is the likelihood of the data given this line.
  • Then you shift the line and calculate a new likelihood of the data and then again shift the line and calculate likelihood again and again…
  • finally the curve with the maximum likelihood is selected.

Use of Sigmoid Function in Logical Regression-

The reason we choose a sigmoid function to model classification problems solved with logistic regression is that we want to make sure that predicted value has a defined range (ie between 0 to 1) which aids us in differentiating the classes.

Y = 1 / 1+e -z

So, if the value of z goes to positive infinity then the predicted value of y will become 1 and if it goes to negative infinity then the predicted value of y will become 0. And if the outcome of the sigmoid function is more than 0.5 then we classify that label as class 1 or positive class and if it is less than 0.5 than we can classify it to negative class or label as class 0.

Difference Between Linear Regression and Logistic Regression-

  1. Linear Regression fits the line to the data whereas Logistic Regression fits as “S” shaped logistic/sigmoid funtion.
  2. Linear Regression is good for predicting continuous output like salary, housing prices etc. whereas Logistic Regression is used for classification problems which predicts a probability range between 0 to 1.
  3. With Linear Regression we fit the line using ‘least squares’, in other words we find the line that minimizes the sum of the squares of the residuals whereas Logistical Regression uses Maximum Likelihood Estimation (MLE) to fit the line.
  4. In Linear Regression we can also use residuals to calculate to compare simple models to complicated models. whereas, in Logistic Regression there is no concept of residuals so we can’t calculate R².

Summary of Logistic Regression-

  • Logistic Regression can be used to classify samples.
  • It can use different types of data (like size, genome) to do the classification
  • It can be used to assess which variables are useful for classifying samples.

I hope that you like my short article about Logistic Regression.

Thank you!!!!!!

--

--