-
Notifications
You must be signed in to change notification settings - Fork 24
Closed
Description
Hello treeshap team,
I am currently attempting to utilize the Treeshap package to calculate SHAP values. However, I encountered an error when trying to apply it to models created using the mlr3 framework. Specifically, I am unsure how to properly execute Treeshap with mlr3 models.
Could you please provide guidance or an example of how to integrate Treeshap with mlr3 models? Any assistance would be greatly appreciated.
Thank you in advance for your support π
library(shapviz)
library(kernelshap)
library(mlr3)
library(mlr3verse)
library(mlr3learners)
library(treeshap)
library(xgboost)
data <- fifa20$data[colnames(fifa20$data) != 'work_rate']
target <- fifa20$target
data$target = target
tsk = mlr3::TaskRegr$new(id="dd", backend = data, target = "target")
as.data.table(lrn())
learner = lrn("regr.xgboost")
mm = resample(
task = tsk,
learner = learner,
resampling = rsmp("cv", folds=3),
store_backends = T,
store_models = T
)
unified <- unify(mm$learners[[1]], data)
Error: unify.default(mm$learners[[1]], data):
Provided model is not of type supported by treeshap.
The model object is
> mm$learners[[1]]
<LearnerRegrXgboost:regr.xgboost>: Extreme Gradient Boosting
* Model: xgb.Booster
* Parameters: nrounds=1000, nthread=1, verbose=0
* Validate: NULL
* Packages: mlr3, mlr3learners, xgboost
* Predict Types: [response]
* Feature Types: logical, integer, numeric
* Properties: hotstart_forward, importance, internal_tuning, missings,
validation, weights
Metadata
Metadata
Assignees
Labels
No labels