I have a really small dataset (124 samples) and I'd like to try out if I get some interesting results with some machine learning algorithms in R.
What I've done: I splitted my data set into 75% training and 25% test, and trained six diferent models with the structure similar as follows:
fitControl <- trainControl(## 10-fold CV
method = "repeatedcv",
number = 10,
## repeated five times
repeats = 5,
savePredictions = TRUE,
classProbs = TRUE,
summaryFunction = twoClassSummary)
model_SVM_P <- train(Group ~ ., data = training_set,
method = "svmPoly",
trControl = fitControl,
metric = "Accuracy",
verbose = FALSE,
tuneLength = 10)
However, I just started studying about machine learning and deep learning and the cross validation part is aways hard to understand.
The question is: In the code there is only the inner cross validation step, is it necessary to do an outer loop for cv? If yes, how can I code it?
EDIT:
Just an update that can be helpful if someone is passing by with the same problem:
I did this and worked fine:
folds <- createFolds(training_set$Group,4)
split_up <- lapply(folds, function(ind, dat) dat[ind,], dat = training_set)
parms_list_SVM_P <- list()
model_list_SVM_P <- list()
for (i in 1:4) {model_SVM_P <- train(Group ~ ., data = split_up[[i]],
method = "svmPoly",
trControl = fitControl,
metric = "Accuracy",
verbose = FALSE,
tuneLength = 10)
model_list_SVM_P[[i]] <- model_SVM_P
parms_list_SVM_P[[i]] <- model_SVM_P$bestTune}
Now I'm proceding to further analysis.
If someone with more expertise find a mistake, please let me know.
This link helped me a lot: https://stackoverflow.com/questions/62183291/statistical-test-with-test-data/62193116#62193116