how to disable the random partition in cvpartition?

조회 수: 4 (최근 30일)
abhisrisai
abhisrisai 2019년 6월 25일
댓글: abhisrisai 2019년 6월 25일
Hi,
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 :
rng('default');
partition = cvpartition(total.status, 'HoldOut', 0.5);
traindata = total(training(partition), :);
testdata = total(test(partition), :);
Thank you.

채택된 답변

Chinmay Anand
Chinmay Anand 2019년 6월 25일
Hi,
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
abhisrisai
abhisrisai 2019년 6월 25일
Hi Chinmay,
Thank you for the suggestion, I shall try the same and let you know. Regards.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Statistics and Machine Learning Toolbox에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by