So let us see how to do preplanning and our.
So the first step is to create the full three.
That is we will not stop it at any point.
We will not give it a stopping constraint.
We will let it grow to its maximum, to its maximum land.
So you know how to grow a tree.
You'll use the ah part library.
You need to install it and make it active before using it like we did in the last video.
So we're using this are part, Labidi.
We will clear the street only differences here.
I'm using this control parameter.
The c.p is that same during parameter that we discussed, NATO related.
Since we have bought CPS equal to zero, the tree will grow as a normal tree.
There will not be any pruning and we will get the maximum land for this tree.
So if I run this command, I press control into.
So we need to take this check box so that we can build history.
So we'll run that on.
And in the four three variable, we have the details of our complete regression tree with no pruning.
Now, if you want to just have a look at this story, we can run this our plourde function and you will
see that it is a huge tree.
Now, when we run this regression tree, using our part, it by default runs the tree on different values
of c.p.
That is this control parameter that was during Parameter Aalto.
If you want to look at how the relative error in our tree is changing with the value of C.p, we can
run this command print c.p.
You can see here.
The different values of C.p.
We get different relative air values.
This ex added value is the cross-validation error.
We want to find out that value of S.P. for which the cross validation error is minimum.
That value of S.P. other tuning parameter will be used to prune the tree.
Now you can also plot this plot.
These are the lives of S.P. and Exeter.
By using this block C.p function.
And you can see that as we keep on increasing the value of S.P., the relator weather is initially decreasing.
Then it starts to increase and so on.
So basically somewhere around here, there should be some value of S.P., at which Relator Atari's minimum.
So to find out that particular point, that particular value of S.P. at which cross validated later
whether it is minimum, we will run this command.
And just go on.
We are finding that valley of S.P. variable for which X added value and this S.P. table is minimum.
So that c.B value will be stored in this man S.P. variable.
So if I had run this KomaI, a new variable is created Mincy P.
And it has a value, nearly zero point zero one.
Now, using this valley of S.P. Autotuning parameter, we will round up prune command and the same tree
will be pruned.
Will prune the full tree using this valley OCP.
So will use prune function.
We will input the full three variable, which contains the information of full regression tree and CPI
equal to this mincey.
B, the C p value at which we were getting the minimum cross validated relative error.
And I'd underscore my.
Groomed, grieving Abel now has the information of deep rooted three.
If you want to blog this Plumtree, we will run this command, which is our blog.
You can see that there are only four levels left now.
The three is much more clean interpretable and possibly it has less overfit.
Now to Genndy performance of this tree on the said.
And compared it with the performance of the fall tree and the tree that we created earlier, we will
run these commands first.
We will predict the values on the test set using the predict function of the on before tree will then
my.
And now in the desert, we have another variable for tree, which contains predictions using the information
indeed for tree regression tree.
So if you want to look at the predictions, you can click on, Essid said.
And you can go to the end and see that there is a new column for.
It has the predictions it.
You can see for first row the predicted values, a leawood, forty six thousand nearly this prediction
value is for Dadri, which we created last time that we had a maximum depth of three.
This country had no such constraint.
It had a lot of levels.
And history is predicting nearly 59000 collections.
This seems far from the actual value.
But if you look at the second observation.
The prediction of the previous three was far from the actual value, but the prediction of distri of
the full three is very near to the actual value.
So we have the predicted values using the predicted values, we can find out the MSE Dussel that we
are able to compare the MASC that these previously great entry, we will create a new variable, MACV
full.
And we will run this command.
Now, you can see that then we had a depth of three, then we applied the constraint that the depth
should be maximum three.
We had masc of one hundred, 13 million.
But when I create the full three, that is when we do do not give any constraint on the tree.
That tree has a MSE of ninety nine million.
So there is a considerable decrease in the MSE value.
Now, let us take the performance off the prudery so we'll first find out the predictions using the
Plumtree variable and.
That those predicted values are in another column and detested, so we can again click on desert.
We can go to the last column and you can see there is additional column broomed, which has the prediction
from the Plumtree.
Now let us find out the embassy of this and compare its performance.
We'll run this command and you can see that we have MASC of Plumtree at ninety seven million.
There is a slight improvement in the prediction accuracy of Plumtree over difficulty.
This improvement may seem counterintuitive.
That is, this is a smaller tree.
Whereas Vaudrey was a very large tree.
So you may feel that full tree should have more prediction accuracy.
But the reason here is because in full tree we were orbiting on the training data.
So using the alpha value at which we had lowest cross validated error, we have pruned this tree.
To get listed on the desk.
This is all we do to keep running, to get a shorter tree than better prediction accuracy on that side
and more into breathability.