From 8303c6a2676f60e749149814db52af84be0be4b5 Mon Sep 17 00:00:00 2001 From: Marvin Wright Date: Tue, 19 Mar 2024 07:33:53 +0100 Subject: [PATCH] calculate shap values only for the selected features --- R/glex.R | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/R/glex.R b/R/glex.R index f97a32f..7f69b57 100644 --- a/R/glex.R +++ b/R/glex.R @@ -380,7 +380,10 @@ calc_components <- function(trees, x, max_interaction, features, probFunction = interactions <- sweep(m_all[, -1, drop = FALSE], MARGIN = 2, d[-1], "/") # SHAP values are the sum of the m's * 1/d - shap <- vapply(colnames(x), function(col) { + if (is.null(features)) { + features <- colnames(x) + } + shap <- vapply(features, function(col) { idx <- find_term_matches(col, colnames(interactions)) if (length(idx) == 0) {