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

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(). An explainer created with DALEX::explain(). New observations with columns that correspond to variables used in the model. True label for new_observation (optional). Maximum number of features to be included in BD and SV plots. Default is 10. Number of permutation rounds used for calculation of SV and FI. Default is 10. See vignette Verbose a progress on the console. Default is TRUE. Speed up the computation using parallelMap::parallelMap(). See vignette. This might interfere with showing progress using show_info. 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 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

• The input object is implemented in DALEX

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

• Break Down and Shapley Values explanations are implemented in iBreakDown

## Examples

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) #> Preparation of a new explainer is initiated #> -> model label : lm ( default ) #> -> data : 2207 rows 8 cols #> -> target variable : 2207 values #> -> predict function : yhat.glm will be used ( default ) #> -> predicted values : No value for predict function target column. ( default ) #> -> model_info : package stats , ver. 4.0.5 , task classification ( default ) #> -> predicted values : numerical, min = 0.008128381 , mean = 0.3221568 , max = 0.9731431 #> -> 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! # make a studio for the model ms <- modelStudio(explainer_titanic, N = 200, B = 5) # faster example #> new_observation argument is NULL. new_observation_n observations needed to calculate local explanations are taken from the data. # \donttest{ # 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

# }