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()
#>           V11           V12           V47           V49           V13 
#>  2.561028e-02  1.323409e-02  1.235312e-02  1.019343e-02  9.810706e-03 
#>           V52           V36            V9           V48           V51 
#>  9.481490e-03  8.606201e-03  7.305030e-03  6.870299e-03  5.862328e-03 
#>           V23            V4           V45           V27           V28 
#>  5.626376e-03  5.203937e-03  4.543327e-03  4.515675e-03  4.494368e-03 
#>           V10           V37            V8            V1           V16 
#>  4.441849e-03  4.049533e-03  3.858121e-03  3.820861e-03  3.566370e-03 
#>           V15           V19            V5            V6           V58 
#>  3.331810e-03  3.266639e-03  3.144055e-03  2.895907e-03  2.735605e-03 
#>           V31           V25           V18           V17            V3 
#>  2.659380e-03  2.353731e-03  2.350171e-03  1.882912e-03  1.550821e-03 
#>           V42           V50           V21           V35           V53 
#>  1.515933e-03  1.480075e-03  1.361713e-03  1.222527e-03  1.192251e-03 
#>           V24           V38           V60           V56           V39 
#>  1.104007e-03  1.089762e-03  1.055442e-03  8.904125e-04  4.835715e-04 
#>           V55           V57            V7           V22           V30 
#>  4.432917e-04  4.093713e-04  3.908065e-04  2.124441e-04  1.215933e-05 
#>           V29           V26           V14           V44           V20 
#>  9.591735e-06 -5.485564e-05 -3.424499e-04 -3.457508e-04 -4.053188e-04 
#>           V32           V43           V34           V40           V33 
#> -4.504615e-04 -4.927023e-04 -5.826639e-04 -6.545455e-04 -7.056604e-04 
#>           V54           V41           V46            V2           V59 
#> -8.328934e-04 -9.701128e-04 -1.044430e-03 -1.342388e-03 -1.897432e-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
#>        6     R        R 0.4162381 0.5837619
#>        7     R        M 0.5662460 0.4337540
#>       14     R        R 0.4997381 0.5002619
#>      ---   ---      ---       ---       ---
#>      203     M        M 0.7096667 0.2903333
#>      204     M        M 0.8194127 0.1805873
#>      208     M        M 0.5058095 0.4941905
# Score the predictions
pred$score()
#> classif.ce 
#>  0.2463768