Skip to contents

Native random forest (ESL Algorithm 15.1). 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

set.seed(1)
morie_random_forest_ensemble(x = rnorm(50), y = rnorm(50))
#> $estimate
#> [1] 0.308614
#> 
#> $train_score
#> [1] 0.308614
#> 
#> $oob_score
#> [1] -0.1776206
#> 
#> $feature_importances
#> [1] 0.4721262 0.5278738
#> 
#> $n_estimators
#> [1] 100
#> 
#> $task
#> [1] "regression"
#> 
#> $n
#> [1] 50
#> 
#> $method
#> [1] "Random Forest (regression)"
#>