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           V12           V48           V11           V49 
#>  2.917662e-02  2.219828e-02  1.638956e-02  1.600801e-02  8.711407e-03 
#>           V51           V47           V17           V22           V13 
#>  8.361882e-03  7.678265e-03  6.180360e-03  5.686361e-03  5.316656e-03 
#>           V52           V27           V28           V54           V15 
#>  4.467209e-03  4.199809e-03  4.113874e-03  3.986618e-03  3.871675e-03 
#>           V10           V16            V4           V43            V6 
#>  3.498572e-03  3.453766e-03  3.141137e-03  3.102352e-03  2.990641e-03 
#>           V23           V35            V1           V21           V19 
#>  2.934904e-03  2.762931e-03  2.725908e-03  2.681251e-03  2.640633e-03 
#>           V40           V37           V42           V44           V59 
#>  2.595200e-03  1.954516e-03  1.841476e-03  1.806520e-03  1.565542e-03 
#>           V46           V31           V36            V5            V3 
#>  1.486271e-03  1.453809e-03  1.345795e-03  1.266201e-03  1.025677e-03 
#>           V20            V7           V14           V30           V25 
#>  9.196745e-04  8.210060e-04  6.137522e-04  5.345138e-04  4.998363e-04 
#>           V55           V29           V34           V38           V24 
#>  3.656343e-04  2.285580e-04  2.003030e-04  1.980392e-04  1.864858e-04 
#>           V33           V53            V2           V58           V26 
#>  7.819512e-05  4.772633e-05  1.010101e-05 -5.695671e-05 -1.214700e-04 
#>            V8           V50           V41           V39           V45 
#> -1.399251e-04 -2.295283e-04 -4.166667e-04 -4.299640e-04 -4.654824e-04 
#>           V56           V32           V57           V18           V60 
#> -7.917436e-04 -8.091881e-04 -1.109983e-03 -1.345855e-03 -2.526247e-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        M 0.5451667 0.4548333
#>        4     R        R 0.3412698 0.6587302
#>        5     R        R 0.4388492 0.5611508
#>      ---   ---      ---       ---       ---
#>      203     M        M 0.7935000 0.2065000
#>      204     M        M 0.7921825 0.2078175
#>      206     M        M 0.6810635 0.3189365
# Score the predictions
pred$score()
#> classif.ce 
#>   0.173913