So I know
it's supposed to be a template that work for every classifier,
but the k in and classifier will be the only classifier
we will need to change something in the template.
And that's because of this structure we changed here.
You know, for all the classifiers we had this first section
where we create our classifier with the, you know, classifier equals
and then we create our classifier with the function.
And then in another section we create a widespread
using the classifier we built in this section above.
But here, since we did both at the same time,
we just need to change a little thing here in the template.
Can you guess what it is?
Okay, so it's actually in this line because as you can see here
we are using the predict function on our classifier.
But here, since we didn't create a classifier separately
from the vector of prediction of white bread,
well that means that this predict classifier doesn't mean anything here.
So actually it's really simple.
What we need to do is to replace this predict classifier.
New data equals group set by this code here.
Because this is actually like the predict function on the.
It's creating the classifier and making the predictions at the same time.
So there is not a predict function here.
So it's very simple.
Where we only need to do is to take this
command C.
And here you know, since it's all the predictions
of the pixel points in the grid, we will need to change this.
New data equals test set.
So this test equals test set by grid set.
So basically it will be very simple.
We will remove this predict function here and paste that.
And here we're just going to replace test set by
grid set.
Because we want to predict if those imaginary pixel points
that we picture as imaginary users of the social network will buy yes or no,
the SUV according to their coordinates
in the graph that is their age and their estimated salary.
And then once the prediction is done, it will be colorized in the proper color
green.
If this imaginary user pixel point is predicted to buy
the SUV, and red if it's predicted not to buy the SUV.
And that's it, that's all we need.
So we are going to select this as well
and paste it here to do the same for the test set.
Of course, it's the same.
And here we go.
And then we are all good to plot the results.
So let's do this.
We're going to select this and let's see what we obtain.
Command and control.
Plus enter to execute the graph.
The plot is coming.
You're going to see how the cannon manages to classify
the two classes of users.
Those who didn't buy the SUV and those who bought the SUV.
And here we go.
That's the graph.
That's the prediction boundary here.
So you can see there are a lot of irregularities,
but that's because of the way the cannon model works,
because it's taking each time the five nearest neighbors.
That's all the prediction boundary.
These are our two prediction regions.
The red one and the green one.
All these points here
are the real observation points are real users of the data set.
And they're real results.
Whether they bought yes, the SUV,
if it's green and no, they didn't buy the SUV to train.
So we can see that most of our predictions are correct because all the red
points are in the red region and most of the green points are in the green region.
We also see that the cannon classifier makes a much better job at classifying
those users here that their logistic regression couldn't
classify correctly because it was a straight line,
and as some green points were falling on the red region.
So here it's a much better job.
And all those users with the knowledge above the average and an estimated salary
below the average are now well classified in the green region.
So very good, very good.
But let's not scream victory until we find out about the results
on the test set.
Because since this is the training set
and the canine classifier was built on the training set,
we might get different results on the test set.
So let's see I'm going to select this.
The test set results already execute.
And these are great results.
Most of the red points are in the red region.
Most of the green points are in the green region.
And of course we had a few incorrect predictions
like these two guys here or these two guys here.
But here it looks very good.
And we have made nice prediction regions.
Okay, so that's it for this tutorial.
I hope you enjoyed discovering this new type of classifier.
We are going to discover new kinds of classifiers in the next sections.
I can't wait to show you this and until then, enjoy machine learning.