Extract the individual-algorithm extrinsic importance from a ranger object, along with the importance rank.

extract_importance_ranger(fit = NULL, feature_names = "", coef = 0)

Arguments

fit

the ranger object.

feature_names

the feature names

coef

the Super Learner coefficient associated with the learner.

Value

a tibble, with columns algorithm (the fitted algorithm), feature (the feature), importance (the algorithm-specific extrinsic importance of the feature), rank (the feature importance rank, with 1 indicating the most important feature), and weight

(the algorithm's weight in the Super Learner)

Examples

data("biomarkers")
# subset to complete cases for illustration
cc <- complete.cases(biomarkers)
dat_cc <- biomarkers[cc, ]
# use only the mucinous outcome, not the high-malignancy outcome
y <- dat_cc$mucinous
x <- dat_cc[, !(names(dat_cc) %in% c("mucinous", "high_malignancy"))]
feature_nms <- names(x)
# get the fit
set.seed(20231129)
fit <- ranger::ranger(y ~ ., data = data.frame(y = y, x), importance = "impurity")
# extract importance
importance <- extract_importance_ranger(fit = fit, feature_names = feature_nms)
importance
#> # A tibble: 22 × 5
#>    algorithm feature                 importance  rank weight
#>    <chr>     <chr>                        <dbl> <dbl>  <dbl>
#>  1 rf        lab3_muc3ac_score             4.07     1      0
#>  2 rf        lab6_ab_score                 3.71     2      0
#>  3 rf        lab1_telomerase_score         3.69     3      0
#>  4 rf        lab1_actb                     3.58     4      0
#>  5 rf        lab4_glucose_score            3.48     5      0
#>  6 rf        cea                           3.36     6      0
#>  7 rf        lab2_fluorescence_score       3.18     7      0
#>  8 rf        lab1_molecules_score          3.10     8      0
#>  9 rf        lab3_muc5ac_score             2.99     9      0
#> 10 rf        lab4_areg_score               2.98    10      0
#> # ℹ 12 more rows