how can I separate data randomly ?

2 visualizaciones (últimos 30 días)
felipe gonzalez
felipe gonzalez el 29 de Abr. de 2015
Comentada: Salih Okur el 5 de Ag. de 2022
hi
well ... I have a dimension data matrix 445x52, I need to randomly separated into two subsets such data, training daods and test data. which basically have to do is:
dados_treinamento = Data (1: 100, :)
dados_teste = data (101: end, :)
just as the example but in a random way, how can I do this using some function of matlab?
any help is welcome

Respuestas (2)

the cyclist
the cyclist el 29 de Abr. de 2015
There are many ways to accomplish this in MATLAB. Here is one:
% Here are some pretend data
data = rand(445,52);
% Create a randomly ordered vector of indices, then use
% that vector to separate into two groups
idx = randperm(445);
indexToGroup1 = (idx<=100);
indexToGroup2 = (idx>100);
group1 = data(indexToGroup1,:);
group2 = data(indexToGroup2,:);

Neil Caithness
Neil Caithness el 29 de Abr. de 2015
Make a random permutation vector.
k = randperm(size(data,1));
then
dados_treinamento = data (k(1: 100), :)
dados_teste = data (k(101: end), :)
  2 comentarios
felipe gonzalez
felipe gonzalez el 29 de Abr. de 2015
tnkss bro!!!! :)
Salih Okur
Salih Okur el 5 de Ag. de 2022
it works perfect. thanks alot

Iniciar sesión para comentar.

Categorías

Más información sobre Descriptive Statistics en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by