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()
#>           V49            V9           V48           V51           V11 
#>  1.709475e-02  1.584460e-02  1.574908e-02  1.404239e-02  9.684483e-03 
#>            V5           V12           V16           V58           V13 
#>  4.910647e-03  4.710261e-03  4.519937e-03  4.148098e-03  4.093539e-03 
#>           V10           V36           V17           V52           V54 
#>  3.837362e-03  3.591954e-03  2.545291e-03  2.518686e-03  2.390908e-03 
#>            V7            V6           V25           V19            V8 
#>  2.242279e-03  2.209344e-03  2.206349e-03  2.142857e-03  2.095327e-03 
#>            V3            V1           V33           V39           V35 
#>  1.901974e-03  1.714242e-03  1.615045e-03  1.431165e-03  1.379560e-03 
#>           V44           V46           V43           V53            V4 
#>  1.283019e-03  1.269976e-03  1.214810e-03  1.139802e-03  8.851609e-04 
#>           V22           V42            V2           V28           V29 
#>  8.764843e-04  8.578073e-04  8.406593e-04  8.281815e-04  7.576358e-04 
#>           V18           V20           V24           V14           V40 
#>  6.859683e-04  5.349308e-04  4.081633e-04  3.826923e-04  3.733333e-04 
#>           V37           V21           V41           V38           V23 
#>  8.422646e-05  1.045423e-05 -2.069231e-04 -2.402050e-04 -2.586924e-04 
#>           V15           V56           V32           V45           V27 
#> -2.934354e-04 -3.065881e-04 -3.846154e-04 -6.227292e-04 -7.354926e-04 
#>           V31           V26           V57           V47           V34 
#> -7.843137e-04 -9.105621e-04 -1.038715e-03 -1.124433e-03 -1.538462e-03 
#>           V59           V30           V60           V50           V55 
#> -1.739074e-03 -1.892886e-03 -2.065104e-03 -2.186201e-03 -2.342850e-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
#>        3     R        M 0.5112857 0.4887143
#>        5     R        M 0.5735952 0.4264048
#>       15     R        R 0.3326746 0.6673254
#>      ---   ---      ---       ---       ---
#>      202     M        M 0.6684762 0.3315238
#>      207     M        M 0.5566190 0.4433810
#>      208     M        R 0.4398730 0.5601270
# Score the predictions
pred$score()
#> classif.ce 
#>  0.2608696