Hello and welcome to this art tutorial.
So in the previous tutorial we predicted our test results
and now in this tutorial we are going to evaluate those predictions
by making the confusion matrix, which will count
the number of correct predictions and the number of incorrect predictions.
So let's do it.
Let's make the matrix. It's very simple.
It will just take us one line.
So let's call it CM equals.
Then very practically we're going to use the table function in R.
And in this table I will first input the real values
which are the test set brackets.
And then I have to select the columns of the real results which is
if we go to the test set this column because this column contains
the real results.
Whether the user bought yes or no, the SUV and this column has index three.
So here I will put
comma and three.
All right. So that's my first argument.
That's the real values.
And then as the second argument I'm going to input the predicted values
which is of course the y vector here.
So here I'm going to add y prep.
And I don't have to select any index because Whitbread is already
the vector of predictions.
So in short this is the vector of real values for all the observations.
And this is the vector of predictions
for the same observations as in this vector
okay. And that's it.
The confusion matrix is ready.
So now let's select this line and execute.
Here it is table created.
Now let's go to the console and have a look at it
CM enter.
And here it is.
The most important thing to understand here
is that the 57 and the 26 here are the correct predictions.
And the ten and the seven here are the incorrect predictions.
So what's interesting here at first sight is that the classifier made
57 plus 26 equals 83.
Correct predictions, and ten plus seven equals 17 incorrect predictions.
All right.
So 17 incorrect predictions on the test set.
That's not bad. But we can do better.
And we will do better with other classifiers.
You will see that in the next sections okay.
So we're done with the confusion matrix.
And finally now it's time for the best part
because in the next tutorial we will be graphically looking at our results
because we will plot this very cool chart that will allow us to make an awesome
interpretation of the results.
So I look forward to seeing you in the next tutorial
where we will make this chart.
Until then, enjoy machine learning.