I like to know how to build an Ensembl Stacking R model using the caret package. In this model cross-validation function should be loocv In trainControl index param required to add manually.
currently, I tried this but I got errors like follows.
Error: Stopping
In addition: Warning messages:
1: model fit failed for Subjectdead: cp=0.08824 Error in omnibus.balancing(formula, data, subset, na.action, N, p, method = "rose", :
The response variable has only one class.
2: model fit failed for Subjectsurvived: cp=0.08824 Error in omnibus.balancing(formula, data, subset, na.action, N, p, method = "rose", :
The response variable has only one class.
3: In nominalTrainWorkflow(x = x, y = y, wts = weights, info = trainInfo, :
There were missing values in resampled performance measures.
Code Like this
# Stacking Algorithms
subs <- unique(train_set$classes)
model_these <- vector(mode = "list", length = length(subs))
for(i in seq_along(subs))
model_these[[i]] <- which(train_set$classes != subs[i])
names(model_these) <- paste0("Subject", subs)
control <- trainControl(sampling="rose",method="loocv", index=model_these, savePredictions=TRUE, classProbs=TRUE, summaryFunction = twoClassSummary)
algorithmList <- c('rpart', 'knn', 'nb')
set.seed(seed)
stack_models <- caretList(classes~., data=train_set, metric="ROC", trControl=control, methodList=algorithmList)
Dataset: https://archive.ics.uci.edu/ml/datasets/forest+fires
Thanks