Skip to contents

Random planted forest: a directly interpretable tree ensemble. Calls randomPlantedForest::rpf() from package 'randomPlantedForest'.

Installation

Package 'randomPlantedForest' is not on CRAN and has to be installed from GitHub via remotes::install_github("PlantedML/randomPlantedForest").

Saving a Learner

The fitted forest lives in C++ memory and does not survive R serialization. Call $marshal() before writing a trained learner to disk, and $unmarshal() after loading it again. By default, marshaling does not store the training data, so a restored model cannot be purified afterwards. Set purify = TRUE at training time if purification is needed, or include the training data in the marshaled model via the marshal_include_data parameter or $marshal(include_data = TRUE).

Custom mlr3 parameters

  • max_interaction:

    • This hyperparameter can alternatively be set via max_interaction_ratio as max_interaction = max(ceiling(max_interaction_ratio * n_features), 1). The parameter max_interaction_limit can optionally be set as an upper bound, such that max_interaction_ratio * min(n_features, max_interaction_limit) is used instead. This is analogous to mtry.ratio in classif.ranger, with max_interaction_limit as an additional constraint. The parameter max_interaction_limit is initialized to Inf.

  • marshal_include_data:

    • Whether to store the training data when marshaling the model, which is required to call randomPlantedForest::purify() on a restored model. Defaults to FALSE to keep marshaled models small. Can be overridden for a single call via $marshal(include_data = TRUE).

Dictionary

This Learner can be instantiated via lrn():

lrn("classif.rpf")

Meta Information

  • Task type: “classif”

  • Predict Types: “response”, “prob”

  • Feature Types: “logical”, “integer”, “numeric”, “factor”, “ordered”

  • Required Packages: mlr3, mlr3extralearners, randomPlantedForest

Parameters

IdTypeDefaultLevelsRange
max_interactioninteger2\([0, \infty)\)
max_interaction_rationumeric-\([0, 1]\)
max_interaction_limitinteger-\([1, \infty)\)
ntreesinteger50\([1, \infty)\)
splitsinteger30\([1, \infty)\)
split_structurecharacterleavesleaves, hist, cur_trees_1, cur_trees_2, res_trees-
split_tryinteger10\([1, \infty)\)
t_trynumeric0.4\([0, 1]\)
max_candidatesinteger50\([1, \infty)\)
split_decay_ratenumeric0.1\([0, \infty)\)
delete_leaveslogicalTRUETRUE, FALSE-
losscharacterexponentialL1, L2, logit, exponential-
deltanumeric0.001\([0, 1]\)
epsilonnumeric0.1\([0, 1]\)
purifylogicalFALSETRUE, FALSE-
nthreadsinteger1\([1, \infty)\)
export_forestlogicalFALSETRUE, FALSE-
deterministiclogicalFALSETRUE, FALSE-
marshal_include_datalogicalFALSETRUE, FALSE-

References

Hiabu, Munir, Mammen, Enno, Meyer, T. J (2023). “Random Planted Forest: a directly interpretable tree ensemble.” arXiv preprint arXiv:2012.14563. doi:10.48550/ARXIV.2012.14563 .

See also

Author

jemus42

Super classes

mlr3::Learner -> mlr3::LearnerClassif -> LearnerClassifRandomPlantedForest

Active bindings

marshaled

(logical(1))
Whether the learner has been marshaled.

Methods

Inherited methods


LearnerClassifRandomPlantedForest$new()

Creates a new instance of this R6 class.


LearnerClassifRandomPlantedForest$marshal()

Marshal the learner's model.

Usage

LearnerClassifRandomPlantedForest$marshal(...)

Arguments

...

(any)
Additional arguments passed to mlr3::marshal_model().


LearnerClassifRandomPlantedForest$unmarshal()

Unmarshal the learner's model.

Usage

LearnerClassifRandomPlantedForest$unmarshal(...)

Arguments

...

(any)
Additional arguments passed to mlr3::unmarshal_model().


LearnerClassifRandomPlantedForest$clone()

The objects of this class are cloneable with this method.

Usage

LearnerClassifRandomPlantedForest$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

# Define the Learner
learner = lrn("classif.rpf")
print(learner)
#> 
#> ── <LearnerClassifRandomPlantedForest> (classif.rpf): Random Planted Forest ────
#> • Model: -
#> • Parameters: max_interaction_limit=Inf
#> • Packages: mlr3, mlr3extralearners, and randomPlantedForest
#> • Predict Types: [response] and prob
#> • Feature Types: logical, integer, numeric, factor, and ordered
#> • Encapsulation: none (fallback: -)
#> • Properties: marshal, multiclass, and twoclass
#> • Other settings: use_weights = 'error', predict_raw = 'FALSE'

# Define a Task
task = tsk("sonar")

# Create train and test set
ids = partition(task)

# Train the learner on the training ids
learner$train(task, row_ids = ids$train)

print(learner$model)
#> ── Classification Random Planted Forest ────────────────────────────────────────
#> Predictors: `V1`, `V10`, `V11`, …, `V8`, and `V9`
#> 50 tree families with 30 splits each on 60 predictors, interactions to degree
#> 2.
#> ℹ Forest is not purified.
#> 
#> ── Tree growing 
#>    split_structure: leaves
#>          split_try: 10
#>              t_try: 0.4
#>     max_candidates: 50
#>   split_decay_rate: 0.1
#>      delete_leaves: TRUE
#> 
#> ── Loss 
#>      loss: exponential
#>     delta: 0.001
#>   epsilon: 0.1
#> 
#> ℹ Fit using 1 thread, also the default for `predict()` and `purify()`.


# Make predictions for the test rows
predictions = learner$predict(task, row_ids = ids$test)

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