gbm.unify {treeshap} | R Documentation |
Unify GBM model
Description
Convert your GBM model into a standardized representation.
The returned representation is easy to be interpreted by the user and ready to be used as an argument in treeshap()
function.
Usage
gbm.unify(gbm_model, data)
Arguments
gbm_model |
An object of |
data |
Reference dataset. A |
Value
a unified model representation - a model_unified.object
object
See Also
lightgbm.unify
for LightGBM 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 = "gaussian",
n.trees = 20,
interaction.depth = 4,
n.cores = 1)
unified_model <- gbm.unify(gbm_model, data)
shaps <- treeshap(unified_model, data[1:2,])
plot_contribution(shaps, obs = 1)
[Package treeshap version 0.3.1 Index]