ModelOriented / DALEX

moDel Agnostic Language for Exploration and eXplanation
https://dalex.drwhy.ai
GNU General Public License v3.0
1.38k stars 166 forks source link

predict_profile fails for penguins data because it is a tibble #540

Closed pbiecek closed 1 year ago

pbiecek commented 1 year ago

this code generates an error

library("palmerpenguins")
data("penguins", package = "palmerpenguins")

library("mlr3")
library("mlr3learners")

penguins = na.omit(penguins)
task_peng = as_task_classif(penguins, target = "species")

learner = lrn("classif.ranger")
learner$predict_type = "prob"
learner$train(task_peng)

library("DALEX")
library("DALEXtra")

ranger_exp = explain_mlr3(learner,
  data = penguins[test_set, ],
  y = penguins[test_set, "species"],
  label = "Ranger RF",
  colorize = FALSE)

mumble <- penguins[1,]

predict(ranger_exp, mumble)

pmp1cp <- predict_profile(ranger_exp, as.data.frame(mumble))
plot(pmp1cp)

because all_observations[, var] for tibble does not produce vector, it stays a tibble

suggested solution: use all_observations[[var]]

pbiecek commented 1 year ago

candidate fix in https://github.com/ModelOriented/ingredients/commit/f061a703f08c54bb2a2f551eee8e7dc76f6e9ae9 is working with ingredients 2.3.0 and above

pbiecek commented 1 year ago

fixed in https://github.com/ModelOriented/ingredients/commit/87bfca97dfa750353f6704c58b1648c2793ecd51