This function creates a Shiny application for explainers which are adapters for models created using the DALEX package. The application contains model performance and explanations to fully explore the model.

xai2shiny(
  ...,
  directory = NULL,
  selected_variables = NULL,
  run = TRUE,
  override = FALSE,
  verbose = TRUE
)

Arguments

...

one or more explainers created with DALEX::explain() function. They can be switched in top right corner of the application.

directory

path to the directory the application files will be created in. If NULL the application will be created in a temporary directory.

selected_variables

choosen variables for application start-up. There can be more added in the application interface through an input.

run

whether to run the Shiny application instantly

override

how to respond to a directory overriding case

verbose

whether to log in console internal function's steps

Examples

# Create models library("ranger") library("DALEX")
#> Welcome to DALEX (version: 2.0.1). #> Find examples and detailed introduction at: https://pbiecek.github.io/ema/ #> Additional features will be available after installation of: ggpubr. #> Use 'install_dependencies()' to get all suggested dependencies
model_rf <- ranger(survived ~ ., data = titanic_imputed, classification = TRUE, probability = TRUE) model_glm <- glm(survived ~ ., data = titanic_imputed, family = "binomial") # Create DALEX explainers explainer_rf <- explain(model_rf, data = titanic_imputed[,-8], y = titanic_imputed$survived)
#> Preparation of a new explainer is initiated #> -> model label : ranger ( default ) #> -> data : 2207 rows 7 cols #> -> target variable : 2207 values #> -> predict function : yhat.ranger will be used ( default ) #> -> predicted values : numerical, min = 0.01324852 , mean = 0.3220632 , max = 0.9892313 #> -> model_info : package ranger , ver. 0.12.1 , task classification ( default ) #> -> residual function : difference between y and yhat ( default ) #> -> residuals : numerical, min = -0.7996185 , mean = 9.356414e-05 , max = 0.8899283 #> A new explainer has been created!
explainer_glm <- explain(model_glm, data = titanic_imputed[,-8], y = titanic_imputed$survived)
#> Preparation of a new explainer is initiated #> -> model label : lm ( default ) #> -> data : 2207 rows 7 cols #> -> target variable : 2207 values #> -> predict function : yhat.glm will be used ( default ) #> -> predicted values : numerical, min = 0.008128381 , mean = 0.3221568 , max = 0.9731431 #> -> model_info : package stats , ver. 4.0.3 , task classification ( default ) #> -> residual function : difference between y and yhat ( default ) #> -> residuals : numerical, min = -0.9628583 , mean = -2.569729e-10 , max = 0.9663346 #> A new explainer has been created!
# Create and run the application if (FALSE) { xai2shiny(explainer_rf, explainer_glm) }