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()
#>           V11           V12           V48            V9           V49 
#>  1.902439e-02  1.872060e-02  1.135564e-02  9.699545e-03  8.896895e-03 
#>           V45           V47           V16           V37           V52 
#>  7.021457e-03  6.382942e-03  6.042717e-03  5.590296e-03  5.509129e-03 
#>            V6           V54           V44           V28           V10 
#>  5.491675e-03  4.847287e-03  4.354379e-03  4.187705e-03  4.166797e-03 
#>           V23           V18            V4            V5           V34 
#>  3.486976e-03  2.898275e-03  2.857614e-03  2.839004e-03  2.691946e-03 
#>           V38           V20           V17           V46            V1 
#>  2.655705e-03  2.474963e-03  2.354400e-03  1.873046e-03  1.740923e-03 
#>           V21           V43            V7           V36           V59 
#>  1.677621e-03  1.528555e-03  1.420901e-03  1.327894e-03  1.245119e-03 
#>           V19           V31           V39           V41           V13 
#>  1.155545e-03  1.005966e-03  7.769655e-04  6.361452e-04  6.057105e-04 
#>           V24           V57           V40           V25           V26 
#>  5.947352e-04  4.604279e-04  4.193062e-04  3.703704e-04  2.931833e-04 
#>           V42           V15           V55           V60           V29 
#>  2.381172e-04  1.972874e-04  5.684760e-05  9.052606e-06 -5.491384e-05 
#>           V27            V2           V14           V22           V30 
#> -6.111942e-05 -1.767650e-04 -3.320856e-04 -6.918003e-04 -8.608716e-04 
#>           V50           V51           V58            V8           V53 
#> -1.140758e-03 -1.382791e-03 -1.836026e-03 -1.995271e-03 -2.017457e-03 
#>           V33            V3           V35           V32           V56 
#> -2.213487e-03 -2.323219e-03 -2.781134e-03 -3.062166e-03 -3.185946e-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
#>       10     R        R 0.31221429 0.6877857
#>       11     R        R 0.08414286 0.9158571
#>       22     R        M 0.68777778 0.3122222
#>      ---   ---      ---        ---       ---
#>      201     M        M 0.88480952 0.1151905
#>      207     M        M 0.73800000 0.2620000
#>      208     M        R 0.49588889 0.5041111

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