Gradient Boosting Classification Learner
Source:R/learner_gbm_classif_gbm.R
mlr_learners_classif.gbm.RdGradient Boosting Classification Algorithm.
Calls gbm::gbm() from gbm.
Meta Information
Task type: “classif”
Predict Types: “response”, “prob”
Feature Types: “integer”, “numeric”, “factor”, “ordered”
Required Packages: mlr3, mlr3extralearners, gbm
Parameters
| Id | Type | Default | Levels | Range |
| distribution | character | bernoulli | bernoulli, adaboost, huberized, multinomial | - |
| n.trees | integer | 100 | \([1, \infty)\) | |
| interaction.depth | integer | 1 | \([1, \infty)\) | |
| n.minobsinnode | integer | 10 | \([1, \infty)\) | |
| shrinkage | numeric | 0.001 | \([0, \infty)\) | |
| bag.fraction | numeric | 0.5 | \([0, 1]\) | |
| train.fraction | numeric | 1 | \([0, 1]\) | |
| cv.folds | integer | 0 | \((-\infty, \infty)\) | |
| keep.data | logical | FALSE | TRUE, FALSE | - |
| verbose | logical | FALSE | TRUE, FALSE | - |
| n.cores | integer | 1 | \((-\infty, \infty)\) | |
| var.monotone | untyped | - | - |
Initial parameter values
keep.datais initialized toFALSEto save memory.n.coresis initialized to 1 to avoid conflicts with parallelization through future.
References
Friedman, H J (2002). “Stochastic gradient boosting.” Computational statistics & data analysis, 38(4), 367–378.
See also
as.data.table(mlr_learners)for a table of available Learners in the running session (depending on the loaded packages).Chapter in the mlr3book: https://mlr3book.mlr-org.com/basics.html#learners
mlr3learners for a selection of recommended learners.
mlr3cluster for unsupervised clustering learners.
mlr3pipelines to combine learners with pre- and postprocessing steps.
mlr3tuning for tuning of hyperparameters, mlr3tuningspaces for established default tuning spaces.
Super classes
mlr3::Learner -> mlr3::LearnerClassif -> LearnerClassifGBM
Methods
Inherited methods
mlr3::Learner$base_learner()mlr3::Learner$configure()mlr3::Learner$encapsulate()mlr3::Learner$format()mlr3::Learner$help()mlr3::Learner$predict()mlr3::Learner$predict_newdata()mlr3::Learner$print()mlr3::Learner$reset()mlr3::Learner$selected_features()mlr3::Learner$train()mlr3::LearnerClassif$predict_newdata_fast()
Method importance()
The importance scores are extracted by gbm::relative.influence() from
the model.
Returns
Named numeric().
Examples
# Define the Learner
learner = lrn("classif.gbm")
print(learner)
#>
#> ── <LearnerClassifGBM> (classif.gbm): Gradient Boosting ────────────────────────
#> • Model: -
#> • Parameters: keep.data=FALSE, n.cores=1
#> • Packages: mlr3, mlr3extralearners, and gbm
#> • Predict Types: [response] and prob
#> • Feature Types: integer, numeric, factor, and ordered
#> • Encapsulation: none (fallback: -)
#> • Properties: importance, missings, twoclass, and weights
#> • Other settings: use_weights = 'use'
# Define a Task
task = tsk("sonar")
# Create train and test set
ids = partition(task)
# Train the learner on the training ids
learner$train(task, row_ids = ids$train)
#> Distribution not specified, assuming bernoulli ...
print(learner$model)
#> gbm::gbm(formula = f, data = data, keep.data = FALSE, n.cores = 1L)
#> A gradient boosted model with bernoulli loss function.
#> 100 iterations were performed.
#> There were 60 predictors of which 43 had non-zero influence.
print(learner$importance())
#> V10 V11 V48 V52 V12 V57 V36
#> 19.7097062 12.8056587 8.3553172 7.4724039 7.2462522 5.8946235 5.5098608
#> V45 V4 V21 V8 V47 V46 V13
#> 5.1627623 4.3492610 4.0596331 3.9137548 3.7085400 3.4124520 3.3633818
#> V5 V26 V22 V55 V27 V15 V23
#> 3.0059740 2.8983465 2.5760175 2.3334755 2.1112127 2.0823628 1.8071046
#> V16 V51 V1 V9 V20 V49 V7
#> 1.7039959 1.6850348 1.4105187 1.3994288 1.3548494 1.2970369 1.1756207
#> V17 V60 V28 V35 V37 V31 V44
#> 1.1077672 1.0223043 0.9670103 0.9542359 0.9522755 0.8738898 0.7883649
#> V24 V3 V58 V32 V43 V54 V25
#> 0.7594512 0.7026979 0.6187861 0.5863976 0.5277795 0.5107163 0.4428077
#> V30 V14 V18 V19 V2 V29 V33
#> 0.3893974 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> V34 V38 V39 V40 V41 V42 V50
#> 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> V53 V56 V59 V6
#> 0.0000000 0.0000000 0.0000000 0.0000000
# Make predictions for the test rows
predictions = learner$predict(task, row_ids = ids$test)
# Score the predictions
predictions$score()
#> classif.ce
#> 0.2173913