how can I separate data randomly ?

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

回答 (2 件)

the cyclist
the cyclist 2015 年 4 月 29 日

1 投票

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,:);

1 件のコメント

felipe gonzalez
felipe gonzalez 2015 年 4 月 29 日
nice bro!!! tnksss :)

サインインしてコメントする。

Neil Caithness
Neil Caithness 2015 年 4 月 29 日

1 投票

Make a random permutation vector.
k = randperm(size(data,1));
then
dados_treinamento = data (k(1: 100), :)
dados_teste = data (k(101: end), :)

2 件のコメント

felipe gonzalez
felipe gonzalez 2015 年 4 月 29 日
tnkss bro!!!! :)
Salih Okur
Salih Okur 2022 年 8 月 5 日
it works perfect. thanks alot

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeDevelop Apps Using App Designer についてさらに検索

タグ

質問済み:

2015 年 4 月 29 日

コメント済み:

2022 年 8 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by