Mean of matrices in cell array
Mostrar comentarios más antiguos
I have a 100x40 cell array, each cell contains a 46x2 double, which is the score output from classifiers: knn, treebagger, svm. I am trying to make ROC curves from the scores, but I need to take the mean of the elements in each array. Basically, the 100 is the number of iterations for which I ran my code and the 40 is the number of feature sizes selected. The 46 is the number of test points I used. I need the mean of the score for each sample size. I am relatively new to MATLAB and am not sure where to start. I read through other posts and found some help, but cannot seem to apply it to my issue. The code I tried is:
catscore=mean(cat(2,scorepofknn15{:}),2);
which did not produce the desired result. Any help or suggestions would be greatly appreciated.
Respuestas (1)
Sandra Preaux
el 2 de Oct. de 2018
I'm not sure from your question if you are trying for catscores to be 100x40 or 1x40. So I'll show both. If you want 100x40 (one average for each run of each feature size) then use this loop
xm=zeros(size(scorepofknn));
for ii=1:size(scorepofknn15,1)
for jj=1:size(scorepofknn15,2)
xm(ii,jj)=mean(scorepofknn15{ii,jj});
end
end
If you want to cat all runs for the same feature size together use this loop
xm=zeros(1,size(scorepofknn15,2));
for ii=1:size(scorepofknn15,2)
xm(1,ii)=mean([x{:,ii}]);
end
1 comentario
Ian Loveless
el 2 de Oct. de 2018
Categorías
Más información sobre Classification Ensembles en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!