PRTools examples: Mappings
Mappings are with datasets a key element of PRTools. It is assumed that the reader is familiar with the introductory sections of the user guide:
The basic idea of a mapping is that it transforms the representation of objects from on space to another. This can be from a higher dimensional vector space to a lower one, but also the reverse. Vector spaces might also be given another scaling or being rotated. A set of objects might also given in a non-vectorial domain, e.g. images of different sizes, a set of graphs or a set of strings in a datafile. Also these might be transformed by a mapping. In the following examples we assume the availability of
prdatfiles. Add them to the Matlab path or give the fiollowing commands to create their directories:
Observe the feature sizes of the datasets as a result of the fixed mapping
featsel: feature selection
A = sonar % 60 dimensional dataset
featsel(A,[2 4 10]) % 3 dimensional dataset
B = A(:,[2,4,10])
% 3 dimensional dataset
A simple rescaling of the features of a dataset by a sigmoid:
The fixed mapping affine is applied in many routines. It just linearly rotates and shifts data
The data is rotated over 45 degrees and the origin is shifted to
A = kimia
B = selclass(A,[7 11])
C = B*im_unif(,11)
C = B*im_resize(,[8 8]) %
samplingto 64 pixels
C = B*
im_resize(,[8 8],'cubic') % interpolation to 64 pixels
- repeat the above experiment for the the
kimia_imagesdatafile. Look what happens to the images sizes in the figures.
- Consider the entire kimia dataset. Use
testk(A,1)to see its nearest neighbor error. What happens to the error if the images are reduced to 32*32, 16*16, 8*8 and 4*4? How does this depend on the interpolation method?
Trainable mappings optimize the mapping for a training set. There are always two steps:
- Train the untrained version of the mapping by a training set
- Apply the trained mapping to the same or new data.
Feature extraction and classification are well known examples. Here is the famous eigenface examples
A = faces
W = A*pcam(,20); % compute first 20 eigenfaces
B = A*W; % apply the mapping to the same data
Are the eigenfaces the best ones? Test it yourself by the following exercise,
testk(B(:,1:n),1)to find the classification error for
n = 1:20
- Rank the 20 features by the trainable mapping
V = B*featself(,,20)
- Inspect the feature ranking by
- Reorder the features by
C = B*V
testk(C(:,1:n),1)to find the classification error for
n = 1:20
- What is wrong?
Another interesting experiment is
- Plot the scatterplot for the first two eigenfaces
- Plot the scatterplot for the first two Fisher faces (use
- Explain the differences
cells and doubles
operations: datasets datafiles cells and doubles mappings classifiers stacked parallel sequential dyadic.
user commands: datasets representation classifiers evaluation clustering examples support routines.
introductory examples: Introduction Scatterplots Datasets Datafiles Mappings Classifiers Evaluation Learning curves Feature curves Dimension reduction Combining classifiers Dissimilarities.