All right, so that's done.
That's, what we had to input for train here.
So train is your training set, but without the dependent variable then comma.
And then let's add the second argument.
So the second argument is test.
So you can guess what it is.
It's going to be the same test equals test set of course.
All right.
So test set and then same training set.
We're going to remove
the dependent variable because anyway we are supposed not to know the results.
We want to predict the observations of the test set.
So anyway we need to remove it.
So comma to take all the lines and minus
three to remove the last column
okay.
So we have our training set and our test set.
And now what is the next parameter okay.
The next parameter is CL factor of true classification of training set.
So can you guess what it's going to be
okay.
Let's see CL equals in your opinion what is it going to be.
Well you know to train a classifier
the classifier needs to have okay the independent variables.
But it also needs to have
the dependent variable because it needs to have the results to,
you know, find the correlations between the informations of the independent
variables and the information contained in the dependent variable.
So here, since we only have the info about the independent variables,
we also need to include somewhere the info of the dependent variable.
And that's what we add here.
That's the CL so factor of true classifications of training set.
That is the categorical dependent variable.
So let's do this.
So to take this vector actually.
So as you can see that's the last column of the training set.
So it's going to be training set taking all the lines of the observations.
And then the 123.
So third index of the column purchased.
So let's take that training set brackets come up.
And then three because the column we want is indexed by three.
All right. So that's for the third argument.
And then we have one more argument which is the number of neighbors.
So let's add this one.
So remember in Python we took five neighbors.
That's actually the default parameter.
So here we're going to take the same.
That will allow us to compare the results we obtained on Python in R.
So it will be interesting.
So let's take k equals five neighbors.
All right.
And now we have everything we need.
We can select this.
And here it is widespread.
All good.
So now let's have a look at white bread.
We can have a look here.
White bread and pressing white bread in the console and press enter to
have a look at it.
And here are all the predictions for the test set.
So remember the test.
It contains 100 observations.
So here we have 100 predictions.
Correspond to the same observations as these guys here.
So for example let's take the first observation to the first users.
So let's take the 12345.
So the five first users these five first users didn't buy the SUV.
In reality because the purchased variable equals zero here.
And that's the truth.
That's what actually happens in reality.
And what does our prediction say?
1234550 here.
So correct predictions for the five first users okay perfect.
Then then we have four ones.
The the 678
and nine users actually bought the SUV.
So great for the six one.
The seventh one great. Correct prediction eight one.
Correct prediction as well. But the classifier.
You made a little mistake here.
But that's fine.
It looks like it's making some correct prediction most of the time.
And then we were going to check that on the confusion matrix.
That will be faster.
Was just to
you know, understand to explain what white bread was.
But I think you get it.
So here we just need to select this and execute
here CM we can have a look at it in the console.
CM and that's the predictions okay.
So we have six plus five incorrect predictions 11 incorrect predictions.
So that's not too bad.
And now what we are most interested to see is the prediction regions
how they behave and especially the prediction boundary to
see if it's going to be a straight line or something else.
And actually you're going to see that the K then is a nonlinear classifier.
So we will get something different.
Then once we got the logistic regression.