使用 IML 计算 Shapley 值时出错

问题描述 投票:0回答:1
#training random forest model
set.seed(8431)
cvforest.train <- train(x = train[, c(3:122, 124:138)], y = train[, 123],  
                        method = "cforest", metric = "RMSE",
                        trControl = trainControl(method = "cv", number = 5),
                        controls = cforest_unbiased(ntree = 1000, minsplit = 5, minbucket = 5)
) 

cvforest.model.train<-cvforest.train$finalModel #final model object

#calculating shapley values
X <- train[, c(3:122, 124:138)]
y <- train[, 123]

predictor <- iml::Predictor$new(cvforest.model.train, data = X, y = y)
shapley_vals <- iml::Shapley$new(predictor)

使用上面的代码,我使用 R 中的 caret 和 party 包拟合了一个随机森林模型。现在我想计算该模型的 Shapley 值。但是,当我使用上面的代码创建“shapley_vals”对象时,我发现“results”和“fit”选项为 NULL。我不确定我错过了哪些步骤。关于下一步该做什么有什么建议吗?

r machine-learning random-forest iml shapley
1个回答
0
投票

如果没有示例数据,就很难提供帮助。您是否尝试过在 shapley 对象上使用

compute
函数?

shapley_vals$compute()
shapley_vals$results
© www.soinside.com 2019 - 2024. All rights reserved.