HOME Feature labels Dataset details Image handlingClassification matrix

Classification matrix

The classification matrix is the result of classifying a dataset (e.g. a test set) by some classifier. For every object the some confidence or similarity to each of the classes is stored. The larger the value the more likely the corresponding class. So in case of m objects and c classes the classification matrix has a size of m*c.

PRTools stores a classification matrix into a dataset. Most of the fields of the input dataset are copied. The data field is replaced by the classification matrix, consequently is has c columns ('features', but in fact the class confidence). As feature labels the class names stored in the classifier are used. Routines for assigning objects to classes, see again the section on classifier, usually take the class for which the object entry in the classification matrix has the highest value.

It is important to realize that a dataset in which a classification matrix is stored has two sets of labels: the original object labels (if given) for the objects stored in the rows (these are usually the true object labels) and the class names stored as feature labels for the columns which are used to estimate the classes of the objects. Here is an example using the wine dataset in prdatasets which has three classes.

    a = wine
%       Wine recognition data, 178 by 13 dataset with 3 classes: [59  71  48]
    [trainset,testset] = gendat(a,0.95)  % split a small testset
%       Wine recognition data, 171 by 13 dataset with 3 classes: [57  68  46]
%       Wine recognition data, 7 by 13 dataset with 3 classes: [2  3  2]
    w = ldc(trainset)   % simple linear classifier
%       Bayes-Normal-1, 13 to 3 trained  mapping   --> normal_map
    getlablist(trainset)% get the class names in the training set
%       cultivar 1
%       cultivar 2
%       cultivar 3
    getlabels(w)        % get the class names in the classifier
%       cultivar 1
%       cultivar 2
%       cultivar 3
    d = map(testset,w)  % compute classification matrix for test set
%       Wine recognition data, 7 by 3 dataset with 3 classes: [2  3  2]
    getfeatlab(d)       % get the class names stored as feature labels
%       cultivar 1
%       cultivar 2
%       cultivar 3
    +d                  % show the classification matrix
      1.0e-006 *

    0.0123    0.0057    0.0000
    0.1303    0.0001    0.0000
    0.0000    0.1903    0.0000
    0.0000    0.0000    0.0000
    0.0000    0.0223    0.0000
    0.0000    0.0000    0.0764
    0.0000    0.0000    0.0078

R.P.W. Duin, January 28, 2013


HOME Feature labels Dataset details Image handlingClassification matrix