How to use the several average of same class
1 回表示 (過去 30 日間)
古いコメントを表示
Hello.
I have a data (90 x 2857), column 2857 is a label(class).
I want to select 5 rows of the same classes randomly and compute the mean of each 5 rows.
(10 Combination 5)
So I want to get all possible combinations' average values of the same classes.
In this code, I computed all rows of the same class and got one average value.
Could you explain how to fix the code?
data = csvread('outfile.csv');
values = data(:,1:end-1);
labels = data(:,end);
avg = splitapply(@(x) {mean(x,1)}, values, labels+1);
0 件のコメント
採用された回答
David Hill
2020 年 4 月 5 日
a=randi(size(values,1),5,1);%randomly choose 5 rows
avg=mean(values(a,:),2);%compute mean of the rows
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!