In this video, we are going to learn how to implement a double sting and not a double thing or adaptive
boosting can only be done on classification trees in art.
It cannot be done on regular countries.
As of now.
To do Addabbo thing, we use a package called At our back a.D.A B.G..
So we'll first install this package.
The package is downloader and successfully installed.
You can see on that idolater this package is available in the library.
No, be activated by running library command.
And this package is now active to be used since we are going to do classification.
We'll be using the classification training set, which is train C and we will test the performance on
the test classification said, which is STC.
The first thing that we have to do is we have to change the response variable, that is the static Oscar
two factor type of variable.
So if you open the street and he does say.
This last variable is numeric with the range zero or one.
But when we are running a classification model, this has to be a factor type that is categorical.
So I should know that the output variable is a categorical variable.
So we need to change this numeric to factor type for that.
We will run discom on trains each dollar.
This variable gets the value as factor of this way variable to the night on this.
And now I open Kranti.
Now, if I hold over this column, it is in fact, that with two livid.
This variable can now be used for bringing that model.
Now we have to train our model for that.
We use the boosting function in the back package.
This boosting function will give us the model information, which will be stored in another boost variable.
So this will be a very well created.
And it will have the information of the booster model.
And this boosting function.
The first parameter we give is, again, the formula, which is that star tech Oscar will be our dependent
variable at the lesson.
And then all the independent variables for which we give us an Beloff dot data is going to be trained.
See.
There will be a barometer called Boose is equal to true.
If this is true, boosting will be done.
That is when we are taking all the bootstrap sample to train the next tree.
It will have mode where date for the misclassified guesses.
So if I open the help for this function, you can see there is a booze argument, which is just saying
that if through a boot straps and all of the training set is drawn, using the weights for each observation
on that I operation.
So since we want the words to be considered.
Therefore we will keep both is equal to true.
There are other parameters also which are not mandatory, but you can go through them and thus help
section.
Well, run this go on.
And now I have this.
I boost very well, which contains the information of adaptive boosted model.
Now, using the information in this model, I'm going to predict the values on the test data.
And this predicted values will be used to c.D prediction accuracy.
So I used again to predict function.
First parameter will be the model.
Second parameter will be the test set.
So this spread at every level will get the predicted values.
And from this model.
So at underscore on.
And there will be a parade and up believable if I click on this, you can see it has several parts.
One is Formula One is boards, then is probability and so on.
We are interested in this particular one, which is having the predicted class.
So if I want to access this, I like the dialogue class.
So this is what I do in the next part.
I will create a confusion matrix on this table using red at our dollar plus, which is the predicted
values.
These will be needles and Dessy dollar start.
Take Oscar.
These are the actual values toward this variable.
So when I run this on the rolls, I have the predicted values on the columns.
I have the actual values.
These Bagnold are the correctly classified observations.
So we have twenty nine plus forty one correctly class rate observations, which is nearly 70 out of
113 total observations.
So our test set had 113 total of deletions.
So if you want to check the prediction accuracy Greevey 70 by one one three.
And it is nearly sixty two percent.
We can change some of the parameters here to get different prediction accuracy.
So if you look at this help, that is this and final argument.
It is the number of iterations for which boosting is run by default as it is hundred.
If I report and final is equal 2000.
And bring this model again, predictive values again and create this table again.
Now, by increasing the value of M final two, one thousand, which was a little one hundred, you can
see that the prediction accuracy is now 77 out of one or thirteen.
So if we jig's 77 by 113 is sixty eight percent.
So you can see by changing the parameters in the boosting formula.
You can increase the the prediction accuracy of this model.
There is an option to block any tree that it opposed, created through throughout the hydration process.
So if you want to plot the first tree, you can store that value in some variable and you can plot that
value to see the tree.
So this is what the tree looks like.
But it does not have any labelling on it.
That is which renewable was used to split.
And all this splitting value.
All that is not written for that.
We will run this text command.
You can see the text is now here, but still it is not looking good.
If you zoom it.
It comes out to be something like this, although not very readable, but still you can get some idea.
So the three created by Adbusters also readable and you can Broyer using blog function.
So this is how we create an edible model.
Remember a few things.
One, it can be done only on classification trees.
Second, the dependent variable or the variable that you want to predict should be in factor format.
I showed you earlier that our variable was in numeric format.
It had Value 011 with the same values.
It can be changed to factor alter.
So use this as vector to change the training response variable values to factor.
Then you can train the model and predict the values and find out the conclusion matrix in the same way
that we used to do.
What other methods also?
We're definitely open the help for boosting function.
Check out different arguments.
Try out different values for them and try to see what does the impact of changing accuracy or the time
taken to run the program, etc., of changing the value of these parameters.
That's it.
And this we do it in.