Accelerating the pace of engineering and science

# Documentation Center

• Trial Software
• Product Updates

# confusion

Classification confusion matrix

## Syntax

[c,cm,ind,per] = confusion(targets,outputs)

## Description

[c,cm,ind,per] = confusion(targets,outputs) takes these values:

 targets S-by-Q matrix, where each column vector contains a single 1 value, with all other elements 0. The index of the 1 indicates which of S categories that vector represents. outputs S-by-Q matrix, where each column contains values in the range [0,1]. The index of the largest element in the column indicates which of S categories that vector represents.

and returns these values:

 c Confusion value = fraction of samples misclassified cm S-by-S confusion matrix, where cm(i,j) is the number of samples whose target is the ith class that was classified as j ind S-by-S cell array, where ind{i,j} contains the indices of samples with the ith target class, but jth output class per S-by-4 matrix, where each row summarizes four percentages associated with the ith class:```per(i,1) false negative rate = (false negatives)/(all output negatives) per(i,2) false positive rate = (false positives)/(all output positives) per(i,3) true positive rate = (true positives)/(all output positives) per(i,4) true negative rate = (true negatives)/(all output negatives)```

[c,cm,ind,per] = confusion(TARGETS,OUTPUTS) takes these values:

 targets 1-by-Q vector of 1/0 values representing membership outputs S-by-Q matrix, of value in [0,1] interval, where values greater than or equal to 0.5 indicate class membership

and returns these values:

 c Confusion value = fraction of samples misclassified cm 2-by-2 confusion matrix ind 2-by-2 cell array, where ind{i,j} contains the indices of samples whose target is 1 versus 0, and whose output was greater than or equal to 0.5 versus less than 0.5 per 2-by-4 matrix where each ith row represents the percentage of false negatives, false positives, true positives, and true negatives for the class and out-of-class

## Examples

```[x,t] = simpleclass_dataset;
net = patternnet(10);
net = train(net,x,t);
y = net(x);
[c,cm,ind,per] = confusion(t,y)```

## See Also

Was this topic helpful?