Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in plot_explanations() function with a regression model - Error in combine_vars(data, params$plot_env, vars, drop = params$drop) : At least one layer must contain all variables used for facetting #60

Closed
andresrcs opened this issue Dec 5, 2017 · 1 comment

Comments

@andresrcs
Copy link

Hi, does plot_explanations() work with regression models? if it does, what am I doing wrong?

Here is a reproducible example:

library(tidyverse)
library(h2o)
library(lime)

dataset_url <- "https://www.dropbox.com/s/m2a0at1vk0xf3cr/sales.rds?raw=1"
sales_aug <- readRDS(gzcon(url(dataset_url)))

train <- sales_aug %>% filter(month <= 8)
valid <- sales_aug %>% filter(month == 9)
test <- sales_aug %>% filter(month == 10)

h2o.init()
h2o.no_progress()
train <- as.h2o(train)
valid <- as.h2o(valid)
test <- as.h2o(test)

y <- "amount"
x <- setdiff(names(train), y)

leaderboard <- h2o.automl(x, y, training_frame = train, validation_frame = valid, leaderboard_frame = test, max_runtime_secs = 30, stopping_metric = "deviance", seed = 12345)

model <- leaderboard@leader

explainer <- lime(as.data.frame(train[,-1]), model)
#> Warning: Data contains numeric columns with zero variance
explanation <- explain(as.data.frame(test[1:5,-1]), explainer, n_features = 5)

plot_explanations(explanation)
#> Error in combine_vars(data, params$plot_env, vars, drop = params$drop): At least one layer must contain all variables used for facetting
@thomasp85
Copy link
Owner

You're doing nothing wrong - thanks for reporting it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants