Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradient Boosting Variable Importance

I have fit my gradient boosting model and am trying to print variable importance. I have used the same code and works using random forest. I keep getting the error when running varImp(). The error is the following.

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")
like image 567
Dustin Smith Avatar asked May 01 '18 03:05

Dustin Smith


1 Answers

Did you include the library "gbm?" (library(gbm)) That fixed the same error for me.

like image 199
phoenix0401 Avatar answered Jan 01 '23 22:01

phoenix0401