R/ms_merge_observations.R
ms_merge_observations.Rd
This function merges local explanations from multiple modelStudio
objects into one.
ms_merge_observations(...)
modelStudio
objects created with modelStudio()
.
An object of the r2d3, htmlwidget, modelStudio
class.
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
# \donttest{
library("DALEX")
library("modelStudio")
# fit a model
model_happiness <- glm(score ~., data = happiness_train)
# create an explainer for the model
explainer_happiness <- explain(model_happiness,
data = happiness_test,
y = happiness_test$score)
#> Preparation of a new explainer is initiated
#> -> model label : lm ( default )
#> -> data : 156 rows 7 cols
#> -> target variable : 156 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.3.1 , task regression ( default )
#> -> predicted values : numerical, min = 2.726257 , mean = 5.553508 , max = 7.560368
#> -> residual function : difference between y and yhat ( default )
#> -> residuals : numerical, min = -1.976856 , mean = -0.1464115 , max = 0.9116971
#> A new explainer has been created!
# make studios for the model
ms1 <- modelStudio(explainer_happiness,
N = 200, B = 5)
#> `new_observation` argument is NULL. `new_observation_n` observations needed to calculate local explanations are taken from the data.
ms2 <- modelStudio(explainer_happiness,
new_observation = head(happiness_test, 3),
N = 200, B = 5)
# merge
ms <- ms_merge_observations(ms1, ms2)
ms
# }