source: distools/disrc.m @ 41

Last change on this file since 41 was 10, checked in by bduin, 14 years ago
File size: 2.1 KB
RevLine 
[10]1%DISRC Dissimilarity based classifier by distance ranking
2%
3%       W = disrc(A)
4%       W = A*disrc
5%
6% A should be a dissimilarity based dataset with class labels as
7% feature labels. The classifier W is based on distance ranking.
8% A new dataset B defined by dissimilarities to the same representation
9% set A is classified by D = B*W by comparing the dissimilarities in B
10% with the ranked dissimilarities in A for each object in the
11% representation set separately. The columns in D yield for each
12% object in the representation set a distance such that D*classc
13% generates for these objects the ranked based probabilities.
14%
15% Formally W is a set of parallel mappings, so B*W*classd combines
16% them by assigning objects to the class with the highest probability.
17% Other combiners may be used as well, e.g. B*W*classc*prodc,
18% combining all probabilities by the product rule.
19%
20% See mappings, classc, classd.
21%
22% $Id: disrc.m,v 1.2 2001/07/10 16:35:58 pavel Exp $
23
24% Copyright: R.P.W. Duin, duin@ph.tn.tudelft.nl
25% Faculty of Applied Physics, Delft University of Technology
26% P.O. Box 5046, 2600 GA Delft, The Netherlands
27
28function w = disrc(a,v)
29
30if nargin < 1 | isempty(a) % empty call (untrained classifier)
31        w = mapping('disrc');
32               
33elseif nargin == 1    % training
34        [nlab,lablist,m,k,c,p] = dataset(a);
35        [nn,nf,fl] = renumlab(lablist,getfeat(a));
36        if c < 2
37                error('Dataset should containf more than one class')
38        end
39        if max(nf) > c
40                error('Feature labels of dataset do not match with class labels')
41        end
42        w = [];
43        for j = 1:k
44                b = {+a(find(nlab==nf(j)),j) +a(find(nlab~=nf(j)),j)};
45                w = [w; mapping('disrc',b,fl(nf(j),:),1,1,1)];
46        end
47
48%       w = cnormc(w,a); forget normalisation and apriori probs for the moment
49
50elseif nargin == 2      % evaluation
51        [m,k] = size(a);
52        b = +v; b1 = b{1}; b2 = b{2};
53        n1 = length(b1); n2 = length(b2);
54        w1 = zeros(m,1); w2 = zeros(m,1);
55        [d R1] = sort([b1;+a]);
56        [d R2] = sort([b2;+a]);
57        L1 = find(R1>n1);
58        L2 = find(R2>n2);
59        w1(R1(L1)-n1) = (n1+2-(L1-[1:m]'))/(n1+2);
60        w2(R2(L2)-n2) = (n2+2-(L2-[1:m]'))/(n2+2);
61%       disp([w1;w2])
62        w = invsig(dataset((w1+w2)/2,getlab(a),getfeat(v)));
63else
64        error('Illegal call')
65end
66
Note: See TracBrowser for help on using the repository browser.