ms_update_observations: Update the observations of a modelStudio object

Description Usage Arguments Value References See Also Examples

View source: R/ms_update_observations.R

Description

This function calculates local explanations on new observations and adds them to the modelStudio object.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
ms_update_observations(
  object,
  explainer,
  new_observation = NULL,
  new_observation_y = NULL,
  max_features = 10,
  B = 10,
  show_info = TRUE,
  parallel = FALSE,
  widget_id = NULL,
  overwrite = FALSE,
  ...
)

Arguments

object

A modelStudio created with modelStudio().

explainer

An explainer created with DALEX::explain().

new_observation

New observations with columns that correspond to variables used in the model.

new_observation_y

True label for new_observation (optional).

max_features

Maximum number of features to be included in BD and SV plots. Default is 10.

B

Number of permutation rounds used for calculation of SV and FI. Default is 10. See vignette

show_info

Verbose a progress on the console. Default is TRUE.

parallel

Speed up the computation using parallelMap::parallelMap(). See vignette. This might interfere with showing progress using show_info.

widget_id

Use an explicit element ID for the widget (rather than an automatically generated one). Useful e.g. when using modelStudio with Shiny. See vignette.

overwrite

Overwrite existing observations and their explanations. Default is FALSE which means add new observations to the existing ones.

...

Other parameters.

Value

An object of the r2d3, htmlwidget, modelStudio class.

References

See Also

Vignettes: modelStudio - R & Python examples and modelStudio - perks and features

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
library("DALEX")
library("modelStudio")

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

# create an explainer for the model
explainer_titanic <- explain(model_titanic,
                             data = titanic_imputed,
                             y = titanic_imputed$survived)

# make a studio for the model
ms <- modelStudio(explainer_titanic,
                  N = 200,  B = 5) # faster example



# add new observations
ms <- ms_update_observations(ms,
                             explainer_titanic,
                             new_observation = titanic_imputed[100:101,],
                             new_observation_y = titanic_imputed$survived[100:101])
ms



# overwrite the observations with new ones
ms <- ms_update_observations(ms,
                             explainer_titanic,
                             new_observation = titanic_imputed[100:101,],
                             overwrite = TRUE)
ms

modelStudio documentation built on Jan. 13, 2021, 8:12 p.m.