Run. All this will run all the cells, including this one,
which will get us a new model with a new non-linear kernel.
Where is it? Right here. Kernel equals RBF.
And so now.
Now it's very interesting because this time we have a non-linear classifier.
And therefore I look forward to showing you the visualization results
at the end, you know, both for the training set and tested.
Because you will see that we will get a super beautiful curve
that will catch the right observation point.
You know, the right red customers, in the right red region
and the right green customers in the right green prediction region.
Not all of them, of course, but the ones which couldn't get
cut properly by the previous, you know, linear models
such as the support vector machine or the logistic regression model.
Right. Remember this straight line?
The straight line could not catch these customer
properly in the right green region and these ones as well.
And so you will see that now we will get much better results.
But first because you know
right now I think it should be you know loading running the code. Yes.
So we don't have yet the final result.
But that's okay.
Let's observe you know the different predictions.
So first our kernel SVM was perfectly able to predict the right result here.
Remember with that customer of age 30 and estimated salary $87,000,
who in reality didn't buy indeed any SUV.
And here we get the same prediction.
So that's all good.
Then let's look at the test results.
All right. So let's scroll back up a bit.
So that's the test results.
And well once again we have many correct predictions.
An incorrect one here.
The real result is zero meaning that in reality
this particular customer didn't buy the SUV.
But our model predicted that discussing the but the SUV.
Then we have the same incorrect prediction here.
Then all correct, all correct.
It looks very good.
Here we have an incorrect prediction, the inverse one.
In reality the customer, but the SUV.
But our model predicted that the customer didn't buy the SUV.
Then all correct are correct.
Are correct.
It looks very very very good. Right?
I really wonder if we can beat this accuracy.
And that's
what we were about to find out right now with, you know, the confusion matrix.
Are you ready.
Are you going to beat that.
So for best accuracy we got which was I remind
93% from the k nearest neighbor model.
Here it is 93%.
And now let's see if we managed to beat it.
All right. Let's scroll down.
And the accuracy is 93% again okay.
So we didn't beat it but we reached the same level as the K.
And then and now let's see if we get the curve.
No still not all right. You know it's still running.
That's because we have a small step here oh point 25.
If you want this to run faster you can actually increase the step to 0.5
or even one.
But you will get a less smooth curve, you know, less nice curve.
But that's okay.
So you know, just in case it will get us the results in a few minutes or two.
Long time.
Well, let's maybe have a look at them in the original implementation
which is right here. Okay.
Just let's do that.
Let's observe the final results.
And here they are.
As you can see, we get a super nice prediction boundary curve
that catches this time perfectly well those green customers
who couldn't get cut properly.
But the linear classifiers, you know with the straight line
this time it is catching them perfectly well.
Except these ones, of course,
because they're trapped in the middle of many red customers.
But you know, these ones which couldn't be cut properly
by the logistic regression model or, you know, the SVM classifier, right?
If we have a look at it again, remember that the
customers here couldn't get cut properly because of that straight line.
But now that we have a curve, oh there we go.
We have the results.
Now that we have this curve, well, these same customers,
you know, these are exactly the same one.
These same customers are now cut properly in the green region.
And same for these ones actually, you know, these ones are cuts
in the right green region by very short and same for these ones.
And here you know, these ones are incorrect predictions.
But once again that's totally fine.
We want to avoid overfitting anyway because indeed what's mostly important
are the results of the test set, which we still don't have.
It is still running, but we should give them in a second.
Or you know, let's just have a look at them right here.
So now the challenge is to see whether we have the same results on new
observations, meaning on observations with which our model wasn't trained.
And that's exactly the observations that said, you know, the 100 customers
of the tested and well, well here now it looks even better,
which makes sense, right?
Because we had 93% accuracy.
And since they are 100 customers in a test set,
we actually have 93 correct predictions and seven incorrect predictions.
And we can actually count them here.
You know, the seven incorrect predictions.
You have the two first ones here, the red customers filling in the wrong green
prediction region.
Then these two here, two other red customers falling in the wrong green
prediction regions, and then these three green customers falling in the wrong red
prediction region.
But that's totally fine.
Once again, thanks to this beautiful curve here,
we managed to catch these customers in the right region, which couldn't be the case
previously because of the straight line resulting from the linear classifier.
But this time, there we go.
We have a nonlinear classifier, which is the reason why we have this curve
and that's why we get a better accuracy.
All right.
So I'm at the same time very happy and excited
because this curve is beautiful and we got great results.
But I'm still hoping that with a future classification model
like the three ones we have left, we can beat that 93% accuracy,
which we got so far as the best ones by two models,
the K-nearest neighbors and the kernel SVM.
So I look forward to seeing you in this next practical activity.
And until then, enjoy machine learning.