-1

The code is as follows:

g1 = [1 1 2 2 3 3]';    % Known groups
g2 = [1 1 2 3 4 5]';    % Predicted groups

[C,order] = confusionmat(g1,g2);
figure; imagesc(C);

accuracyAll = trace(C)/sum(C(:));
disp(['Total accuracy is ',num2str(accuracyAll*100),'%']);

When you run the code, you will get a figure. My question is how to add the corresponding accuracy in the blocks of the figure?

Martin S
  • 814
  • 2
  • 11
  • 24
brown wang
  • 13
  • 7
  • `C` is already a confusion matrix. What exactly do you mean by "add the corresponding values"? – rayryeng Feb 28 '17 at 21:17
  • I read that as text labels in the figure @rayryeng – Luis Mendo Feb 28 '17 at 21:17
  • @LuisMendo OK that makes much more sense. I agree with your answer below. – rayryeng Feb 28 '17 at 21:20
  • @rayryeng: This may be a better reference duplicate: [How do I visualize a matrix with colors and values displayed?](http://stackoverflow.com/q/3942892/52738) – gnovice Feb 28 '17 at 21:35
  • @gnovice That's the one I was looking for... I was looking for literally 10 minutes on your list of posts... I had to settle with Amro's because I couldn't find it. I'm going to reopen for you to dupehammer. – rayryeng Feb 28 '17 at 21:35
  • @rayryeng, i modified the question. I thought for each block there is a corresponding accuracy for it. – brown wang Feb 28 '17 at 21:51

1 Answers1

1

Is this what you want?

[ii, jj, vv] = find(C);
text(jj(:), ii(:), num2str(vv(:)))
Luis Mendo
  • 110,752
  • 13
  • 76
  • 147