Last change
on this file since 105 was
20,
checked in by bduin, 13 years ago
|
updates for handling soft labels
|
File size:
901 bytes
|
Line | |
---|
1 | %NNE Leave-one-out Nearest Neighbor Error on a Dissimilarity Matrix |
---|
2 | % |
---|
3 | % [E,LAB] = NNE(D) |
---|
4 | % |
---|
5 | % INPUT |
---|
6 | % D NxN symmetric dissimilarity dataset |
---|
7 | % |
---|
8 | % OUTPUT |
---|
9 | % E Leave-one-out error |
---|
10 | % LAB Nearest neighbor labels |
---|
11 | % |
---|
12 | % DESCRIPTION |
---|
13 | % Estimates the leave-one-out error of the 1-nearest neighbor rule |
---|
14 | % on the givven symmetric dissimilairy data. |
---|
15 | % |
---|
16 | |
---|
17 | % Copyright: Robert P.W. Duin, r.p.w.duin@prtools.org and |
---|
18 | % Elzbieta Pekalska, ela.pekalska@googlemail.com |
---|
19 | % Faculty EWI, Delft University of Technology and |
---|
20 | % School of Computer Science, University of Manchester |
---|
21 | |
---|
22 | |
---|
23 | function [e,NNlab] = nne(D) |
---|
24 | |
---|
25 | [m,n] = size(D); |
---|
26 | if m ~= n, |
---|
27 | error('Distance matrix should be square.'); |
---|
28 | end |
---|
29 | |
---|
30 | lab = getlab(D); |
---|
31 | [nlab,lablist] = renumlab(lab); |
---|
32 | D(1:m+1:end) = inf; |
---|
33 | [d,M] = min(D'); |
---|
34 | e = mean(nlab(M) ~= nlab); |
---|
35 | if islabtype(D,'crisp') |
---|
36 | NNlab = lablist(nlab(M),:); |
---|
37 | else |
---|
38 | labs = gettargets(D); |
---|
39 | NNlab = labs(M,:); |
---|
40 | end |
---|
41 | return; |
---|
Note: See
TracBrowser
for help on using the repository browser.