Split a data in random partitions
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Sophia Nador
el 27 de Nov. de 2020
Respondida: KSSV
el 27 de Nov. de 2020
Hi,
I'm trying to split my data in random partition.
I have a code of this type :
rng(1000)
cv = cvpartition(size(my_data,1),'HoldOut',0.4);
idx = cv.test;
dataTrain = split(~idx,:);
dataTest = split (idx,:);
The problem is that it provides me dataTrain as a (0x12)table instead of (1200x12)table.
How can I fix this problem ?
0 comentarios
Respuesta aceptada
KSSV
el 27 de Nov. de 2020
A = rand(100,2) ;
n = size(A,1) ;
% Get 70% of data random from A
m = round(0.7*n) ;
% Randomize the data
idx = randperm(n) ;
% Training data
P = A(idx(1:m),:) ;
% Testing
T = A(idx(m+1:end),:) ;
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Statistics and Machine Learning Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!