Created
March 21, 2020 15:04
-
-
Save almogsi/5791894793a391af9d7add7ca67edb08 to your computer and use it in GitHub Desktop.
Lime with Caret
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(tidyverse) | |
| library(caret) | |
| library(lime) | |
| #fit | |
| lasso_caret<- train(data = mtcars, mpg~., method = "glmnet", | |
| tuneGrid = expand.grid(alpha = 1, | |
| lambda = 0)) | |
| #LIME | |
| explainer <- lime(mtcars, lasso_caret) #here the train data | |
| explanation <- explain(mtcars, explainer) #here the test data | |
| #plots | |
| plot_features(explanation, ncol = 2) | |
| plot_features(explanation, ncol = 1, cases = "Volvo 142E") #plot a specific case | |
| plot_explanations(explanation) #plot feature by case |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment