.fit.rf {tidyfit} | R Documentation |
Random Forest regression or classification for tidyfit
Description
Fits a random forest on a 'tidyFit' R6
class. The function can be used with regress
and classify
.
Usage
## S3 method for class 'rf'
.fit(self, data = NULL)
Arguments
self |
a 'tidyFit' R6 class. |
data |
a data frame, data frame extension (e.g. a tibble), or a lazy data frame (e.g. from dbplyr or dtplyr). |
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()
.
Value
A fitted 'tidyFit' class model.
Author(s)
Johann Pfitzinger
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
# Within 'regress' function
fit <- regress(data, Return ~ ., m("rf"))
explain(fit)