Consistent Confusion Matrix Size

16 ビュー (過去 30 日間)
Andrew Dai
Andrew Dai 2016 年 7 月 11 日
回答済み: Image Analyst 2016 年 7 月 11 日
Hi, so I'm currently training a machine learning model in MATLAB with cross-validation using TreeBagger, and am outputting confusion matrices with confusionmat.
I have a total of 6 labels and 30 subjects -- across each cross-validation trial, sometimes the output prediction labels do not include all 6 labels since not all the subjects' data has activity corresponding to all 6 labels. This makes the resulting confusion matrices range in size from 2x2 to 6x6.
I was wondering if there was a way to keep the confusion matrices as a 6x6 across all trials? Then 0's would just represent the missing data and labels, instead of the confusion matrix eliminating the corresponding rows/columns outright. I'm trying to average the confusion matrix results across all the trials.
Right now I'm attempting to just pad the pre-existing matrices with zeros when applicable, but I'm having a difficult time coding in all the possible permutations and switches that would need to occur.
Thanks in advance

回答 (1 件)

Image Analyst
Image Analyst 2016 年 7 月 11 日
Just figure out what class numbers the classes you go refer to and add the confusion matrix you got to your master, standard 6-by-6 confusion matrix. For example if you got a 2x2 array and you know that those two classes would have really been class #3 and class #5 if you would have had the full 6 classes present, then just do
masterCM(3,3) = masterCM(3,3) + thisCM(1,1);
masterCM(5,5) = masterCM(5,5) + thisCM(2,2);
masterCM(3,5) = masterCM(3,5) + thisCM(1,2);
masterCM(5,3) = masterCM(5,3) + thisCM(2,1);

カテゴリ

Help Center および File ExchangeParallel and Cloud についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by