Let's do it.
So it's ready to be built.
And that means all our code is ready to be executed.
Because we don't need to change anything more.
So let's execute these sections one by one,
and let's see what happens with decision tree regression.
So I'm going to select the first section.
Execute data sets one imported.
Here it is.
All right.
So then no need to split the data set into a training set and a test set.
Because as you can see this is a very small data set.
Then no need for feature scaling because for decision trees
we don't need to do any feature scaling.
Because the way this model is built is based on conditions
on the independent variable and not on Euclidean distances.
So we're fine with that.
We definitely don't need to apply feature scaling, and we can move on
to the next step which is to create our model.
So let's create it executing all right.
Perfect regressor is created.
And now let's get our final verdict.
Okay.
So 160 K according to this person.
And now let's see the predicted salary according to our model.
So executing this and we get a $249,000.
Well much higher than the salary mentioned by this person.
But let's not drop
hasty conclusions and let's see what's happening on the graph here.
So I'm going to select all this
and let's see what's happening with the decision tree regression results.
All right.
That's what I thought okay.
So we don't need to zoom in to clearly see what's happening here.
It's plotting a straight horizontal line.
Exactly like we saw in SVR with for Python.
For those of you
who didn't follow the Python tutorial,
note that we already encountered this situation.
When we get a straight horizontal line.
And actually in SVR.
This was due to the fact that we didn't apply feature scaling to our data set.
So what do you think the problem is here?
Do you think it's due to the fact that we didn't apply feature scaling
like for SVR, and we need to apply feature scaling to get a model fitting properly.
The data set.
Well, as I mentioned in the beginning of this tutorial,
we definitely don't need to apply feature scaling for decision trees because
decision tree regression models are based on condition on the independent variable.
That has nothing to do with Euclidean distances.
And you know, when we need to apply feature scaling, it's
because the machine learning models are based on Euclidean distances,
and we need to put all the independent variables on the same scale so that one
independent variable is not dominating another one.
But this is not the problem here.
This is not about feature scaling.
You can try to apply feature scaling here and re-execute this,
but you'll get the same problem with a straight horizontal line.
And of course this is actually the decision tree model.
This is actually one model of decision tree.
But this is of course
not the best version of decision tree regression we want to get.
So can you start seeing what's the problem here?
And especially after watching the intuition tutorial made by Kirill,
can you spot the problem?
Okay, I'm going to tell you
this problem is related to the number of splits.
Because you know, the way the decision tree regression model is made
is that it's making some splits based on different conditions.
So the more conditions you have
in your independent variables, the more you have splits.
And here we clearly have no split here because you know,
all the predictions are equal to $250,000.
So, you know, it took all the different salaries
for the different ten levels here and made an average
and just gave the average for all the levels.
So no conditions here, no splits.
And therefore that's absolutely not interesting,
especially for the potential the decision tree can have.
So what we'll do now
is add a parameter here that will set a condition on the splits.
You know that's what I was telling you.
We have several parameters in this output library.
And we can use these optional parameters to improve our model
and make it more robust.
Well this is exactly what we're going to do now.
We are going to get back to our part.
So I'm going to press F1 here.
Oh actually this time our part is showing up okay.
So grades are parts here.
And as I mentioned our part has several parameters
that we can use to make our model more robust.
And the one we're interested in right now is one parameter
that will correct this problem we had with the splits.
So this parameter is actually the control parameter.
And right now I'm going to give you a little trick to solve this problem.
On the splits we had just obtained here.
So I'm going to add this third optional argument.
You know to improve our model.
Right now we doing some model performance improvement.
So that's a thing that machine learning scientists do very often in their job.
So don't worry we'll get more advanced sections on it,
especially when we cover cross-validation to find the best models.
Selecting the best parameters.
But here we'll just do some simple model performance
improvement and we'll just add this control parameter.
And then I'm going to give you this little trick.
So this little trick is to take the R part library again.
So we're taking our part control here which is a function.
And in this function we're going to add an argument.
As you can see here on this yellow rectangle here
we have the first argument that is min split.
And that's exactly what we're interested in.
And that's what will solve our problem.
Because you know
actually we didn't have any split here because it just took the average.
So it's like we had no conditions on the independent variables and no splits.
So to make sure we have some splits and some conditions
on the dependent variables, we will actually set
min splits to one and that will solve the problem.