Learn R Programming

flevr (version 0.0.4)

extract_importance_SL_learner: Extract the learner-specific importance from a fitted SuperLearner algorithm

Description

Extract the individual-algorithm extrinsic importance from one fitted algorithm within the Super Learner, along with the importance rank.

Usage

extract_importance_SL_learner(fit = NULL, coef = 0, feature_names = "", ...)

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)

Arguments

fit

the specific learner (e.g., from the Super Learner's fitLibrary list).

coef

the Super Learner coefficient associated with the learner.

feature_names

the feature names

...

other arguments to pass to algorithm-specific importance extractors.

Examples

Run this code
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 (using a simple library and 2 folds for illustration only)
library("SuperLearner")
set.seed(20231129)
fit <- SuperLearner::SuperLearner(Y = y, X = x, SL.library = c("SL.glm", "SL.mean"), 
                                  cvControl = list(V = 2))
# extract importance
importance <- extract_importance_SL_learner(fit = fit$fitLibrary[[1]]$object, 
                                            feature_names = feature_nms, coef = fit$coef[1])
importance

Run the code above in your browser using DataLab