thomasp85 / lime

Local Interpretable Model-Agnostic Explanations (R port of original Python package)

Home Page:https://lime.data-imaginist.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error in plot_features: (list) object cannot be coerced to type 'double'

mstaniak opened this issue · comments

I found a problem with the bin_continuous option:

x1 <- rnorm(500)
x2 <- rnorm(500)
x3 <- rnorm(500)

y <- 4*x1 + 2*x2

X <- data.frame(y = y, 
                x1 = x1,
                x2 = x2,
                x3 = x3)

lm_m <- lm(y ~ x1 + x2 + x3, data = X)

library(lime)
lime_wrapper2 <- lime(X[, -1], model = lm_m,
                      bin_continuous = FALSE)
model_type.lm <- function(x, ...) "regression"
predict_model.lm <- function(x, newdata, type, ...) as.data.frame(predict(x, newdata, ...))
lime_explanation_2_0 <- lime::explain(X[4, -1], lime_wrapper2,
                                      n_features = 2)
plot_features(lime_explanation_2_0)