Clear Filters
Clear Filters

how to disable the random partition in cvpartition?

3 views (last 30 days)
I'm trying to build a classification model, where I'm using the cvpartition function to 'HoldOut' a certain percentage of train and test data.
In my design, I want to train 50% and tst the rest. But the problem I'm facing is, it splits the data randomly which I don't want it to happen. I have 9000 rows, I want the first 4500 for train and the next 4500 for test.
How do I solve this? Here's my code :
partition = cvpartition(total.status, 'HoldOut', 0.5);
traindata = total(training(partition), :);
testdata = total(test(partition), :);
Thank you.

Accepted Answer

Chinmay Anand
Chinmay Anand on 25 Jun 2019
I think if you don't want randomized data you can partition the data yourself. Something like what i have written below.
traindata = total(1:4500, :);
testdata = total(4501:9000, :);
  1 Comment
abhisrisai on 25 Jun 2019
Hi Chinmay,
Thank you for the suggestion, I shall try the same and let you know. Regards.

Sign in to comment.

More Answers (0)


Find more on Statistics and Machine Learning Toolbox 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!