christophM / interpretable-ml-book

Book about interpretable machine learning
https://christophm.github.io/interpretable-ml-book/
Other
4.73k stars 1.05k forks source link

get_effects() should have gsub() edits applied to reference_X and not just X #262

Closed brshallo closed 3 years ago

brshallo commented 3 years ago

Tried running these functions on another dataset and got an error:

mod <- lm(Sepal.Length ~ ., data = iris)
iml.book::get_effects(mod, iris)
#> Error in reference_X[1, names(X)] : subscript out of bounds

This occurs because in get_effects() the changes to colnames() from gsub() are applied only to X but are not applied to the names for reference_X so get subscript error during apply() step if had non-characters in column names.

Sidenote

Would love if some of these funs were put into a separate package (or if have tips on other established packages for effect plots).

christophM commented 3 years ago

Hi Bryan. I am not planning to put this into a separate package or anything, I am happy as long as the code works for the examples in the book.

brshallo commented 3 years ago

It might be helpful to add a "software" section for 4.1. providing recommendations on available packages.