How can I do a 80-20 split on datasets to obtain training and test datasets?
55 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Chidiebere Ike
el 15 de Mzo. de 2018
Comentada: Prasobhkumar P. P.
el 7 de Nov. de 2020
I tried [training, test] = partition (faceDatabase, [0.8, 0.2]); but it gives me error. Can anyone help? Are there ways to do this manually? I can't find a function for this!
2 comentarios
Respuesta aceptada
KSSV
el 15 de Mzo. de 2018
Let P and T be your input and target sets.
PD = 0.80 ; % percentage 80%
Ptrain = P(1:round(PD*length(T)),:) ; Ttrain = T(1:round(PD*length(T))) ;
Ptest = P(round(PD*length(T)):end,:) ;Ttest = T(round(PD*length(T)):end) ;
2 comentarios
Más respuestas (2)
Akira Agata
el 15 de Mzo. de 2018
Editada: Akira Agata
el 15 de Mzo. de 2018
If you want to randomly select 80% of your data as training dataset, please try following:
PD = 0.80 ; % percentage 80%
% Let P be your N-by-M input dataset
% Solution-1 (need Statistics & ML Toolbox)
cv = cvpartition(size(P,1),'HoldOut',PD);
Ptrain = P(cv.training,:);
Ptest = P(cv.test,:);
Another possible solution:
% Solution-2 (using basic MATLAB function)
N = size(P,1);
idx = randperm(N);
Ptrain = P(idx(1:round(N*PD)),:);
Ptest = P(idx(round(N*PD)+1:end),:);
Munshida P
el 14 de En. de 2020
This will help you.
[training,test] = partition(faceDatabase,[0.8 0.2]);
0 comentarios
Ver también
Categorías
Más información sobre Get Started with Statistics and Machine Learning Toolbox en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!