show_rugs | R Documentation |
Function show_rugs
adds a layer to a plot created with
plot.ceteris_paribus_explainer
for selected observations.
Various parameters help to decide what should be plotted, profiles, aggregated profiles, points or rugs.
show_rugs( x, ..., size = 0.5, alpha = 1, color = "#371ea3", variable_type = "numerical", sides = "b", variables = NULL )
x |
a ceteris paribus explainer produced with function |
... |
other explainers that shall be plotted together |
size |
a numeric. Size of lines to be plotted |
alpha |
a numeric between |
color |
a character. Either name of a color or name of a variable that should be used for coloring |
variable_type |
a character. If |
sides |
a string containing any of "trbl", for top, right, bottom, and left. Passed to geom rug. |
variables |
if not |
a ggplot2
layer
Explanatory Model Analysis. Explore, Explain, and Examine Predictive Models. https://ema.drwhy.ai/
library("DALEX") library("ingredients") titanic_small <- select_sample(titanic_imputed, n = 500, seed = 1313) # build a model model_titanic_glm <- glm(survived ~ gender + age + fare, data = titanic_small, family = "binomial") explain_titanic_glm <- explain(model_titanic_glm, data = titanic_small[,-8], y = titanic_small[,8]) cp_glm <- ceteris_paribus(explain_titanic_glm, titanic_small[1,]) cp_glm library("ranger") rf_model <- ranger(survived ~., data = titanic_imputed, probability = TRUE) explainer_rf <- explain(rf_model, data = titanic_imputed[,-8], y = titanic_imputed[,8], label = "ranger forest", verbose = FALSE) selected_passangers <- select_sample(titanic_imputed, n = 100) cp_rf <- ceteris_paribus(explainer_rf, selected_passangers) cp_rf plot(cp_rf, variables = "age", color = "grey") + show_observations(cp_rf, variables = "age", color = "black") + show_rugs(cp_rf, variables = "age", color = "red")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.