Okay.
So now we have it. So now we can use it.
And therefore just below we will actually call it.
And in order to do this efficiently we can just say the example here.
And right below
we paste it and we just replace once again why true.
But why test.
So that we can get indeed the accuracy under test it okay.
And here we don't have to do a print
because this accuracy score will directly return that accuracy.
You know that rate of correct predictions.
So there you go.
We can just play this cell you know run this cell.
And here you go. Congratulations.
You have here the confusion matrix showing that we have indeed 65
correct predictions of the class zero, meaning the customers of the test set
who didn't buy the new SUV.
Then 24 correct predictions of the class one meaning
correct predictions of the customers who but the SUV
and then three incorrect predictions of the class one
meaning three incorrect predictions of the customers who
but in reality the SUV but were predicted not two.
And finally eight incorrect predictions of the class zero mean
eight customers who in reality didn't buy
the SUV but were predicted to buy it.
Okay, so you see, the confusion matrix has no mystery.
It's very easy to read, and in a flashlight we can indeed
get the main information of our predictions.
And finally, that little number that we have here is of course the accuracy.
And here we get oh point 89,
which means that we had 89% of correct predictions in the test set.
And actually remember that there are 100 observations in a test set,
which means that we had indeed 89 correct predictions.
Actually, 65 here plus 24 is equal indeed to 89.
All right.
But for any size of the test set, this would mean that
you had 89% of correct predictions.
And that's exactly the accuracy.
The accuracy is the rate of correct predictions.
All right.
So now you know how to, you know, quickly evaluate a classification model.
You know the accuracy is usually
the right metric to use when evaluating your classification models.
So now you have it in the tool kit.
And so here we go for our final step of the journey.
We're going to visualize not only the training
set results but also the test set results.
And this will be super interesting because we will actually see
how the logistic regression classifier
was actually trained to classify our customers.
You know, our observations into the two different classes, you know, 0 or 1.
We will have super nice results showing all the real results
in both the training set and the test.
It and also the prediction regions, you know, the regions where
our predictions are zero and the other region where the predictions are one.
And you will see that the curve that separates
these two regions is exactly the classification curve.
And you will see that it will be a straight line for linear models
and something else in a straight line for nonlinear models.
I really, really can't wait to show you this
because you will really see and visualize the difference between
linear classification models and nonlinear classification models.
So there you go.
Take a little break now, and we'll tackle together
this final step to visualize indeed these two results.
And until then, enjoy machine learning.