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


LearnerClassifBlockForest$new()

Creates a new instance of this R6 class.


LearnerClassifBlockForest$importance()

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

Usage

LearnerClassifBlockForest$importance()

Returns

Named numeric().


LearnerClassifBlockForest$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()
#>           V48           V49            V9            V4           V11 
#>  2.860117e-02  1.715424e-02  1.711521e-02  1.246304e-02  1.207739e-02 
#>           V10           V16           V45           V21           V28 
#>  1.060622e-02  8.462472e-03  6.877366e-03  6.818455e-03  5.268522e-03 
#>           V46           V13           V12           V15           V47 
#>  5.082980e-03  4.961210e-03  4.494855e-03  4.140274e-03  3.692158e-03 
#>           V34           V32           V35           V20           V18 
#>  2.685910e-03  2.585586e-03  2.523282e-03  2.467646e-03  2.417157e-03 
#>           V19           V58            V7           V36           V38 
#>  2.176679e-03  2.018382e-03  1.987307e-03  1.712481e-03  1.699214e-03 
#>           V59           V53            V6           V51            V1 
#>  1.582714e-03  1.541636e-03  1.486681e-03  1.415568e-03  1.261659e-03 
#>           V29           V39            V3           V17           V25 
#>  1.250528e-03  1.100877e-03  9.250063e-04  9.153567e-04  9.131839e-04 
#>           V55           V52           V24           V43           V22 
#>  8.142818e-04  7.814865e-04  7.644784e-04  7.407407e-04  6.168675e-04 
#>           V23           V26           V54           V42           V41 
#>  6.144064e-04  6.101473e-04  4.602865e-04  4.165739e-04  3.856932e-04 
#>           V27           V50           V31           V33           V56 
#>  3.639780e-04  9.124023e-05  7.004001e-05 -2.204106e-04 -2.707254e-04 
#>           V37           V60            V5           V40           V57 
#> -1.167991e-03 -1.195691e-03 -1.332234e-03 -1.424661e-03 -1.514830e-03 
#>           V14           V44            V8            V2           V30 
#> -1.534684e-03 -1.987149e-03 -2.030612e-03 -2.092144e-03 -3.485740e-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
#>        2     R        M 0.5251746 0.47482540
#>        3     R        M 0.6130714 0.38692857
#>       11     R        R 0.0700000 0.93000000
#>      ---   ---      ---       ---        ---
#>      201     M        M 0.9051429 0.09485714
#>      206     M        M 0.7083810 0.29161905
#>      208     M        R 0.4196190 0.58038095

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