Skip to contents

Wraps randomForest::randomForest. Auto-detects task from y (factor / integer-like -> classification, otherwise regression).

Usage

morie_random_forest_ensemble(
  x,
  y,
  n_estimators = 100L,
  max_depth = NULL,
  task = "auto",
  seed = 0L,
  deterministic_seed = NULL
)

Arguments

x

Numeric predictor matrix.

y

Response.

n_estimators

Number of trees.

max_depth

Max tree depth (NULL -> unrestricted).

task

"auto", "classification", or "regression".

seed

RNG seed.

deterministic_seed

Integer or NULL. If supplied, the RNG state is derived from the SHA-keyed morie_det_rng() so Py<->R streams agree on the canonical fixture. When NULL (default), behaviour is unchanged: seed drives set.seed() directly.

Value

Named list: estimate, train_score, oob_score, feature_importances, n_estimators, task, n, method.

Examples

morie_random_forest_ensemble(x = rnorm(50), y = rnorm(50))
#> $estimate
#> [1] 0.6799557
#> 
#> $train_score
#> [1] 0.6799557
#> 
#> $oob_score
#> [1] -0.2972133
#> 
#> $feature_importances
#> [1] 0.5207263 0.4792737
#> 
#> $n_estimators
#> [1] 100
#> 
#> $task
#> [1] "regression"
#> 
#> $n
#> [1] 50
#> 
#> $method
#> [1] "Random Forest (regression)"
#>