r - tree.cv 回归的变量重要性图
问题描述
我使用回归模型创建了一个模型tree.cv()
split.tree <- sample(1:nrow(Boston), nrow(Boston) / 2)
tree.train <- Boston[split.tree,]
tree.test <- Boston[-split.tree,]
Boston.tree <- tree(medv ~ .,
data = Boston.train)
summary(Boston.tree)
plot(Boston.tree)
text(Boston.tree, pretty = 0)
title(main = "Unpruned Regression Tree")
tree.cv <- cv.tree(Boston.tree)
Boston.tree.prune= prune.tree(Boston.tree, best = 5)
summary(Boston.tree.prune)
plot(Boston.tree.prune)
text(Boston.tree.prune, pretty = 0)
title(main = "Pruned Regression Tree")
Boston.prune.pred <- predict(Boston.tree.prune, tree.test)
我现在有了预测,但我正在尝试绘制模型中存在的每个变量的重要性。我尝试使用 vip 包,但它似乎不适合这种类型的回归。
vip::vip(tree.cv, num_features = 40, bar = FALSE)
## Error: Model-specific variable importance scores are currently not available for this type of model.
我找到了另一个选项,varImpPlot()
但它只适合randomForest
. 关于如何做到这一点的任何想法?
解决方案
推荐阅读
- android - 为什么 Firebase Google 登录需要 API 密钥?
- python - Discord.py - 尝试加载特定的 cog
- python - 将文本数据预处理为整数索引(如 tensorFlow 文本分类示例中的 imdb 数据集)
- angular - 在角材料中共享一个组件或使用多个组件?
- hadoop - Hadoop Nodemanager 失败并出现错误无法获取组信息
- azure - AAD 登录引发 NotImplementedException
- go - 将默认值设置为自定义序列
- javascript - 查找以两位数字和一个字母开头的字符串
- swift - 我想知道印刷中的分隔符和终结符有什么不同?
- java - 如何在 Java 中进行 SAML SSO 重定向