8
Nov

# Logistic Regression in R | Machine Learning Algorithms | Data Science Tutorial | Intellipaat

Hey Guys, welcome to yet another interesting
session by Intellipaat and today we are going to look at Logistic Regression. So, we will start off by understanding what
exactly is Regression, then we will understand what is Logistic Regression and finally we will
implement the concept of logistic regression in R.
So, let’s get started!!! Let’s take this scenario, where we have
three employees: Sam, whose age is 20 and earns \$50,000
Bob, who is 35yrs old and earns \$75,000 and Matt, who is 50yrs old and earns \$100,000
Now, I will introduce a new employee to you, whose age is 28 and ask you what is his salary. What would you do? You would look at the general trend between
the age and salary and understand that as age of the employee increases, his salary
also increases. This is nothing but regression, where you
are trying to understand how does a person’s age affect his salary based on the historical
data. Over here “salary” is the dependent variable
and “age” is the independent variable i.e. you are trying to ascertain the salary
of employee, with respect to the age. Let’s look at the second scenario:
Here, we have two students, Rachel and Ross. They appear for an exam and Rachel manages
to pass the exam, while Ross fails. Now, what if another student, Monica, takes
the same test? Would she be able to clear the exam? Well, you will again look at the data provided
to you and see that Rachel being a girl, was able to pass the exam, while Ross being a
guy, failed to clear it and on the basis of this data you’d say there is a good probability
for Monica to clear the exam as well. This again is regression, where you’re finding
out if the student has cleared the exam based on their gender and hence “result” is
the dependent variable over here and “gender” is the independent variable. So, in simple terms, regression helps you
to understand the extent of relationship between two variables. Now that we have understood what exactly is
regression, it’s time to understand logistic regression.
Logistic Regression is a regression technique, where the dependent variable is categorical
i.e we determine the probability of the observation belonging to a particular category. Let’s look at an example to understand this
better.. Over here, we are trying to determine the
probability of raining, based on independent variables such as “temperature” and “humidity”. Or in other words, we are choosing a category,
namely “yes” or “no” for the question, will it rain?
Right, now, we will head on and understand the difference between linear regression and
logistic regression. In linear regression, we fit a straight line. I.e. for a given value of “x”, there definitely
exists a “y” value which falls on the line.

• Peehu Gupta says:

Is logistic regression mainly used for regression?

• Intellipaat says:

Got a question on Logistic Regression? Do write it in the comment and you will get a response immediately by our expert. For Data Science with R Programming training & certification, call us at US: 1800-216-8930 (Toll Free) or India: +917022374614.
You can also write us at [email protected]

• Manoj Joshi says:

Good introductory video. I wanted to know if i can fit a linear line with logistic regression?
Thanks.

• Anik Saxena says:

Wonderful Tutorial on R….

• Anik Saxena says:

How can I evaluate the model’s accuracy in R?

• Lavanya Shukla says:

The video is so much informative and simplified.

• Jyoti Garg says:

Can I use more than one dependent variable in the ‘glm()’ formula?

• Sonam Jain says:

Straight to the point and easy to follow. Thank you

• priyasha jothi says:

Thank you so much for the effort.

• jennifer George says:

this kind of videos are really informative.

• Samyuktha Godani says:

Amazing video.

• Kirti Kumari says:

Your description very useful keep it up …thank you intellipaat

• meena kumari says:

Thank you for a great content a great video.

• Raju Modi says:

Excellent Tutorial :very comprehensive and to the point delivering the value.

• Surveen Chawla says:

Its really nice. Its kind of summary.

• Kathikeyan Kumar says:

great lecture!!!

• abhishek khandelwal says:

Really Awesome presentation…

• jeetu patni says:

Exactly what I needed. Thanks for making this video.

• phool sinha says:

Thanks a lot!!I have spent days looking for this ..

• nidhi kholi says:

Interesting Video.

• Saba goutham says:

Great video. It was explained very well.

• Tarun Sharma says:

Perfect explanation !! Thanks

• Naveen Goyal says:

Some interesting tips, thanks!

• sakshi goyal says:

Great video! very simple and straight to the point!

• komal patodi says:

thanks for such informative videos .

• priyanka jain says:

Nice video well explained everything.

• poorva jain says:

This is really good video. Thank you so much

• Gyathri Suresh says:

thank you so much for providing this excellent video

• Ramya Nair says:

Great video… well paced
..