All right.
Then, as we said, we want to get the same criterion
as in the intuition lectures, meaning entropy with the information gain.
So there we go.
Let's add criterion equals and quote entropy.
Great.
And then finally that final parameter random underscore state
to which we set the value zero.
Perfect.
And now final step you know it by heart classifier.
Then from this classifier we call the fit
method which will train the classifier only built
so far onto the training set composed of the two arguments.
We have two input here, which are x train for the matrix of features
of the training set, and then y train
for the dependent variable vector of the same training set.
And that's it my friends.
Now we're about to find out if we can beat that record accuracy of 93%.
I actually have a good feeling about this.
We might beat it, but let's not talk too fast.
We never know what's going to happen.
So first let's upload the data set by clicking this fully here.
You know let's upload it in the notebook.
So right now as usual you know same story.
The Colab notebook
is connecting to a runtime to enable file browsing on your machine.
And we will get the upload button in a second.
There we go.
So let's click it and let's go to where we have our machine learning.
It is at folder.
There it is. Mine is on my machine.
So we're going to go inside and part three classification.
Then section 20 random forest classification.
The last class regression model of this part Gratulations again
for making such huge progress with this course.
There we go inside and Python and then social network add dot csv.
Let's open it.
And now we're very close to the final result,
you know to the final discovery of whether we're going to beat yes or no.
The record accuracy of 93%. So there we go.
Let's click runtime here.
And then let's click run URL to build and train again.
The random Forest classification. Here we go.
We have it now and our future prediction.
So let's see let's see let's see what we get first that prediction
of the purchase decision of that single customer of age
30 and $87,000 estimated salary is correct, right?
Because in reality, this customer didn't buy the SUV.
And now with the test result,
let's scroll back up here and let's see a bit what we have.
So all this is correct here. Correct.
One incorrect prediction here.
Two other incorrect predictions here.
Oh maybe we won't beat it.
You know, let's see directly if we beat it and well actually no.
Wow. Okay. I'm very surprised.
I thought we had a chance to beat it.
I hope you're not too disappointed.
But indeed, we didn't beat that record accuracy of 93%.
Because indeed, with the random forest, we get 91%.
Let's try to tune.
You know, this is not our final word.
Let's try to tune a bit the number of estimators.
Maybe we can get a better one.
Let's try, for example, the default value of 100.
But you know
I don't think we will even improve that because we might yet anyway overfitting.
And this will not help of course for the predictions of new observations
in the test set.
But anyway let's try.
Let's run all again.
So this will rebuild and retrain
your random forest classification with 100 trees.
All right.
We're about to get a new one. There we go.
So now we have indeed 100 trees in the random forest.
All right.
The new result prediction is still correct as a result.
Okay. And now let's see the confusion matrix.
That's what I was telling you.
Still 91%.
So it was perhaps better trained on the training set.
But what we get on the test set is just the same.
So anyway, you know, clearly the best model for our data set here,
you know, for classification is kernel SVM and k nearest neighbors.
So I'm going to put that back to ten right.
Press save run everything again.
And I'm going to show you, you know the final visualization results
for Random Forest because it's always good to see it.
You know even if we didn't beat the accuracy let's observe them.
Let's actually observe them in the original file
because it is right now running.
All right. So we'll find them at the bottom.
And so there you go.
That's the result of the training set.
And below you have the results on the test set.
And indeed we see that even if it could be very well trained on the training set.
Well we still have some wrong predictions here of green customers
who fall in the wrong red region.
And there's not much we can do.
You know, when tuning the random forest
classification to catch correctly these customers here.
But I want to say something now.
You know,
maybe you want to play with the diverse classification models we implemented.
And by playing with them I mean playing with the parameters, you know,
trying different values of the parameters.
And please let me know, you know, in either private message or in the Q&A,
if you managed to beat 93%, you know, as a final accuracy
on the test set, of course.
But let me know if you succeed.
I'll be very interested to see how you did it.
All right, so here we are at the end of the section.
Congratulations for completing it.
Now you have some great tools in your classification toolkit.
Please understand that the best models we got here
are just for this data set before your future data set.
The best model might be another one.
It might be random forest, or it might be Naive Bayes.
So you have to try all of them.
And speaking of which, this is exactly what we'll do next.
In this part three, I'm going to take all these code templates here that we made.
I'm going to simplify them.
You know, I'm going to remove all the prints and everything
so that it can be very clear and well-structured, and mostly
so that you can get very efficient code templates that you can try and deploy
very quickly and efficiently on your data sets,
so that you can quickly figure out what is the best model and that's
what we'll do in this last section of part three.
Can't wait to meet you there.
And until then, enjoy machine learning.