- Set the number of folds and repetitions for your cross-validation process. For example, you can choose 10-fold cross-validation with 50 repetitions.
- Create an outer loop that iterates over the number of repetitions. This will allow you to perform the cross-validation process multiple times.
- Within the outer loop, shuffle your data to ensure each repetition has different data in the folds. You can do this by generating a random permutation of the indices of your data points.
- Create a partition of your shuffled data into training and validation sets using k-fold cross-validation.
- Create an inner loop that iterates over the number of folds. Extract the training and validation sets for the current fold within this loop.
Repeated k fold cross validation
19 次查看(过去 30 天)
显示 更早的评论
Hi all
Does anyone know how to performed repeated k-fold cross validation? I can implement a single k-fold e.g. 10 fold many ways e.g.
cvmdlLD = fitcdiscr(X,y,'DiscrimType','linear','KFold',10)
Or by using crossval or cv partition etc.
But I can figure out how to repeat the process, shuffling the data in the folds.
For example, I would like to run the process several times e.g. run 10 fold cross validation once, then shuffle the data in the folds, run again and so on for a reasonably good number of times so as to get an idea of any variability. Ideally I would like to collect the classification performance statistics (accuracy, sensitivity, specificity, AUROC) each time (so if I looped round 50 times I would have 50 accuracies, 50 sensitivities and so on) so that I can look at, for example, the average and standard deviation.
Thanks
0 个评论
回答(1 个)
Himanshu
2023-4-26
Hello James,
I understand that you want to perform repeated k-fold cross-validation while shuffling the data in the folds for each repetition.
Here's a general outline of the steps:
By following this outline, you can perform repeated k-fold cross-validation.
You can refer to the below documentation to understand more about Cross Validation in MATLAB.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Classification Ensembles 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!