xgboost
xgboost copied to clipboard
xgb.plot.shap failed when not providing model
Hi, I changed the example in help a little, found that not work. Can someone bring me a clue what happened?
data(agaricus.train, package='xgboost')
data(agaricus.test, package='xgboost')
bst <- xgboost(agaricus.train$data, agaricus.train$label, nrounds = 50,
eta = 0.1, max_depth = 3, subsample = .5,
method = "hist", objective = "binary:logistic", nthread = 2, verbose = 0)
contr <- predict(bst, agaricus.test$data, predcontrib = TRUE)
#Since the last col of contr is NOT included in original date, I didn't pick it.
xgb.plot.shap(agaricus.test$data, contr, features = colnames(contr)[1:(ncol(contr)-1)], top_n = 12, n_col = 3)
but this failed