split data into 5 train and test data

5 ビュー (過去 30 日間)
redha wassim brahimi
redha wassim brahimi 2022 年 5 月 21 日
Hello , i'm trying to split my data that has 392 row and 9 colums into 5 train and test datas to do a cross validation on an ANFIS
since i just want to do it on my dataset i thought about creating
traindata1= the rows from 1 to 312 and testdata1 = from 312 to 392
traindata 2 = rows from .....
is there any function to do it automatically , if no how to copy a certain number of rows to a table ?

採用された回答

the cyclist
the cyclist 2022 年 5 月 21 日
You can use the cvpartition function to do this, if you have the Statistics and Machine Learning Toolbox.
If you don't have that toolbox, you might want to use randperm instead of just choosing the first rows for training, and the rest for testing, in case the order of the data in your dataset is not already random.
  3 件のコメント
the cyclist
the cyclist 2022 年 5 月 22 日
You can copy from one matrix to another by indexing in.
M = [ 2 3;
5 7;
11 13;
17 19;
23 29];
M1 = M([1,3],:)
M2 = M([2,4,5],:)
You might want to watch the MATLAB Onramp tutorial for basics like this.
redha wassim brahimi
redha wassim brahimi 2022 年 5 月 22 日
ok thank you

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStatistics and Machine Learning Toolbox についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by