Learn R Programming

modelStudio (version 0.3.0)

modelStudio: Generate Interactive Studio for Explanatory Model Analysis

Description

This function computes various (instance and dataset level) model explanations and produces an interactive, customisable dashboard made with D3.js. It consists of multiple panels for plots with their short descriptions. Easily save and share the dashboard with others. Tools for model exploration unite with tools for EDA (Exploratory Data Analysis) to give a broad overview of the model behavior.

Find more details about the plots in Explanatory Model Analysis: Explore, Explain and Examine Predictive Models

Usage

modelStudio(explainer, ...)

# S3 method for explainer modelStudio( explainer, new_observation = NULL, new_observation_y = NULL, facet_dim = c(2, 2), time = 500, max_features = 10, N = 400, B = 15, eda = TRUE, show_info = TRUE, parallel = FALSE, options = modelStudioOptions(), viewer = "external", ... )

Arguments

explainer

An explainer created with function DALEX::explain().

...

Other parameters.

new_observation

A new observation with columns that correspond to variables used in the model.

new_observation_y

True label for new_observation (optional).

facet_dim

Dimensions of the grid. Default is c(2,2).

time

Time in ms. Set animation length. Default is 500.

max_features

Maximum number of features to be included in Break Down and Shapley Values plots. Default is 10.

N

Number of observations used for calculation of partial dependence profiles. Default is 400.

B

Number of random paths used for calculation of Shapley values. Default is 15.

eda

Compute EDA plots. Default is TRUE.

show_info

Verbose progress bar on the console. Default is TRUE.

parallel

Speed up the computation using parallelMap::parallelMap(). See vignette.

options

Customize modelStudio. See modelStudioOptions and vignette.

viewer

Default is external to display in an external RStudio window. Use browser to display in an external browser or internal to use the RStudio internal viewer pane for output.

Value

An object of the r2d3 class.

References

  • Wrapper for the function is implemented in DALEX

  • Feature Importance, Ceteris Paribus, Partial Dependence and Accumulated Dependence plots are implemented in ingredients

  • Break Down and Shapley Values plots are implemented in iBreakDown

See Also

Python wrappers and more can be found in DALEXtra

Examples

Run this code
# NOT RUN {
library("DALEX")
library("modelStudio")

#:# ex1 classification on 'titanic_imputed' dataset

# Create a model
model_titanic <- glm(survived ~.,
                     data = titanic_imputed,
                     family = "binomial")

# Wrap it into an explainer
explain_titanic <- explain(model_titanic,
                           data = titanic_imputed[,-8],
                           y = titanic_imputed[,8],
                           label = "glm",
                           verbose = FALSE)

# Pick some data points
new_observations <- titanic_imputed[1:2,]
rownames(new_observations) <- c("Lucas","James")

# Make a studio for the model
modelStudio(explain_titanic, new_observations,
            N = 100, B = 10, show_info = FALSE)

# }
# NOT RUN {
#:# ex2 regression on 'apartments' dataset

model_apartments <- randomForest::randomForest(m2.price ~. ,
                                               data = apartments)

explain_apartments <- explain(model_apartments,
                              data = apartments[,-1],
                              y = apartments[,1],
                              verbose = FALSE)

new_apartments <- apartments[1:2,]
rownames(new_apartments) <- c("ap1","ap2")

# change dashboard dimensions and animation length
modelStudio(explain_apartments, new_apartments,
            facet_dim = c(2, 3), time = 800,
            show_info = FALSE)

# add information about true labels
modelStudio(explain_apartments, new_apartments,
                                new_observation_y = apartments[1:2, 1],
                                show_info = FALSE)

# don't compute EDA plots
modelStudio(explain_apartments, eda = FALSE,
            show_info = FALSE)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab