Best way to split data into random partitions

조회 수: 5 (최근 30일)
G. Nardi
G. Nardi 2019년 1월 12일
답변: Asimananda Khandual 2020년 8월 4일
I have a mat file which contains a double that I created into a histogram.
I have classOne and classTwo. I am trying to slip the data into random partitions
this is not working for me. can you help?
split = [x,y];
% Cross varidation (train: 70%, test: 30%)
cv = cvpartition(split,'HoldOut',0.4);
idx = cv.test;
% Separate to training and test data
dataTrain = split(~idx,:);
dataTest = split (idx,:);
  댓글 수: 2
Akira Agata
Akira Agata 2019년 1월 13일
What is the variable split ? If this variable is a data set with N-by-M array, I think the following will work.
split = [x,y];
% Cross varidation (train: 70%, test: 30%)
cv = cvpartition(size(split,1),'HoldOut',0.3);
idx = cv.test;
% Separate to training and test data
dataTrain = split(~idx,:);
dataTest = split (idx,:);

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

답변 (1개)

Asimananda Khandual
Asimananda Khandual 2020년 8월 4일
if you have 15 dataset feed as variable Lab_ABC to split for training and testing proceed as below:
Indices=randperm(15);
Trainingset=Lab_ABC(Indices(1:10),:);
Testingset= Lab_ABC (Indices(11:end),:);
Asim

카테고리

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

태그

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by