ModelOriented / iBreakDown

Break Down with interactions for local explanations (SHAP, BreakDown, iBreakDown)
https://ModelOriented.github.io/iBreakDown/
GNU General Public License v3.0
81 stars 15 forks source link

[shap] NA in variable_value column #76

Closed hbaniecki closed 4 years ago

hbaniecki commented 4 years ago
library("xgboost")
library("DALEX")

model_matrix <- model.matrix(status == "fired" ~ . -1, HR)
data <- xgb.DMatrix(model_matrix, label = HR$status == "fired")

params <- list(max_depth = 2, eta = 1, silent = 1, nthread = 2,
               objective = "binary:logistic", eval_metric = "auc")

model_HR <- xgb.train(params, data, nrounds = 50)

explainer_HR <- explain(model_HR,
                        data = model_matrix,
                        y = HR$status == "fired",
                        verbose = FALSE)

library(iBreakDown)
# this works
break_down(explainer_HR, model_matrix[1,,drop=FALSE])

# this has NA in variable_value (and rownames)
shap(explainer_HR, model_matrix[1,,drop=FALSE])