Okay.
So let's have a look at the arguments.
The first argument is formula.
So as for SVM it's going to be purchased tilde.
And then a point.
And the point represents all the independent variables.
So we know this then data. Okay.
So yes you need to specify the data because you want to specify the data
set on which you want to train your kernel SVM model.
So we need to specify data equals training set.
Because we are training a model on the training set.
Then x, y and scale are not important here.
What's really important are the type and the kernel.
So the type is whether you want to make a regression model
that is SVM for regression, that is SVR that we saw in the regression part,
or SVM for classification, which is the common way of saying SVM.
So here we will need to specify the C classification type,
which is the default type for classification for SVM.
Remember in the as the R we chose EPS regression.
That was the default type for regression for SVM.
But here we are in classification.
So we will choose this classification type.
And then the most important is the kernel.
Here we jumped to a higher level.
We are making a more sophisticated SVM than the SVM we did
in the previous section, which was a linear kernel SVM.
But now we want to go pro and we are choosing a Gaussian SVM,
which you will see
make a terrific job at classifying your users in the social network.
Because remember the kernel SVM was linear,
which made our SVM model a linear classifier
and therefore the separator separating the two classes of users
was a straight line here and therefore couldn't get the users here.
That made our data set non-linearly separable.
So here we're going to choose the Gaussian kernel,
which is going to be the radial basis kernel.
Actually we're not going to write radial basis.
We're just going to write radial. That's how it works.
But the Gaussian kernel is radial.
Actually you can see the formula here.
Carol gave you the formula of the Gaussian kernel.
And here it is.
Okay.
So now let's jump back to our code
and let's implement this.
Okay.
So remember the first argument was formula.
And then here we have to
first take the dependent variable which is purchased.
Now if we go back to our data set this is the dependent variable.
And this is purchased then tilde which is alt n
and then a dot to take all the independent variables of our training set.
That is we're taking age and estimated salary.
All right then comma to go to the next argument enter.
And then the second argument.
So the second argument remember it was data
equals the training set okay.
And then the next parameter what was it.
It was type
type equals C classification.
Actually we don't really need to input the type here
because it's the default type.
But let's specify this to, you know, make the distinction between
SVM for regression SVR and SVM for classification kernel SVM here.
And then of course we will add the essential parameter
for this section kernel SVM which is of course kernel.
And that's where we pick our more sophisticated kernel
which is the Gaussian kernel call here radial.
All right.
Now our classifier is ready.
So let's immediately select this.
And perfect our classifier is now built.
So now let's use it to predict the test results.
So we're going to select this line simply and press Command and control.
Press enter to execute.
And here is our Y prat. Let's have a look.
Why pred.
We type right pred here in the console press enter.
And here we have all the predictions for the test set.
So there are 100 predictions.
So let's have a look at the first one.
So we need to compare this widespread which is the vector of predictions
with the true results of the observations,
the true results, whether they bought yes or no, the SUV.
And for this we need to go to the test and here to check it out.
So let's see the one, two, three,
four and five users didn't buy the SUV.
In reality.
And our predictor predicted that the same five users didn't buy the SUV.
So that's some correct predictions.
It's a very good start.
Then if we look at the next observation we have one here, one here,
one here, one here.
So that makes the eight first predictions correct predictions.
And here we have our first mistake, our first incorrect predictions.
Because for the user number 22,
our classifier predicts that this user wouldn't buy the SUV.
And in reality it did.
If we look at the number 22, we can see that we have a one here,
which means that this user bought the SUV.
Okay, so but the best way to look at these
prediction is to use the confusion matrix.
So let's do this.
The section is here already.
We don't have to change anything.
The template is there to ease our work.
So let's select this line.
Let's give it a control. Press enter to execute.
And here we have our matrix.
So we're going to look at it in the console.
So cmd here enter.
And here is the matrix okay.
So what do we have here.
We have 58 plus 32 equals 90 correct predictions.
And four plus six equals ten incorrect predictions.
So that's not too bad.