我适合我的渐变增强模型,并尝试打印变量重要性。我使用相同的代码,并使用随机森林。运行varImp()时我一直收到错误。错误如下。
Error in code$varImp(object$finalModel, ...) :
could not find function "relative.influence"
#Split into testing and training
set.seed(7)
Data_Splitting <- createDataPartition(clean_data$Output,p=2/3,list=FALSE)
training = clean_data[Data_Splitting,]
testing = clean_data[-Data_Splitting,]
#Random Forest training part
set.seed(7)
gbm_train <- train(Output~., data=training, method = "gbm",
trControl = trainControl(method="cv",number=4,classProbs = T,summaryFunction = twoClassSummary),metric="ROC")
#Plot of variable importance
varImp(gbm_train)
summary.gbm(gbm_train)
plot(varImp(gbm_train))
print(gbm)
#Random Forest Testing phase
gbm_predict = predict(gbm_train,newdata=testing,type="prob")
答案 0 :(得分:2)
你是否包括图书馆&#34; gbm?&#34;这为我解决了同样的错误。
答案 1 :(得分:0)
谢谢,这也对我有用:
library(gbm)
gbmFitGene=train(StatoP~.,data=dataSetGeneExp, method ="gbm" )
vImpGbm=varImp(gbmFitGene) #Variable importance
>
gbm variable importance
only 20 most important variables shown (out of 16600)
Overall
MRPL51 100.00
LOC646200 60.16
UQCRB 42.09
.......