Consistent Confusion Matrix Size
조회 수: 19 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
답변 (1개)
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);
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Parallel and Cloud에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!