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            V9           V10           V37           V51 
#>  2.231187e-02  2.184228e-02  1.903576e-02  1.036056e-02  9.922738e-03 
#>           V11           V28           V36           V31           V55 
#>  9.065250e-03  7.370031e-03  6.514503e-03  6.083798e-03  5.681341e-03 
#>           V47           V17           V49            V1           V44 
#>  5.408897e-03  5.221783e-03  4.680726e-03  4.217014e-03  4.085495e-03 
#>            V5           V16           V52           V27           V59 
#>  3.995950e-03  3.934381e-03  3.858244e-03  3.857558e-03  3.281417e-03 
#>           V29           V15           V21           V48           V20 
#>  3.237118e-03  2.748620e-03  2.723639e-03  2.569137e-03  2.304089e-03 
#>            V4           V13           V54           V46           V45 
#>  2.296818e-03  2.034569e-03  1.990049e-03  1.960152e-03  1.640762e-03 
#>           V33           V53            V8           V40           V23 
#>  1.614609e-03  1.574882e-03  1.220689e-03  1.026560e-03  9.633129e-04 
#>           V56           V18           V58            V2           V19 
#>  9.617087e-04  9.135377e-04  8.965089e-04  7.562229e-04  7.450854e-04 
#>           V34           V60           V50           V39           V22 
#>  7.077164e-04  6.677291e-04  6.025054e-04  3.843672e-04  3.464766e-04 
#>           V14            V3           V32           V25           V35 
#>  3.393788e-04  2.636848e-04  2.322671e-04  0.000000e+00 -8.970686e-05 
#>           V30           V38           V57           V24            V6 
#> -1.555817e-04 -3.175789e-04 -3.471106e-04 -6.697551e-04 -7.230803e-04 
#>           V42           V26           V41            V7           V43 
#> -8.076561e-04 -9.019943e-04 -9.382758e-04 -1.018827e-03 -2.333345e-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.5173333 0.4826667
#>        2     R        M 0.5912063 0.4087937
#>        5     R        M 0.6161349 0.3838651
#>      ---   ---      ---       ---       ---
#>      205     M        M 0.5964048 0.4035952
#>      206     M        M 0.6983333 0.3016667
#>      207     M        M 0.6661270 0.3338730

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