cvpartition with specified indices
Show older comments
I want to manually specify the indices in cvpartition for leave-one-out cross validation with 5 subjects. Right now the data is split into 5 equal parts if I set "KFold" to 5.
train = [1:50];
cvpt = cvpartition(train,"KFold",5)
K-fold cross validation partition
NumObservations: 50
NumTestSets: 5
TrainSize: 40 40 40 40 40
TestSize: 10 10 10 10 10
Now I want to manually specify which indices are used for training and which for testing. Lets say the indices of my 5 train and test sets are:
Test1_idx = [1:8]; Train1_idx = [9:50];
Test2_idx = [9:21]; Train2_idx = [1:8 22:50];
Test3_idx = [22:31]; Train3_idx = [1:21 32:50];
Test4_idx = [32:44]; Train4_idx = [1:31 45:50];
Test5_idx = [45:50]; Train5_idx = [1:44];
How can I specify this in Matlab before I fit machine learning model?
The cvpt should then look like this:
NumObservations: 50
NumTestSets: 5
TrainSize: 42 37 40 37 44
TestSize: 8 13 10 13 6
Accepted Answer
More Answers (0)
Categories
Find more on Resampling Techniques in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!