But now the most exciting part is coming
because we're going to be visualizing the training set results.
And actually, right now
we don't have to change anything except maybe the title here classifier.
And then here you need to specify kernel
SVM, kernel SVM as well as here in the test set.
So here kernel SVM as well.
All right.
Now we can get some coffee and just execute this and watch the results.
So we're going to do this.
We're going to first look at the results
here and press Command and control.
Press enter to execute.
And wow these are the beautiful results of kernel SVM.
We can see how it's making this curve here to classify.
Well most of the users in the social network here are since
we have a two dimensional space here for the data set,
that means that the data set was mapped to a three dimensional space,
and then on this dimensional space,
it managed to make the data linearly separable,
so that it can find a linear hyperplane that separates in a much better way.
The two classes.
And then it projected back to this two dimensional space
to finally obtain this curve here that separates in a much better way
the two classes than the linear classifier you would do with a straight line here,
as we saw for logistic regression or SVM, SVM with the linear kernel.
So that's what happened.
That's what happened behind the scenes.
The kernel SVM did an amazing job.
So we can say congrats.
Okay, so for those of you who are seeing this for the first time,
I'll just quickly remind what it is.
The points here are the true observations, the true results.
So the red points are the users who didn't buy the SUV in reality,
and the green points are the users who bought the SUV.
And then the regions that we see here are the prediction regions.
So the red region is the region where our model predicts
that the user doesn't buy the SUV and the green region is the one
where our model predicts that the user buys the SUV.
So for example, that means that for this particular user red points,
which is in the green region, that makes an incorrect prediction
because the truth is, the user didn't buy the SUV.
But since this user is in the green region, that means
that the model predicted that this user bought the SUV,
even if that's not what happened in real life.
So that's where the graph is about.
And here is the nonlinear separator of the kernel SVM algorithm.
And thanks to this nonlinear separator our kernel SVM could classify correctly
those users here, which wasn't the case for the linear
separators because since we had the straight lines,
it couldn't catch these users in the right category.
That is the green category, because those users
actually bought the SUV in real life.
So they should be in the green region.
And this wasn't the case for the linear separator.
And now it's the case
for the kernel SVM separator because it's a nonlinear classifier.
Perfect.
Now let's have a look at the test results to see how our model behaves
on new observations, to see if it can still classify
and predict the results of new observations.
So we're going to do this. We only have to
select this.
Press command and control.
Press enter to execute.
And here are the test set results okay.
So that looks great as well.
First an important thing to understand is that the regions that we see
here are the same regions as we saw in the data set.
If you go back to the training set and then go back to the test set,
you can see that the regions here don't change, only the observation
points change because of course these are new observation points.
And so here we can see that
the kernel SVM did an amazing job at classifying new observations
because all these test set observations here are the users who didn't buy the SUV,
because the points are red and they are in the red region.
That is the region where our classifier predicts that the users don't buy the SUV.
So that's correct. Predictions.
Same for these guys here.
All the green points that fall in the green region.
And of course we have those incorrect predictions
which are for example, this green user here
who is in the red region as well as those two green here.
So that's three.
Then we have the red users. This one, this one.
So 456789 and actually ten.
We can see that there is a little green point here hiding behind the red points
okay. Yeah.
So that's definitely a very good job.
You will see how the next classifiers
will make a different style of classification of separation.
You will see that it won't be a curve.
It will be something else.
And I will let you find out about the surprise.
But definitely the kernel SVM is a great classifier
when your data is not linearly separable.
And we can see how it definitely improved the results of the linear classifiers
that we saw with logistic regression and SVM.
All right.
So thank you for watching this tutorial about kernel SVM.
I hope you enjoyed it.
There will be a few more surprises with the next classifiers, as I told you.
Until then, enjoy machine learning.