1 | %DISEX_PROTSELFD Example of forward prototype selection
|
---|
2 | %
|
---|
3 | % This example shows the use of PROTSELFD for a greedy forward
|
---|
4 | % selection of prototypes from a square dissimilarity matrix in
|
---|
5 | % order to optimize the representation set.
|
---|
6 | %
|
---|
7 | % The final plot shown is a 'feature curve'. This is the error
|
---|
8 | % as a function of the number of features used (here the number
|
---|
9 | % of prototypes). The error measure is the mean classification
|
---|
10 | % error of the 1-NN rule using the given dissimilarities as
|
---|
11 | % distances (KNNDC([],1))
|
---|
12 |
|
---|
13 | d = readchicken(20,45); % read dissimilarity dataset
|
---|
14 | w = protselfd(a); % forward feature selection
|
---|
15 | n = size(w,2); % max number of selected prototypes
|
---|
16 | % random prototype (feature) ranking
|
---|
17 | v = featsel(size(d,2),randperm(n));
|
---|
18 |
|
---|
19 | K = [1 2 3 5 7 10 15 20 30 50 70 100 150 200 300 500 700 1000];
|
---|
20 | K = [K(K<n) n]; % dimensionalities to be checked
|
---|
21 |
|
---|
22 | % In the next step the feature curve is build. Note that features
|
---|
23 | % here are prototypes (representation objects).
|
---|
24 | % knndc([],1) is used for classification, i.e. use the values in d
|
---|
25 | % (or d*w) as distances in the 1-NN rule.
|
---|
26 | % Testd is used for evaluation as it is resistant against missing
|
---|
27 | % classes (classes not available in the representation set).
|
---|
28 | % In 10 repititions 50% of the data is used for training and 50%
|
---|
29 | % for testing. Note that final performances are biased as all data
|
---|
30 | % is used in this example for prototype selection.
|
---|
31 |
|
---|
32 | ew = clevalf(d*w,knndc([],1),K,0.5,10,[],testd);
|
---|
33 | ew.names = 'Forward selection';
|
---|
34 | ev = clevalf(d*v,knndc([],1),K,0.5,10,[],testd);
|
---|
35 | ev.names = 'Random selection';
|
---|
36 | ev.title = getname(d);
|
---|
37 | ev.xlabel = 'Size of Representation Set';
|
---|
38 | plote({ew,ev}) |
---|