Logistic Regression Algorithm in Machine Learning.

Akhil Kasare
3 min readJul 14, 2020
Photo by Tim Swaan on Unsplash

The answers you get depends upon the questions you ask. -Thomas kuhn

Logistic Regression Model

Why logistic regression algorithm is used ?

Logistic algorithm is basically used for binary classification. From the above figure you can easily come to know how the classification works.

Now you might have a question that why the term regression is used in this algorithm?

For example we have a problem statement where we want to classify that the person is obese or not based on the weight. In linear regression the best fit line can be represented as

The equation can also be written as hΘ(x) = Θ0 + Θ1x

In this problem statement we have given a condition that if hΘ(x) ≥ 0.5 (It is obese) and hΘ(x) ≤ 0.5 (It is not obese).

In this we have considered the weight to be 75 kg’s we can see that our model is prediction that if your weight is 75 or more than 75 kg’s you are obessed. If your weight is below 60 kg and you want to know whether you are obessed our model will predict correctly that you are not obessed.

But what if our dataset has an outlier ?

If my dataset contains an outlier just with an inclusion of an outlier the whole straight line gets deviated. This is basically computed based on the distance & because of that there is an high error rate in our model.

This is why we should not use Linear Regression model in classification problems.

To solve this problem we will use Logistic Regression.

In this we will discuss about logistic regression in a geometric & mathematical intuition way

It is said that the key to understand any machine learning algorithm is to combine both geometric and mathematical intuition.

Why is Logistic Regression required ?

The logistic regression algorithm is applied where two classification problem can be linearly separable i.e. It can be divided with the help of straight line.

We need to update the weights unless an until we get the maximum summation. When we’ll the maximum summation that line will be particularly selected as my best fit line that linearly classifies both the classification values here.

If we have an outliers in the dataset our equation can be modified. Now the sigmoid function comes into the picture to handle the outliers.

When we actually multiply all the values this values are passed to the sigmoid function. The sigmoid function is denoted in the figure.

The sigmoid function basically transforms the values between 0 to 1. By doing this it removes the effect of outliers from the dataset.

If you have an number of a high value or outlier it will directly transform it into 0 and 1.

Thank You !

--

--