1function [CC]=getclassifier(d,c, Mode)
2% GETCLASSIFIER yields the classifier from labeled data
3%   CC = getclassifier(d,c)
4%   CC = getclassifier(d1,d2)
5%
6% d     DATA
7% c     CLASSLABEL
8% d1    DATA of class 1
9% d2    DATA of class 0
10% Mode	'LDA' and 'MDA' implemented.
11%
12% number of rows in d and c must fit, and C must be a column vector,
13% OR number of columns in d1 and d2 must fit.
14% The functions COVM.M and SUMSKIPNAN.M from the NaN-toolbox are
15% required [1] for Mode 'LDA' and 'MDA'.
16%
17% OUTPUT:
18%   CC 	classifier
19%
20% see also: LDBC, LLBC, MDBC, NaN/COVM
21%
22% Reference(s):
23% [1] A. Schloegl, Missing values and NaN-toolbox for Matlab, 2000-2003.
24% http://www.dpmi.tu-graz.ac.at/~schloegl/matlab/NaN/
25
26%	Copyright (C) 1999-2003 by Alois Schloegl <alois.schloegl@gmail.com>
27
28
29% This program is free software; you can redistribute it and/or
30% modify it under the terms of the GNU General Public License
31% as published by the Free Software Foundation; either version 2
32% of the  License, or (at your option) any later version.
33%
34% This program is distributed in the hope that it will be useful,
35% but WITHOUT ANY WARRANTY; without even the implied warranty of
36% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
37% GNU General Public License for more details.
38%
39% You should have received a copy of the GNU General Public License
40% along with this program; if not, write to the Free Software
41% Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
42
43if nargin<3,
44        Mode = 'LDA';
45end;
46
47if exist('covm')~=2,
48        fprintf(2,'Error GETCLASSIFIER: COVM.M is not in search path. You need to install the NaN-toolbox./n')
49        return;
50end;
51
52if (size(d,1)==size(c,1)) & size(c,2)==1 & all(c==round(c));
53
54elseif (size(d,2)==size(c,2)) ;
55        d1 = d; d2 = c;
56        c  = [ones(size(d1,1),1); ones(size(d2,1),1)*2];
57        d  = [d1; d2];
58else
59        fprintf(2,'Error GETCLASSIFIER: incorrect input arguments\n');
60        return;
61
62end;
63
64CL = sort(unique(c(~isnan(c))));
65
66if strcmp(Mode,'LDA') | strcmp(Mode,'MDA'),
67        for k = 1:length(CL);
68                CC{k} = covm(d(c==CL(k),:),'E');
69        end;
70else
71        fprintf(2,'Error GETCLASSIFIER: classifier %s not implemented.\n');
72        return;
73end;
74
75