bgreenwell / fastshap

Fast approximate Shapley values in R
https://bgreenwell.github.io/fastshap/
115 stars 18 forks source link

fastshap: Error in dimnames(x) <- dn : length of 'dimnames' [2] not equal to array extent #77

Open bellalauys opened 3 months ago

bellalauys commented 3 months ago

Hi @bgreenwell ,

I have tried to run fastshap on my dataset with more than 120 features and 490,000 rows. However, it keeps having such error pop up " Error in dimnames(x) <- dn : length of 'dimnames' [2] not equal to array extent"

(rf <- ranger(Y ~ ., data = Z, probability = TRUE, write.forest = TRUE))

pfun <- function(object, newdata) { # prediction wrapper unname(predict(object, data = newdata, type = "response")$predictions[, 1]) }

install.packages("doParallel") library(doParallel)

registerDoParallel(cores = 20) # use forking with 12 cores

shap <- fastshap::explain(rf, X = X1, pred_wrapper = pfun, newdata = random_row, parallel = TRUE)

Does anyone know how to solve this issue?

bgreenwell commented 3 months ago

Hi @bellalauys, thanks for posting your issue. Can you post a reproducible example to run on my end?