R/plotD3_ceteris_paribus.R
plotD3_ceteris_paribus.Rd
Function plotD3.ceteris_paribus_explainer
plots Individual Variable Profiles for selected observations.
It uses output from ceteris_paribus
function.
Various parameters help to decide what should be plotted, profiles, aggregated profiles, points or rugs.
Find more details in Ceteris Paribus Chapter.
plotD3(x, ...)
# S3 method for ceteris_paribus_explainer
plotD3(
x,
...,
size = 2,
alpha = 1,
color = "#46bac2",
variable_type = "numerical",
facet_ncol = 2,
scale_plot = FALSE,
variables = NULL,
chart_title = "Ceteris Paribus Profiles",
label_margin = 60,
show_observations = TRUE,
show_rugs = TRUE
)
a ceteris paribus explainer produced with function ceteris_paribus()
other explainers that shall be plotted together
a numeric. Set width of lines
a numeric between 0
and 1
. Opacity of lines
a character. Set line color
a character. If "numerical" then only numerical variables will be plotted. If "categorical" then only categorical variables will be plotted.
number of columns for the facet_wrap
a logical. If TRUE
, the height of plot scales with window size. By default it's FALSE
if not NULL
then only variables
will be presented
a character. Set custom title
a numeric. Set width of label margins in categorical
type
a logical. Adds observations layer to a plot. By default it's TRUE
a logical. Adds rugs layer to a plot. By default it's TRUE
a r2d3
object.
Explanatory Model Analysis. Explore, Explain, and Examine Predictive Models. https://ema.drwhy.ai/
library("DALEX")
library("ingredients")
library("ranger")
# \donttest{
model_titanic_rf <- ranger(survived ~., data = titanic_imputed, probability = TRUE)
explain_titanic_rf <- explain(model_titanic_rf,
data = titanic_imputed[,-8],
y = titanic_imputed[,8],
label = "ranger forest",
verbose = FALSE)
selected_passangers <- select_sample(titanic_imputed, n = 10)
cp_rf <- ceteris_paribus(explain_titanic_rf, selected_passangers)
plotD3(cp_rf, variables = c("age","parch","fare","sibsp"),
facet_ncol = 2, scale_plot = TRUE)
selected_passanger <- select_sample(titanic_imputed, n = 1)
cp_rf <- ceteris_paribus(explain_titanic_rf, selected_passanger)
plotD3(cp_rf, variables = c("class", "embarked", "gender", "sibsp"),
facet_ncol = 2, variable_type = "categorical", label_margin = 100, scale_plot = TRUE)
# }