cvpartition with specified indices
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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
0 comentarios
Respuestas (1)
Drew
el 26 de En. de 2024
As of R2023b, users can manually specify the indices in a cvpartition with the syntax
c = cvpartition("CustomPartition",testSets)
The details, including the possible formats for the "testSets" specification, are in the R2023b+ cvpartition doc https://www.mathworks.com/help/stats/cvpartition.html. This new feature is also mentioned in the R2023b SMLT release notes at https://www.mathworks.com/help/stats/release-notes.html.
If this answer helps you, please remember to accept the answer.
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!