我想为 GBM 模型创建特征重要性的形状图:
ctrlCV = trainControl(method = 'repeatedcv', repeats = 5 , number = 10 , classProbs = TRUE , savePredictions = TRUE, summaryFunction = twoClassSummary )
gbmFit = train(CR~., data = training_set,
method = "gbm",
metric="ROC",
trControl = ctrlCV,
tuneGrid = gbmGRID,
verbose = FALSE)
Run Code Online (Sandbox Code Playgroud)
然而,我找到的所有示例都是针对 xgboost 模型、SHAPforxgboost 和 shapr 等软件包,对我不起作用。例如:
shap_values <- shap.values(xgb_model = gbm_fit, X_train = tarining_set)
Run Code Online (Sandbox Code Playgroud)
产生和错误:
error in `colnames<-`(`*tmp*`, value = c(colnames(x_train), "bias")) : attempt to set 'colnames' on an object with less than two …Run Code Online (Sandbox Code Playgroud)