I have an issue with FeatureEffects and my data when categorical features are present but I cannot find a hint in the documentation that categorical features would need a special treatment. It's probably me being stupid but when trying to reproduce the issue with the code and data from the documentation I do get a different error yet it won't run so I'm wondering if there might be a general issue with categorical features?
When adding a random categorical feature to the Boston data set from the example in the documentation of FeatureEffects the code throws an error:
Error in UseMethod("droplevels") :
no applicable method for 'droplevels' applied to an object of class "character"
Here's the modified code:
library("rpart")
library("iml")
data("Boston", package = "MASS")
# Adding a random categorical feature
Boston$cat <- sample(letters[1:2], nrow(Boston), replace = T) # w/o this line of code it works
rf <- rpart(medv ~ ., data = Boston)
mod <- Predictor$new(rf, data = Boston)
eff <- FeatureEffects$new(mod)
Sorry, just realized it has to be a factor... which it is in my dataset that's why the error is different. So probably something with my data... never mind
I have an issue with
FeatureEffects
and my data when categorical features are present but I cannot find a hint in the documentation that categorical features would need a special treatment. It's probably me being stupid but when trying to reproduce the issue with the code and data from the documentation I do get a different error yet it won't run so I'm wondering if there might be a general issue with categorical features?When adding a random categorical feature to the Boston data set from the example in the documentation of
FeatureEffects
the code throws an error:Here's the modified code: