powered by
Fits a conditional random forest using partykit::cforest() and returns the forest object along with variable importance scores.
partykit::cforest()
train_rf( data_train, target_lab, task = c("classification", "regression"), ntree = 500L, mtry = NULL, control = NULL )
A list with elements:
The fitted cforest object.
cforest
A named numeric vector of relative variable importance (scaled to sum to 1 and rounded to two decimals).
Integer. Number of trees in the forest.
Data frame. Training data.
Character. Name of the target column.
Character. "classification" or "regression".
"classification"
"regression"
Integer. Number of trees (default 500).
Integer or NULL. Number of variables randomly sampled at each split. If NULL, uses the cforest default.
A ctree_control object or NULL.
ctree_control
# \donttest{ data(train_covid) rf_res <- train_rf(train_covid, target_lab = "Outcome", ntree = 50) rf_res$var_imp # }
Run the code above in your browser using DataLab