Plot classification confusion matrix




plotconfusion(targets,outputs) takes target and output data and generates a confusion plot. The target data are ground truth labels in 1-of-N form (in each column, a single element is 1 to indicate the correct class, and all other elements are 0). The output data are the outputs from a neural network that performs classification. They can either be in 1-of-N form, or may also be probabilities where each column sums to 1.

plotconfusion(targets1,outputs1,'name1',targets2,outputs2,'name2',...) generates several confusion plots in one figure, and prefixes the character strings specified by the 'name' arguments to the titles of the appropriate plots.

On the confusion matrix plot, the rows show the predicted class, and the columns show the true class. The diagonal cells show where the true class and predicted class match. The off diagonal cells show instances where the classifier has made mistakes. The column on the right hand side of the plot shows the accuracy for each predicted class, while the row at the bottom of the plot shows the accuracy for each true class. The cell in the bottom right of the plot shows the overall accuracy.


This example shows how to train a pattern recognition network and plot its accuracy.

[x,t] = simpleclass_dataset;
net = patternnet(10);
net = train(net,x,t);
y = net(x);

Was this topic helpful?