Hello and welcome to this art tutorial.
So in a previous tutorial, we just pre-processed our data set to make
it ready for our logistic regression model that we will fit on the training set.
So that's what we're going to do in this tutorial.
And let's do it right now.
So it's going to be very simple.
We're just going to create our classifier
equals.
And then we're going to use an existing function of R called the glm function.
That is going to build this logistic regression classifier.
So let's type here glm.
And then let's press F1 to see what parameters we have to input.
Okay.
So the first thing we see is that GLM is for generalized linear models.
And that's because the logistic regression is a linear classifier.
For those of you who didn't follow the Python tutorial,
you will see that our logistic regression classifier
will linearly separate our two classes of users.
And then let's look at the arguments to see why we have two inputs.
All right so the first argument is formula.
So that's the same as what we did in the regression section here.
We're going to write formula
equals.
And then we take the dependent variable which is purchased.
Then alt plus n.
And then here a dot to specify that we want to take all
the independent variables.
So that's way R understands that we want to predict
the purchased result based on all the independent variables
which are the age and the estimated salary.
All right.
Now what is the next argument.
So let's add a comma here. Enter.
And let's add the second argument.
So the second argument is family.
And here since we are in logistic regression we're going to add family
equals binomial.
So at this stage it's
not important to understand what binomial means exactly.
But you just have to remember that
for logistic regression you have to specify the binomial family.
Here.
And then we just need to input one last argument.
It's the data here
which is the data on which you want to train your logistic regression model.
So of course that's our training set.
So we're going to add here data equals training set.
Here we go. Here it is. Okay.
And that's it.
By only using this GLM function and precisely the formula the family
and the fact that we're building the model and the training set
that build our logistic regression classifier.
So now let's select this
command and control plus enter to execute.
And here we go.
The classifier is built.
Okay so that's it.
For this tutorial we fitted logistic regression to the training set.
And in the next tutorial
we will be predicting the test results using this classifier that we just built.
All right thank you for watching this tutorial.
I look forward to seeing you in the next one.
And until then, enjoy machine learning.