How do I sequentially partition the folds in cross validation?

1 view (last 30 days)
I’m working on a partial least squares regression problem where I want to set up cross validation with a cvpartition object. However, I can’t seem to figure out how to make it partition the folds so that the observations are picked consecutively, which I need them to be.
If I write:
c = cvpartition(length(Y),'KFold',10)
it just partitions the folds randomly if I understand the documentation correct. In fact, every option I’ve read about in the documentation seems to be based on random partitioning. Surely there has to be an option for consecutively partitioning the observations?
One idea I had was to first create a random cvpartition object and then manipulate it by manually forcing the object to use indices that I assign in each fold like this:
c.training(i) = TrainIndex(i,:)'
but matlab doesn’t seem to give me permission to do that.
Does anyone know how to do this? If my data for example goes from 1 to 100 I want my folds to consist of 1:10, 11:20, 21:30 etc. or something like that.
Thanks.

Answers (1)

Jo
Jo on 4 Nov 2016
Hi Petter,
Did you find a way to do what you wanted ?
I need to choose my own subsets for the cross-validation and not random ones for optimizing SVM parameters.
And I cannot find a solution. Please tell me if you have one...
Thanks

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!