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()
#>           V12           V11           V13            V9           V48 
#>  0.0165798763  0.0145834667  0.0136389033  0.0103542355  0.0102244468 
#>           V28           V51           V45            V5            V4 
#>  0.0072737290  0.0071770773  0.0071648646  0.0052666428  0.0051773974 
#>           V36           V49           V35           V31           V14 
#>  0.0049501851  0.0048750694  0.0048298759  0.0042772671  0.0038592828 
#>           V37            V7           V20           V47           V50 
#>  0.0035885276  0.0034268065  0.0033711537  0.0031559650  0.0029622387 
#>           V27           V18           V42            V2           V25 
#>  0.0025884258  0.0024487351  0.0024216348  0.0023733580  0.0023156380 
#>           V52           V60           V40            V3            V8 
#>  0.0021203552  0.0019386325  0.0019335652  0.0018520379  0.0016353957 
#>           V23           V32           V30            V6           V16 
#>  0.0016107354  0.0015630495  0.0015093770  0.0014450957  0.0014433589 
#>           V24           V15           V43           V33           V19 
#>  0.0012452174  0.0010151934  0.0010132742  0.0010000000  0.0007883836 
#>           V54           V17           V46           V53           V58 
#>  0.0006612796  0.0005080961  0.0002436934  0.0001258180 -0.0001397992 
#>           V57           V44           V22           V10            V1 
#> -0.0001487316 -0.0002689251 -0.0002706769 -0.0006165785 -0.0006340648 
#>           V38           V59           V41           V26           V34 
#> -0.0006888659 -0.0007094141 -0.0007683450 -0.0008079945 -0.0010557953 
#>           V55           V21           V56           V39           V29 
#> -0.0012313335 -0.0014531833 -0.0020284153 -0.0024475464 -0.0033445567 

# 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        R 0.4498016 0.5501984
#>        4     R        R 0.3690317 0.6309683
#>        5     R        R 0.4965317 0.5034683
#>      ---   ---      ---       ---       ---
#>      203     M        M 0.7569286 0.2430714
#>      204     M        M 0.8146667 0.1853333
#>      208     M        M 0.6073333 0.3926667

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