Construct confusion matrix
[C,NE,LABLIST1,LABLIST2] = CONFMAT(LAB1,LAB2,METHOD,FID)
Constructs a confusion matrix C between two sets of labels LAB1 (corresponding to the rows in C) and LAB2 (the columns in C). The order of the rows and columns is returned in LABLIST. NE is the total number of errors (sum of non-diagonal elements in C).
If METHOD = 'count' (default), co-occurences in LAB1 and LAB2 are counted and returned in C. For METHOD = 'disagreement', the relative disagreement is returned in NE, and is split over all combinations of labels in C (such that the rows sum to 1). (The total disagreement for a class equals one minus the sensitivity for that class as computed by TESTC). For METHOD = 'ids' a cell array C is returned in which C(i,j) contains the indices of the objects for which LAB1 equals LABLIST1(i,:) and LAB2 equals LABLIST2(j,:).
[C,NE,LABLIST] = CONFMAT(D,METHOD)
If D is a classification result D = A*W, the labels LAB1 and LAB2 are internally retrieved by CONFMAT before computing the confusion matrix.
C = CONFMAT(D)
This call also applies in case in D = A*W the dataset A has soft labels W is trained by a soft labeld classifier.
When no output argument is specified, or when FID is given, the confusion matrix is displayed or written a to a text file. It is assumed that LAB1 contains true labels and LAB2 stores estimated labels.
Typical use of CONFMAT is the comparison of true and and estimated labels