Gradient boosting ensembles weak learners and creates a new base learner that maximally correlates with the negative gradient of the loss function. One may apply this method on either regression or classification problems, and it will perform well in different datasets.
In this recipe, we will introduce how to use gbm
to classify a telecom churn
dataset.
In this recipe, we continue to use the telecom churn
dataset as the input data source for the bagging
method. For those who have not prepared the dataset, please refer to Chapter 7, Classification 1 - Tree, Lazy, and Probabilistic, for detailed information.
Perform the following steps to calculate and classify data with the gradient boosting method:
- First, install and load the package
gbm
:
> install.packages("gbm")> library(gbm)
- The
gbm
function only uses responses ranging from0
to1
; therefore, you should transformyes
/no
responses to numeric responses (0
/1
):
...