R/extract_importance_glm.R
extract_importance_glm.Rd
Extract the individual-algorithm extrinsic importance from a glm object, along with the importance rank.
extract_importance_glm(fit = NULL, feature_names = "", coef = 0)
the glm
object.
the feature names
the Super Learner coefficient associated with the learner.
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)
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
fit <- stats::glm(y ~ ., family = "binomial", data = data.frame(y = y, x))
# extract importance
importance <- extract_importance_glm(fit = fit, feature_names = feature_nms)
importance
#> # A tibble: 22 × 5
#> algorithm feature importance rank weight
#> <chr> <chr> <dbl> <int> <dbl>
#> 1 glm lab2_fluorescence_mucinous_call 2.35 1 0
#> 2 glm lab2_fluorescence_score 1.94 2 0
#> 3 glm lab1_telomerase_neoplasia_call 1.37 3 0
#> 4 glm lab4_glucose_score 1.29 4 0
#> 5 glm lab1_actb 1.25 5 0
#> 6 glm institution 1.19 6 0
#> 7 glm lab3_muc3ac_score 0.990 7 0
#> 8 glm lab1_telomerase_score 0.949 8 0
#> 9 glm lab5_neoplasia_v1_call 0.889 9 0
#> 10 glm lab4_areg_score 0.846 10 0
#> # ℹ 12 more rows