How to resolve NA error while using svmbag in R

ensemble_methods
svm

#1

Hello,

I am trying to do bagging of SVM’s using the caret,kernlab and ipred libraries in R.My code is:
bagctrl <- bagControl(fit = svmBag$fit,
predict = svmBag$pred,
aggregate = svmBag$aggregate)
set.seed(300)
svmbag <- train(default ~ ., data = credit, “bag”,trControl = ctrl, bagControl = bagctrl)
However I got an error:

I don’t quite understand why this is happening and hence would request somebody to help me out!!
Shown below is the structure of the dataset:


#2

I am facing the same issue. Did you get it resolved?


#3

I found solution by storing svmBag$pred function as a variable predfunct
Solution Link; http://stackoverflow.com/questions/31844742/caret-function-train-failing-for-bagged-svm

predfunct<-function (object, x)
{
if (is.character(lev(object))) {
out <- predict(object, as.matrix(x), type = “probabilities”)
colnames(out) <- lev(object)
rownames(out) <- NULL
}
else out <- predict(object, as.matrix(x))[, 1]
out
}

bagctrl <- bagControl(fit = svmBag$fit, predict = predfunct,aggregate = svmBag$aggregate)

set.seed(300)
svmbag <- train(default ~ ., data = credit,“bag”, trControl = ctrl, bagControl = bagctrl)
svmbag