user1431282
user1431282

Reputation: 6845

Confusion About Plotting Confusion Matrix MATLAB

I'm trying to create a confusion matrix:

http://en.wikipedia.org/wiki/Confusion_matrix

So far, I have a list of predicted labels (ex: [1, 2, 4, 5, 1]) and test labels (ex: [1, 2, 5, 6, 1]).

However, I am running into problems creating a plot for the confusion matrix.

I can generate one with

[C,order] = confusionmat(testing_vector, predicted_labels)


C =

         933           0           7           5           3           9          13           2           7           1
           0        1104           5           2           1           1           4           1          16           1
           8           7         885          31          10           3          16          15          55           2
          10           1          25         887           5          31           2          13          22          14
           5           1           9           5         876           2          12           5          19          48
          11           6           8          47          12         719          15          12          50          12
          13           3          12           3           9          26         879           0          12           1
           2          11          17           7           9           1           0         926          12          43
          11          18          11          31          13          48           8          12         799          23
          11           7           5          13          45           5           1          41          31         850


order =

     0
     1
     2
     3
     4
     5
     6
     7
     8
     9

However, when I try to use plotconfusion, I am unsure of what to use for the arguments targets and outputs.

I have tried order as targets and C as outputs but this does not appear to work.

Am I on the right track?

Upvotes: 0

Views: 8995

Answers (1)

lennon310
lennon310

Reputation: 12689

use C = plotConfusion(testing_vector, predicted_labels); The confusionmat is called inside plotConfusion. And output C is a repmat transform of the one generated from confusionmat. See their source code for more details.

Upvotes: 3

Related Questions