Reputation: 11
set.seed(2)
rpcv <- trainControl(method='repeatedcv', number=4, repeats = 10,
savePredictions = T, classProbs = T)
iris2 <- iris[c(1:3,60:72,100:109),]
iris2_train <- iris2[-1,]
iris2_test <- iris2[1,]
set.seed(4)
iris_svm <- train(as.factor(Species)~., data=iris2_train, method='svmRadial', trControl=rpcv)
iris_svm$pred
If you look at iris$pred, you can see that there is an NA value. What's the problem?
Upvotes: 1
Views: 30
Reputation: 4425
I think your train data set have small number of sample class setosa (just 2 samples) which too small , so run models with a large enough n and class balance
so try this
library(caret)
set.seed(2)
rpcv <- trainControl(method='repeatedcv', number=4, repeats = 10,
savePredictions = T, classProbs = T)
# here i increased the sample of class setosa
iris2 <- iris[c(1:10,60:72,100:109),]
iris2_train <- iris2[-1,]
iris2_test <- iris2[1,]
set.seed(4)
iris_svm <- train(as.factor(Species)~., data=iris2_train, method='svmRadial', trControl=rpcv)
iris_svm$pred
Upvotes: 0