Closed GitHunter0 closed 2 years ago
Late to the party here, @GitHunter0 - but {lime}
already has support for {parsnip}
models via the predict_model.model_fit
method: https://github.com/thomasp85/lime/blob/0281c56e6da697c686e2d7761dfc7a658decb3ca/R/models.R#L117-L127
Here is a simple example:
library(tidymodels)
library(lime)
model <- fit(
object = rand_forest('regression'),
data = iris,
formula = Sepal.Length ~ .
)
explainer <- lime(iris, model)
explanation <- explain(
x = slice(iris, 1:6),
explainer = explainer,
n_features = 4
)
plot_features(explanation)
If you're using {workflows}
objects instead of {parsnip}
objects, then you just need to extract the {parsnip}
model object with extract_fit_parsnip(workflow)
. For example:
wflow <-
workflow(
preprocessor = Sepal.Length ~ .,
spec = rand_forest('regression')
) %>%
fit(data = iris)
explainer <- lime(iris, extract_fit_parsnip(wflow))
I appreciate the clarification, @mattwarkentin .
I really like how
lime
integrates well withH2O
, do you have plans to also add support fortidymodels
? It would be very helpful since it is becoming the default modeling ecosystem forR
. Thank you