set_reference_dataset {treeshap} | R Documentation |
Set reference dataset
Description
Change a dataset used as reference for calculating SHAP values.
Reference dataset is initially set with data
argument in unifying function.
Usually reference dataset is dataset used to train the model.
Important property of reference dataset is that SHAP values for each observation add up to its deviation from mean prediction for a reference dataset.
Usage
set_reference_dataset(unified_model, x)
Arguments
unified_model |
Unified model representation of the model created with a (model).unify function. ( |
x |
Reference dataset. A |
Value
model_unified.object
. Unified representation of the model as created with a (model).unify function,
but with changed reference dataset (Cover column containing updated values).
See Also
lightgbm.unify
for LightGBM models
gbm.unify
for GBM models
xgboost.unify
for XGBoost models
ranger.unify
for ranger models
randomForest.unify
for randomForest models
Examples
library(gbm)
data <- fifa20$data[colnames(fifa20$data) != 'work_rate']
data['value_eur'] <- fifa20$target
gbm_model <- gbm::gbm(
formula = value_eur ~ .,
data = data,
distribution = "laplace",
n.trees = 20,
interaction.depth = 4,
n.cores = 1)
unified <- gbm.unify(gbm_model, data)
set_reference_dataset(unified, data[200:700, ])