Categories &

Functions List

Function Reference: confusionmat

statistics: C = confusionmat (group, grouphat)
statistics: C = confusionmat (group, grouphat, "Order", grouporder)
statistics: [C, order] = confusionmat (group, grouphat)

Compute a confusion matrix for classification problems

confusionmat returns the confusion matrix C for the group of actual values group and the group of predicted values grouphat. The row indices of the confusion matrix represent actual values, while the column indices represent predicted values. The indices are the same for both actual and predicted values, so the confusion matrix is a square matrix. Each element of the matrix represents the number of matches between a given actual value (row index) and a given predicted value (column index), hence correct matches lie on the main diagonal of the matrix. The order of the rows and columns is returned in order.

group and grouphat must have the same number of observations and the same data type. Valid data types are numeric vectors, logical vectors, character arrays, string arrays (not implemented yet), cell arrays of strings.

The order of the rows and columns can be specified by setting the grouporder variable. The data type of grouporder must be the same of group and grouphat.

MATLAB compatibility: Octave misses string arrays and categorical vectors.

See also: crosstab

Source Code: confusionmat