
Random Forest Variable Importance
rf_importance.RdReturns aggregated split-based variable importance for a fitted
mars_rf
object.
Usage
rf_importance(object, scale = NULL, ...)
# S3 method for class 'mars_rf'
rf_importance(
object,
scale = NULL,
type = c("split", "permutation"),
validation = NULL,
folds = 5L,
repeats = 5L,
seed = 1L,
...
)Arguments
- object
A fitted
"mars_rf"object.- scale
Logical or NULL. For split importance, NULL defaults to TRUE and returns relative importance summing to one when any reduction is positive. Permutation importance defaults to FALSE and cannot be normalized this way.
- ...
Additional arguments are rejected.
- type
Split-loss importance or held-out grouped permutation importance.
- validation
Optional
mars_rf_validate()result with permutations, computed for this fitted workflow. Reuses its importance without refitting.- folds, repeats, seed
Controls for grouped validation when validation is NULL.
Details
Split importance omits terminal linear coefficients and can favor variables with many candidate splits. Permutation importance measures changes in held-out squared error, includes terminal prediction contributions, and is not a significance test. Correlated moderators may share importance.
Examples
# \donttest{
rf_fit <- mars_rf_univariate(
data = teacher_expectancy,
formula = yi ~ year + weeks,
studyID = "study",
variance = "vi",
num_trees = 25,
seed = 123
)
rf_importance(rf_fit)
#> predictor importance
#> 2 weeks 0.8733717
#> 1 year 0.1266283
# }