source: distools/pe_parzenc.m @ 88

Last change on this file since 88 was 79, checked in by bduin, 11 years ago
File size: 1.6 KB
RevLine 
[10]1%PE_PARZENC Parzen Classifier for PE spaces
2%
3%   [W,H,E] = PE_PARZENC(A,H)
4%   [W,H,E] = PE_PARZENC(A)
5%
6% INPUT
7%   A  PE dataset
8%   H  Smoothing parameter (optional; default: H is optimized
9%      with respect to the leave-one-out error on A)
10%
11% OUTPUT
12%   W  Parzen classifier
13%   H  Number of the nearest neighbors used
14%   E  The leave-one-out error
15%
16% DESCRIPTION 
17% Computation of the Parzen classifier for the PE dataset A.
18%
19% Warning: class prior probabilities in A are neglected.
20%
21% SEE ALSO
22% MAPPINGS, DATASETS, PARZENC, PARZENDDC
23
24% R.P.W. Duin, r.p.w.duin@prtools.org
25% Faculty EWI, Delft University of Technology
26% P.O. Box 5031, 2600 GA Delft, The Netherlands
27
28function [w,h,e] = pe_parzenc(a,h)
29
30  if nargin < 2, h = []; end
31
32  if nargin == 0 | isempty(a)
[79]33    w = prmapping(mfilename,'untrained',{h});
[10]34    w = setname(w,'PE Parzen Classifier');
35   
36  elseif ~ismapping(h) % training
37   
38    if ~ispe_dataset(a)
39      [w,h] = parzenc(a,h);
40    else
41      if isempty(h)             % optimize h for PE space
42        d = sqrt(pe_distm(a));  % find PE distances
43        [v,h] = parzenddc(d,h); % use dis mat routine for optimisation h
44      end
45      if nargout > 2
46        e = testpd(sqrt(pe_distm(a)),h,'loo');
47      end
[79]48      w = prmapping(mfilename,'trained',{a,h},getlablist(a),size(a,2),getsize(a,3));
[10]49    end
50   
51  else % execution, testset is in a, trained mapping is in h
52   
53    %retrieve data
54    trainset = getdata(h,1);
55    h = getdata(h,2);
56   
57    d = sqrt(pe_distm(a,trainset));
58    [e,w] = testpd(d,h);         % confidences in w
59   
60  end
61   
62return
Note: See TracBrowser for help on using the repository browser.