You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用shapviz绘制Shap值蜂群图时如何去除‘Sum of x other’项?

移除Shapviz蜂群图中的"Sum of x other"条目

你可以通过两种方式去掉这个汇总项:

方法1:提前筛选前15个特征再绘图

先提取出前15个最重要的特征,再基于这些特征创建新的Shapviz对象,之后绘图就不会出现汇总项了:

# 获取前15个特征的名称(排除自动生成的汇总项)
top15_features <- sv_importance(shp, max_display = 15)$feature[-length(sv_importance(shp, max_display = 15)$feature)]

# 创建仅包含前15个特征的Shapviz对象
shp_top15 <- shp[, top15_features]

# 绘制蜂群图
plot <- sv_importance(shp_top15, kind = "beeswarm", alpha = 0.5, show_numbers = TRUE)

方法2:修改已生成的ggplot对象

如果已经用原代码生成了plot对象,直接修改ggplot的数据源和轴刻度,移除汇总项:

# 移除数据中对应"Sum of x other"的行
plot$data <- plot$data[plot$data$feature != "Sum of x other", ]

# 更新y轴的刻度范围,去掉汇总项
plot$scales$scales[[1]]$limits <- plot$scales$scales[[1]]$limits[plot$scales$scales[[1]]$limits != "Sum of x other"]

内容的提问来源于stack exchange,提问作者kris

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.14 23:20:20