Skip to contents

Random forests for blocks of clinical and omics covariate data. Calls blockForest::blockfor() from package blockForest.

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.threads is initialized to 1 to avoid conflicts with parallelization via future.

Dictionary

This Learner can be instantiated via lrn():

lrn("classif.blockforest")

Meta Information

  • Task type: “classif”

  • Predict Types: “response”, “prob”

  • Feature Types: “logical”, “integer”, “numeric”, “factor”, “ordered”

  • Required Packages: mlr3, mlr3extralearners, blockForest

Parameters

IdTypeDefaultLevelsRange
blocksuntyped--
block.methodcharacterBlockForestBlockForest, RandomBlock, BlockVarSel, VarProb, SplitWeights-
num.treesinteger2000\([1, \infty)\)
mtryuntypedNULL-
nsetsinteger300\([1, \infty)\)
num.trees.preinteger1500\([1, \infty)\)
splitrulecharacterextratreesextratrees, gini-
always.select.blockinteger0\([0, 1]\)
importancecharacter-none, impurity, impurity_corrected, permutation-
num.threadsinteger-\([1, \infty)\)
seedintegerNULL\((-\infty, \infty)\)
verboselogicalTRUETRUE, FALSE-

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

Author

bblodfon

Super classes

mlr3::Learner -> mlr3::LearnerClassif -> LearnerClassifBlockForest

Methods

Inherited methods


Method new()

Creates a new instance of this R6 class.


Method importance()

The importance scores are extracted from the model slot variable.importance.

Usage

LearnerClassifBlockForest$importance()

Returns

Named numeric().


Method clone()

The objects of this class are cloneable with this method.

Usage

LearnerClassifBlockForest$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

# Define a Task
task = tsk("sonar")
# Create train and test set
ids = partition(task)
# check task's features
task$feature_names
#>  [1] "V1"  "V10" "V11" "V12" "V13" "V14" "V15" "V16" "V17" "V18" "V19" "V2" 
#> [13] "V20" "V21" "V22" "V23" "V24" "V25" "V26" "V27" "V28" "V29" "V3"  "V30"
#> [25] "V31" "V32" "V33" "V34" "V35" "V36" "V37" "V38" "V39" "V4"  "V40" "V41"
#> [37] "V42" "V43" "V44" "V45" "V46" "V47" "V48" "V49" "V5"  "V50" "V51" "V52"
#> [49] "V53" "V54" "V55" "V56" "V57" "V58" "V59" "V6"  "V60" "V7"  "V8"  "V9" 
# partition features to 2 blocks
blocks = list(bl1 = 1:42, bl2 = 43:60)
# define learner
learner = lrn("classif.blockforest", blocks = blocks,
              importance = "permutation", nsets = 10, predict_type = "prob",
              num.trees = 50, num.trees.pre = 10, splitrule = "gini")
# Train the learner on the training ids
learner$train(task, row_ids = ids$train)
# feature importance
learner$importance()
#>            V9           V11           V48           V12           V28 
#>  2.041270e-02  1.352075e-02  1.143504e-02  7.646106e-03  7.143717e-03 
#>           V58           V17           V47            V1            V5 
#>  6.097413e-03  5.089226e-03  4.544275e-03  4.492392e-03  4.360063e-03 
#>            V6           V51           V43           V54           V52 
#>  4.176755e-03  4.125957e-03  3.447405e-03  3.257415e-03  2.921741e-03 
#>           V36           V45           V23            V8           V59 
#>  2.698945e-03  2.146047e-03  1.839357e-03  1.829732e-03  1.788199e-03 
#>           V37           V13            V4           V53           V57 
#>  1.727047e-03  1.539129e-03  1.347868e-03  1.334382e-03  1.284117e-03 
#>           V30            V7           V16           V20           V10 
#>  1.277352e-03  1.276767e-03  1.007807e-03  9.879336e-04  9.810376e-04 
#>           V55           V24           V46           V50           V49 
#>  9.696185e-04  9.494232e-04  8.804647e-04  8.483380e-04  8.238255e-04 
#>           V15           V29           V60           V14           V22 
#>  8.179760e-04  7.264957e-04  4.552686e-04  2.722119e-04  2.501257e-04 
#>           V39           V44           V32            V3           V25 
#>  2.105813e-04  2.057315e-04  1.650943e-04  8.593264e-05  2.572016e-05 
#>            V2           V41           V34           V18           V26 
#> -4.523810e-05 -4.535147e-05 -5.402161e-05 -1.014109e-04 -1.332907e-04 
#>           V31           V38           V33           V19           V27 
#> -1.546443e-04 -3.733807e-04 -3.901791e-04 -7.288538e-04 -7.492997e-04 
#>           V56           V21           V42           V40           V35 
#> -8.204807e-04 -8.789542e-04 -1.036451e-03 -1.576219e-03 -1.678397e-03 
# Make predictions for the test observations
pred = learner$predict(task, row_ids = ids$test)
pred
#> 
#> ── <PredictionClassif> for 69 observations: ────────────────────────────────────
#>  row_ids truth response    prob.M     prob.R
#>        3     R        M 0.5711746 0.42882540
#>        4     R        R 0.3784444 0.62155556
#>        9     R        R 0.4056667 0.59433333
#>      ---   ---      ---       ---        ---
#>      203     M        M 0.8023889 0.19761111
#>      204     M        M 0.9371667 0.06283333
#>      208     M        R 0.4493333 0.55066667
# Score the predictions
pred$score()
#> classif.ce 
#>  0.2753623