Hello, my friends.
All right, let's do this.
Let's build and train the decision tree regression model on the whole data set.
So I actually could ask you to do it yourself.
You know, even without giving you the hint of what class you would use.
Because I also would like you to practice to research the documentation.
So if I were to ask you to try to do this before me, you know,
to build and train this decision tree regression model on this data set.
Well, what you would have to do would go to Google or Bing
and then type in the search bar decision tree regression class of scikit learn.
Then you would find the name of the class.
It would probably be on the first link.
And then based on all the work we did before you know, on how to build
and train a machine learning model with scikit learn,
you would totally be able to do this whole step on your own.
All right.
So if you want to do this, please press pause on this video
and do the exercise and I'm sure you'll be proud to find the solution.
All right.
And now let's build a solution together.
Starting with the creation of a new code cell.
And here we go.
The name of the class that can build a decision tree regression
model in scikit learn is called decision tree regressor.
It is a class that belongs to the tree module of scikit learn.
And therefore here we're going to start from scikit learn,
from which we're going to call that tree module
and from which we're going to import that decision.
Google collab will guess it. There we go.
So be careful. It's not decision tree classifier.
That will be for for three classification but decision tree regressor.
All right.
This is based on the same model. Decision trees.
But decision tree regressor will predict a continuous numerical value.
And decision tree classification will predict a category.
All right then the next natural step here is of course to create an object
or an instance of that decision tree regressor class.
And we're going to call that as usual regressor,
which will be equal of course to the call of this class.
So I'm copying this and pasting that right here and adding some parenthesis.
All right.
So now the question is do we have to input anything here in the parenthesis.
Well actually no you know
there are not many parameters to tune in the decision tree regression model.
I don't recommend to spend too much time tuning it and just to try it
among your other regression models.
But if you really want to tune it, please note that there is this part
ten of the course which covers all the techniques of parameter tuning,
which allows you to improve and optimize the performance of a single model.
And so don't worry, you'll know how to deploy these techniques
to and handsome model.
But here
we just want to learn how to build and train the decision tree regression model.
And therefore
we will only input one parameter, but which is just for training purposes.
It is, you know, that random state parameter
which will allow us to get the same result in the end, because indeed
there are some random factors happening when you build
and train your decision tree regressor.
And therefore if we don't fix the seed, we will get slightly different
results again.
And you know, it's
nicer to have the same results so that we can all be on the same page.
So we're just going to input random underscore
state parameter and set that equal to zero.
Right.
We're fixing the seed here with that zero value for the random state parameter.
And now final step.
Well you totally know how to finish this.
We just need to take our regressor and then call the fit method
which takes as input of course the matrix of features x the whole matrix
and then the dependent variable vector y'all.
Right.
So this will actually train your decision tree regressor
to understand the correlations between the position levels here
and the salaries, after which you will have a trained model
which you will be able to deploy in production to predict a new result
and especially that salary of the position level 6.5.
All right.
So that's what we'll do in the next tutorial.
But first let's not forget to run the cell to indeed
build and train that decision tree regression model.
And also I want to say congratulations.
If you, you know, press pause at the beginning of this tutorial
to code this by yourself first.
And also congratulations to those who tried because that's really
what matters.
You know, to take action to at least try and practice.
Okay.
So all good here.
That's great. We have our regression model.
And now in that same spirit of, you know, taking action to practice
and try to implement things on your own, well, I would like you to try
to predict that salary of the position level number 6.5.
And there is absolutely no trap here or no difficulty.
So I have no doubt you will actually smash this.
All right.
So please try to do this and will implement the easy solution
together in the next tutorial.
Until then, enjoy machine learning.