BlockForest Regression Learner
Source:R/learner_blockForest_regr_blockforest.R
mlr_learners_regr.blockforest.RdRandom forests for blocks of clinical and omics covariate data.
Calls blockForest::blockfor() from package blockForest.
The training model includes only the $forest slot, excluding the paramvalues
and the biased_oob_error_donotuse.
In this learner, only the trained forest object ($forest) is retained. The
optimized block-specific tuning parameters (paramvalues) and the biased OOB
error estimate (biased_oob_error_donotuse) are discarded, as they are either
not needed for downstream use or not reliable for performance estimation.
Initial parameter values
num.threadsis initialized to 1 to avoid conflicts with parallelization via future.
Meta Information
Task type: “regr”
Predict Types: “response”, “se”
Feature Types: “logical”, “integer”, “numeric”, “factor”, “ordered”
Required Packages: mlr3, mlr3extralearners, blockForest
Parameters
| Id | Type | Default | Levels | Range |
| blocks | untyped | - | - | |
| block.method | character | BlockForest | BlockForest, RandomBlock, BlockVarSel, VarProb, SplitWeights | - |
| num.trees | integer | 2000 | \([1, \infty)\) | |
| mtry | untyped | NULL | - | |
| nsets | integer | 300 | \([1, \infty)\) | |
| num.trees.pre | integer | 1500 | \([1, \infty)\) | |
| splitrule | character | extratrees | extratrees, variance, maxstat | - |
| always.select.block | integer | 0 | \([0, 1]\) | |
| importance | character | - | none, impurity, impurity_corrected, permutation | - |
| num.threads | integer | - | \([1, \infty)\) | |
| seed | integer | NULL | \((-\infty, \infty)\) | |
| verbose | logical | TRUE | TRUE, FALSE | - |
| se.method | character | infjack | jack, infjack | - |
References
Hornung, R., Wright, N. M (2019). “Block Forests: Random forests for blocks of clinical and omics covariate data.” BMC Bioinformatics, 20(1), 1–17. doi:10.1186/s12859-019-2942-y , https://doi.org/10.1186/s12859-019-2942-y.
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::LearnerRegr -> LearnerRegrBlockForest
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::LearnerRegr$predict_newdata_fast()
Method importance()
The importance scores are extracted from the model slot variable.importance.
Returns
Named numeric().
Examples
# Define a Task
task = tsk("mtcars")
# Create train and test set
ids = partition(task)
# check task's features
task$feature_names
#> [1] "am" "carb" "cyl" "disp" "drat" "gear" "hp" "qsec" "vs" "wt"
# partition features to 2 blocks
blocks = list(bl1 = 1:3, bl2 = 4:10)
# define learner
learner = lrn("regr.blockforest", blocks = blocks,
importance = "permutation", nsets = 10,
num.trees = 50, num.trees.pre = 10, splitrule = "variance")
# Train the learner on the training ids
learner$train(task, row_ids = ids$train)
# feature importance
learner$importance()
#> cyl wt disp hp carb am
#> 9.28256680 4.37152698 2.90594194 2.77961057 2.10826308 2.07194376
#> drat qsec gear vs
#> 1.53270706 -0.06164316 -0.07234622 -0.08566678
# Make predictions for the test observations
pred = learner$predict(task, row_ids = ids$test)
pred
#>
#> ── <PredictionRegr> for 11 observations: ───────────────────────────────────────
#> row_ids truth response
#> 2 21.0 20.98703
#> 4 21.4 19.66009
#> 5 18.7 17.25553
#> --- --- ---
#> 20 33.9 27.71575
#> 22 15.5 16.80642
#> 29 15.8 18.18619
# Score the predictions
pred$score()
#> regr.mse
#> 7.015808