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()
#>           V10           V11           V12           V46           V49 
#>  3.070406e-02  1.971722e-02  1.551891e-02  1.133821e-02  1.114408e-02 
#>            V4            V9           V48           V45           V21 
#>  1.108029e-02  1.001576e-02  7.342178e-03  7.303218e-03  6.217830e-03 
#>           V37           V44           V22           V27           V16 
#>  5.575329e-03  5.029238e-03  4.955754e-03  4.326681e-03  3.891738e-03 
#>           V20           V55            V7            V6           V38 
#>  3.229402e-03  3.142526e-03  3.139035e-03  3.007197e-03  2.538548e-03 
#>           V43           V36           V52           V32           V23 
#>  2.132616e-03  1.975177e-03  1.951433e-03  1.871748e-03  1.850764e-03 
#>           V19           V17           V24           V15            V1 
#>  1.828867e-03  1.733393e-03  1.559450e-03  1.550847e-03  1.442379e-03 
#>            V2            V3           V59           V50            V5 
#>  1.355977e-03  1.277740e-03  1.220106e-03  1.170438e-03  1.160839e-03 
#>           V18           V47           V13           V42           V41 
#>  1.144821e-03  1.136429e-03  1.136058e-03  8.672765e-04  8.433162e-04 
#>           V30           V28           V40           V54           V25 
#>  8.217414e-04  7.864978e-04  7.742203e-04  7.212970e-04  6.889414e-04 
#>           V56           V26           V39           V35           V14 
#>  3.794726e-04  2.890741e-04  2.680645e-04  6.820124e-05 -1.042119e-04 
#>           V31           V60           V51           V33           V58 
#> -3.120553e-04 -3.399748e-04 -3.857787e-04 -4.100931e-04 -4.449140e-04 
#>           V34           V57           V53            V8           V29 
#> -8.132307e-04 -8.690343e-04 -9.092628e-04 -1.019024e-03 -1.691937e-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
#>        4     R        R 0.4090556 0.5909444
#>        9     R        R 0.3623333 0.6376667
#>       17     R        M 0.5215556 0.4784444
#>      ---   ---      ---       ---       ---
#>      202     M        M 0.9450000 0.0550000
#>      203     M        M 0.7415714 0.2584286
#>      205     M        M 0.5674444 0.4325556

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