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            V9           V10           V48 
#>  1.814541e-02  1.656547e-02  1.515708e-02  1.319563e-02  1.191302e-02 
#>            V6           V51           V44           V49           V20 
#>  9.238734e-03  9.089376e-03  8.884059e-03  6.593735e-03  6.284469e-03 
#>           V27           V46            V1           V28           V13 
#>  6.247464e-03  6.203781e-03  6.120697e-03  5.768867e-03  4.856717e-03 
#>           V45           V55           V37           V52           V25 
#>  4.666556e-03  3.849280e-03  3.538879e-03  3.120062e-03  3.014163e-03 
#>           V54            V7           V60           V59            V8 
#>  2.965091e-03  2.688389e-03  2.684984e-03  2.665171e-03  2.656585e-03 
#>           V17           V47           V22           V58           V34 
#>  2.581901e-03  2.544615e-03  2.459070e-03  2.429643e-03  2.238632e-03 
#>            V5           V57           V43           V50           V36 
#>  2.197595e-03  2.091544e-03  2.004506e-03  2.002519e-03  1.986023e-03 
#>            V2           V35           V19           V29           V56 
#>  1.963918e-03  1.681790e-03  1.632653e-03  1.400175e-03  1.184194e-03 
#>           V40           V31           V38           V23           V15 
#>  1.136884e-03  1.114435e-03  9.650067e-04  9.337924e-04  8.888889e-04 
#>           V42           V24            V3           V21           V53 
#>  7.448103e-04  5.442177e-04  3.773585e-04  3.704025e-04  3.019752e-04 
#>           V39           V14           V26           V16           V33 
#>  2.696217e-04  2.221513e-04  1.303098e-04  3.213126e-05  0.000000e+00 
#>           V18           V32            V4           V41           V30 
#> -3.305085e-05 -4.669031e-05 -5.718499e-04 -8.829037e-04 -2.147017e-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
#>        1     R        R 0.4560000 0.5440000
#>        5     R        R 0.4341667 0.5658333
#>       11     R        R 0.1457857 0.8542143
#>      ---   ---      ---       ---       ---
#>      204     M        M 0.8791667 0.1208333
#>      206     M        M 0.7144762 0.2855238
#>      208     M        M 0.5906190 0.4093810

# Score the predictions
pred$score()
#> classif.ce 
#>  0.2173913