r - 使用 Caret 查找重要的特征
问题描述
我在使用时遇到问题Caret
。
我使用以下代码在 nnet 方法中构建模型,它可以工作。
model_nnet<-train(trainSetSmall[,predictors],trainSetSmall[,outcomeName],method='nnet')
importance <- varImp(model_nnet, scale=FALSE)
plot(importance)
然后,我想尝试其他模型。我试过“gbm”,但它不起作用。
model_gbm<-train(trainSetSmall[,predictors],trainSetSmall[,outcomeName],method='gbm')
importance2 <- varImp(model_gbm, scale=FALSE)
Error Message: > importance2 <- varImp(model_gbm, scale=FALSE)
Error in relative.influence(object, n.trees = numTrees) :
could not find function "relative.influence"
我也尝试了其他模型,但除了 nnet,我找不到另一个有效的模型。我的数据样本(所有列都是数字):
structure(list(x_NMI = c(6347, 6347), EstimateReadBitmaskInd = c(0,
0), MeterRegActiveReadingDt = c("15-01-2013", "18-01-2013"),
MtrRegActNetEngyDailyKwh = c(16.736, 18.093), MtrRgActNetEngyMaxdlyKwh = c(0.831,
0.65), RegisterId = c(2, 2), RegisterType = c(2, 2), Building = c(6,
6), numberofpeople = c(5, 5), pool = c(2, 2), typeofAC = c(1,
1), NoOfAc = c(1, 1)), row.names = 1:2, class = "data.frame")
解决方案
看起来relative.influence
是包中的一个函数,gbm
如下所示:
我安装了插入符号并尝试使用 gbm 在一些琐碎的数据上训练模型。此消息提示我安装gbm
软件包。
一旦我安装了这个gbm
包,我就可以在插入符号中使用 gbm 来训练模型。
推荐阅读
- python - 在散景图中显示 base64 图像
- c# - 如何根据外键访问父表中的列
- javascript - XGrid 材质 ui 自定义行颜色
- javascript - 获取 Aspx 页面中的用户控件元素
- django-models - Django Rest Framework 中自定义用户的自定义身份验证令牌
- node.js - 如何在节点 js 应用程序的 heroku procfile 中指定更改目录
- c# - EF Core MySQL 在使用 DateTimeOffset 时使用不一致的时区
- xampp - 你能告诉我这些地址在 XAMPP 中的用途吗?
- javascript - 在 Nodejs (Emscripten) 中调用和包装 C 函数
- android - 登录页面显示在设计预览中但不在模拟器中