DisTools introductory example, dissimilarity matrix analysis

Get rid of old figures. Take a dataset (other examples are kimia_shapes, chickens and protein) and have a look at a part of the dataset. Is it symmetric? Is the diagonal zero?

delfigs
A = catcortex
+A(1:8,1:8)

Display the matrix as an image

imagesc(+A)

Display a scatter of the first two columns, i.e. the dissimilarities with the first two objects

figure;
scatterd(A(:,[1 2]))

Some properties of the dissimilarity matrix like the leave-one-out (LOO) nearest neighbor error, the asymmetry, the intrinsic dimension and the fraction of triplets that don’t fulfill the triangle inequality can be computed and listed like:

A*[nne, asymmetry, intrdim, nmf]

Compute a learning curve for the nearest neigbor error. This routine (nnerror1) computes the expected error for a randomly selected training set of a specific size (horizontal axis):

figure;
plote(A*nnerror1)
title('1NN Learning Curve-1')

Compute another  learning curve for the nearest neigbor error. This routine (nnerror2) computes the expected error for a randomly selected training set of the same number of objects for every class (horizontal axis):

figure;
plote(A*nnerror2)
title('1NN Learning Curve-2')

Distribute figures over the screen

showfigs

Split the dataset 50-50 for training and testing. Use the given dissimilarities for the kNN classifier knndc and the Parzen classifier parzenddc. Both don’t work in a space but are applied on the given dissimilarities. Note that knndc automatically optimizes k and parzenddc automatically optimizes the kernel (also called smoothing parameter). As an experiment we also try the averaged dissimilarity in the training set AT as an estimate.

[AT,AS] = gendat(A,0.5);
AT = setname(gendatb,'TrainSet')
AS = setname(gendatb,'TestSet')
W1 = AT*knnc;
W2 = AT*parzendc;
W3 = AT*parzendc([],mean(mean(+AT)));
W3 = setname(W3,'ParzenD-h');
testc({AT,AS},{W1,W2,W3})

Try yourself some other values for the kernel width, e.g. by:

testc({AT,AS},parzendc(AT,0.5))

Return to DisTools Introductory Examples Continue with next DisTools Example
Print Friendly, PDF & Email