我正在创建一些 SHAP 分数图,用于可视化我使用 xgboost 创建的模型。我使用了运行良好的 SHAPforxgboost 包,现在我想在我正在编写的文本文档中使用这些数字(尤其是来自 shap.plot.summary() 的那个)。但是,x 轴和 y 轴上的标签/标题的字体大小非常小,我想知道是否有一种方法可以使它们变得更大且更具可读性。
我使用了非常相似的设置,如此处所示;https://www.rdocumentation.org/packages/SHAPforxgboost/versions/0.0.2:
library("SHAPforxgboost")
y_var <- "diffcwv"
dataX <- dataXY_df[,-..y_var]
# hyperparameter tuning results
param_dart <- list(objective = "reg:linear", # For regression
nrounds = 366,
eta = 0.018,
max_depth = 10,
gamma = 0.009,
subsample = 0.98,
colsample_bytree = 0.86)
mod <- xgboost::xgboost(data = as.matrix(dataX), label = as.matrix(dataXY_df[[y_var]]),
xgb_param = param_dart, nrounds = param_dart$nrounds,
verbose = FALSE, nthread = parallel::detectCores() - 2,
early_stopping_rounds = 8)
# To return the SHAP values and ranked features by mean|SHAP|
shap_values <- shap.values(xgb_model = mod, X_train = dataX)
# The ranked features by mean |SHAP|
shap_values$mean_shap_score
# To prepare the long-format data:
shap_long <- shap.prep(xgb_model = mod, X_train = dataX)
# is the same as: using given shap_contrib
shap_long <- shap.prep(shap_contrib = shap_values$shap_score, X_train = dataX)
# (Notice that there will be a data.table warning from `melt.data.table` due to `dayint` coerced from integer to double)
# **SHAP summary plot**
shap.plot.summary(shap_long)
更具体地说,我有兴趣增加 y 轴上每个描述符的字体大小