I want to build gradient boosting model for data vowel.train which is from R package AppliedPredictiveModelling. This is my code:
library(gbm)
library(caret)
set.seed(12345)
# Define the training control
ctrl <- trainControl(method = "repeatedcv",
number = 10,
repeats = 3,
verboseIter = TRUE)
# Define tuning grid for GBM model
gbm_grid <- expand.grid(
n.trees = c(50, 100, 150),
interaction.depth = c(1, 5, 9),
shrinkage = c(.01, .1, .5),
n.minobsinnode = c(5, 10, 15)
)
# Train GBM model
model2 <- train(y ~ .,
method = 'gbm',
data = vowel.train,
tuneGrid = gbm_grid,
trControl = ctrl,
metric = 'Accuracy')
# Make predictions on test set
predictions <- predict(model2, newdata = vowel.test, type = 'response')
# Assess model performance
confusionMatrix(predictions, vowel.test$y)
But I can't tune model, because I have got next error message:
+ Fold01.Rep1: shrinkage=0.01, interaction.depth=1, n.minobsinnode= 5, n.trees=150
Iter TrainDeviance ValidDeviance StepSize Improve
1 2.3979 nan 0.0100 0.0412
2 2.3755 nan 0.0100 0.0419
3 2.3536 nan 0.0100 0.0360
4 2.3331 nan 0.0100 0.0296
5 2.3138 nan 0.0100 0.0338
6 2.2951 nan 0.0100 0.0247
7 2.2787 nan 0.0100 0.0350
8 2.2599 nan 0.0100 0.0314
9 2.2437 nan 0.0100 0.0261
10 2.2274 nan 0.0100 0.0274
20 2.0847 nan 0.0100 0.0188
40 1.8872 nan 0.0100 0.0102
60 1.7411 nan 0.0100 0.0063
80 1.6219 nan 0.0100 0.0085
100 1.5196 nan 0.0100 0.0041
120 1.4333 nan 0.0100 0.0046
140 1.3571 nan 0.0100 0.0040
150 1.3227 nan 0.0100 0.0039
predictions failed for Fold01.Rep1: shrinkage=0.01, interaction.depth=1, n.minobsinnode= 5, n.trees=150 Error in UseMethod("predict") :
no applicable method for 'predict' applied to an object of class "gbm"
Warning message in eval(xpr, envir = envir):
"predictions failed for Fold01.Rep1: shrinkage=0.01, interaction.depth=1, n.minobsinnode=10, n.trees=150 Error in UseMethod("predict") :
no applicable method for 'predict' applied to an object of class "gbm"
"
Please, give me a hint what a problem appears in data that I can't fit it?