Details
Hyperparameters:
ntree (number of trees)
mtry (number of variables randomly sampled at each split)
Important method arguments (passed to m
)
The function provides a wrapper for randomForest::randomForest
. See ?randomForest
for more details.
Implementation
The random forest is always fit with importance = TRUE
. The feature importance values are extracted using coef()
.
References
Liaw, A. and Wiener, M. (2002). Classification and Regression by randomForest. R News 2(3), 18–22.
See also
.fit.svm
, .fit.boost
and m
methods
Examples
# Load data
data <- tidyfit::Factor_Industry_Returns
data <- dplyr::filter(data, Industry == "HiTec")
data <- dplyr::select(data, -Date, -Industry)
# Stand-alone function
fit <- m("rf", Return ~ ., data)
fit
#> # A tibble: 1 × 5
#> estimator_fct `size (MB)` grid_id model_object settings
#> <chr> <dbl> <chr> <list> <list>
#> 1 randomForest::randomForest 8.40 #0010000 <tidyFit> <tibble>
# Within 'regress' function
fit <- regress(data, Return ~ ., m("rf"))
explain(fit)
#> Warning: using explain package 'randomForest'
#> # A tibble: 7 × 5
#> # Groups: model [1]
#> model term importance IncNodePurity importanceSD
#> <chr> <chr> <dbl> <dbl> <dbl>
#> 1 rf (Intercept) 0 0 0
#> 2 rf Mkt-RF 36.9 13958. 0.442
#> 3 rf SMB 1.22 2154. 0.104
#> 4 rf HML 3.97 3239. 0.175
#> 5 rf RMW 2.43 2675. 0.144
#> 6 rf CMA 6.11 4413. 0.272
#> 7 rf RF 0.732 1238. 0.0848