And now let's do the whole thing
and you're going to see that we won't get the error.
So let's select this. Okay.
So that's all the data pre-processing steps with now the encoding included.
So execute. All right.
Now we're going to fit the naive base model to the training set.
Execute.
All good.
Now we're going to create our vector of predictions y pred.
Okay.
You're going to see that if I type y pred here we will not have the predictions.
So we can compare it to y set which is the third column of the test set.
Okay. So we can compare them.
But let's not do this.
Let's just get to the point where I want to show you that.
Now a confusion matrix is going to be created without any error.
So let's select this execute.
And now as you can see the confusion matrix is created without any problem.
So and now we can have a look to see the number of incorrect predictions
which is 7.7 equals 14 incorrect predictions.
Not bad.
Out of the 100 observations of the test set.
Okay, great.
And now we're finally getting to the fun part, which is to visualize the results.
Okay. So I'll just you can pause on the video.
And now I'll just select this.
So let's see command and control.
Press enter to execute.
And there is our Naive Bayes graphic results.
Isn't it beautiful how this prediction boundary is a smooth curve?
Classifying quite well the data sets.
That is a data set of observations.
Nonlinear. Separable.
It's kind of like the kernel SVM curve.
You know it's a beautiful smooth curve that manages to catch those green users
that couldn't be caught by linear classifiers
because we had the straight line
and therefore it couldn't catch the green users here
and put them in the green category that were in the red category.
But thanks to this curve, we can see that it's making less incorrect predictions.
But still some like those 123 here.
Regarding this users here, this all the users with a low estimated salary
that were incorrectly predicted by the linear classifiers.
And then, however, it's still making some few mistakes here.
We would have liked to have a lower curve here, like the curve starting from here.
But that's what naive Bayes could do here, and that's already quite a good job.
So now let's see what it does on the test set results.
Here we have the test result code.
Let's execute it.
And here is the test set.
If the execution of this code is taking too much time,
you can try to take a lower resolution.
Because right now you can see that
we have a very high resolution with this by 0.01 step here.
We cannot see the pixels here thanks to this resolution.
If you take a no point one resolution, the script will execute much faster.
But then you will see the pixels point.
So it's as you want.
So the test set results are actually not bad as well.
It did a pretty good job classifying this green uses
here to the right green category, but still some incorrect predictions.
Resist.
Since those green points here stay in the red region.
All right, so that's the best graphic results.
I hope you enjoyed what you saw.
We're going to have other different surprises of other classifiers.
You'll see that we will get very different kind of prediction boundaries
when we look at the decision trees classifiers and the random forest.
Guess first.
So I look forward to showing that to you.
And until then, enjoy machine learning.