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           V51           V11           V49           V48 
#>  1.895817e-02  1.533218e-02  1.526693e-02  1.469123e-02  1.418623e-02 
#>            V9           V28           V13           V37           V45 
#>  1.106882e-02  1.014492e-02  8.466230e-03  6.479529e-03  6.161251e-03 
#>            V1           V15           V52           V23           V26 
#>  6.134813e-03  5.900057e-03  5.483168e-03  5.281203e-03  5.061789e-03 
#>            V4           V18           V22           V31           V21 
#>  4.840731e-03  4.508136e-03  4.200747e-03  4.094931e-03  3.916157e-03 
#>            V5           V43            V2           V40           V59 
#>  3.856421e-03  3.732280e-03  3.558813e-03  3.417858e-03  3.217859e-03 
#>           V60           V19           V32           V34           V36 
#>  3.087898e-03  2.717835e-03  2.312647e-03  2.293456e-03  2.271587e-03 
#>           V55           V38           V30           V27           V25 
#>  2.136273e-03  2.053968e-03  1.900975e-03  1.588694e-03  1.234133e-03 
#>           V33           V42            V6           V44           V58 
#>  1.182604e-03  1.154646e-03  1.138061e-03  1.075908e-03  1.063199e-03 
#>           V24           V53           V46           V17           V10 
#>  9.047619e-04  7.105620e-04  6.739338e-04  1.685664e-04  1.367960e-04 
#>           V39           V20           V16           V54           V47 
#>  1.273585e-04  6.696429e-05 -6.005906e-05 -2.448783e-04 -3.571429e-04 
#>           V50           V56            V3            V7           V41 
#> -3.763476e-04 -5.299546e-04 -6.519334e-04 -6.721192e-04 -1.142405e-03 
#>           V35           V57           V29           V14            V8 
#> -1.476671e-03 -1.727105e-03 -1.791625e-03 -2.111687e-03 -2.291199e-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
#>        5     R        M 0.5301349 0.4698651
#>       10     R        R 0.1822540 0.8177460
#>       13     R        R 0.3823968 0.6176032
#>      ---   ---      ---       ---       ---
#>      201     M        M 0.8624444 0.1375556
#>      204     M        M 0.8826190 0.1173810
#>      205     M        M 0.7976349 0.2023651

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