| gbm.unify | R Documentation | 
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.
gbm.unify(gbm_model, data)
gbm_model | 
 An object of   | 
data | 
 Reference dataset. A   | 
a unified model representation - a model_unified.object object
lightgbm.unify for LightGBM models
xgboost.unify for XGBoost models
ranger.unify for ranger models
randomForest.unify for randomForest models
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.