1. Stochastic Gradient Boosting (SGB)
2. Gradient Boosting: Cons
Gradient boosting involves an exhaustive search procedure.
Each tree in the ensemble is trained to find the best split-points and the best features.
This procedure may lead to CARTs that use the same split-points and possibly the same features.
3. Stochastic Gradient Boosting
To mitigate these effects, you can use an algorithm known as stochastic gradient boosting.
In stochastic gradient boosting, each CART is trained on a random subset of the training data. This subset is sampled without replacement.
Furthermore, at the level of each node, features are sampled without replacement when choosing the best split-points.
As a result, this creates further diversity in the ensemble and the net effect is adding more variance to the ensemble of trees.
4. Stochastic Gradient Boosting: Training
Let's take a closer look at the training procedure used in stochastic gradient boosting by examining the diagram shown on this slide.
First, instead of providing all the training instances to a tree, only a fraction of these instances are provided through sampling without replacement.
The sampled data is then used for training a tree. However, not all features are considered when a split is made. Instead, only a certain randomly sampled fraction of these features are used for this purpose.
Once a tree is trained, predictions are made and the residual errors can be computed. These residual errors are multiplied by the learning rate eta and are fed to the next tree in the ensemble.
This procedure is repeated sequentially until all the trees in the ensemble are trained.
The prediction procedure for a new instance in stochastic gradient boosting is similar to that of gradient boosting.
5. Stochastic Gradient Boosting in sklearn (auto dataset)
Alright, now it's time to put this into practice. As in the last video, we'll be dealing with the auto-dataset which is already loaded.
Perform the same imports that were introduced in the previous lesson and split the data.
6. Stochastic Gradient Boosting in sklearn (auto dataset)
Now define a stochastic-gradient-boosting-regressor named sgbt consisting of 300 decision-stumps.
This can be done by setting the parameters max_depth to 1 and n_estimators to 300.
Here, the parameter subsample was set to 0-dot-8 in order for each tree to sample 80% of the data for training.
Finally, the parameter max_features was set to 0-dot-2 so that each tree uses 20% of available features to perform the best-split.
Once done, fit sgbt to the training set and predict the test set labels.
7. Stochastic Gradient Boosting in sklearn (auto dataset)
Finally, compute the test set RMSE and print it.
The result shows that sgbt achieves a test set RMSE of 3-dot-95.
8. Let's practice!
Now let's try some examples.