annotate extra/NaN/test/test_xval.m @ 12583:21f4d96c4959 octave-forge

[nan] modify tests
author schloegl
date Fri, 03 Apr 2015 19:24:06 +0000
parents 41f92a4ada86
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6530
7e9aed1ac687 add test routines for some functions of NaN-toolbox
schloegl
parents:
diff changeset
1 % test_classifier;
7e9aed1ac687 add test routines for some functions of NaN-toolbox
schloegl
parents:
diff changeset
2
7e9aed1ac687 add test routines for some functions of NaN-toolbox
schloegl
parents:
diff changeset
3 % $Id$
8037
6a419bec96bb update contact e-mail and www address
schloegl
parents: 6787
diff changeset
4 % Copyright (C) 2010 by Alois Schloegl <alois.schloegl@gmail.com>
6530
7e9aed1ac687 add test routines for some functions of NaN-toolbox
schloegl
parents:
diff changeset
5 % This function is part of the NaN-toolbox
8037
6a419bec96bb update contact e-mail and www address
schloegl
parents: 6787
diff changeset
6 % http://pub.ist.ac.at/~schloegl/matlab/NaN/
6530
7e9aed1ac687 add test routines for some functions of NaN-toolbox
schloegl
parents:
diff changeset
7
7e9aed1ac687 add test routines for some functions of NaN-toolbox
schloegl
parents:
diff changeset
8 % This program is free software; you can redistribute it and/or
7e9aed1ac687 add test routines for some functions of NaN-toolbox
schloegl
parents:
diff changeset
9 % modify it under the terms of the GNU General Public License
7e9aed1ac687 add test routines for some functions of NaN-toolbox
schloegl
parents:
diff changeset
10 % as published by the Free Software Foundation; either version 3
7e9aed1ac687 add test routines for some functions of NaN-toolbox
schloegl
parents:
diff changeset
11 % of the License, or (at your option) any later version.
7e9aed1ac687 add test routines for some functions of NaN-toolbox
schloegl
parents:
diff changeset
12 %
7e9aed1ac687 add test routines for some functions of NaN-toolbox
schloegl
parents:
diff changeset
13 % This program is distributed in the hope that it will be useful,
7e9aed1ac687 add test routines for some functions of NaN-toolbox
schloegl
parents:
diff changeset
14 % but WITHOUT ANY WARRANTY; without even the implied warranty of
7e9aed1ac687 add test routines for some functions of NaN-toolbox
schloegl
parents:
diff changeset
15 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7e9aed1ac687 add test routines for some functions of NaN-toolbox
schloegl
parents:
diff changeset
16 % GNU General Public License for more details.
7e9aed1ac687 add test routines for some functions of NaN-toolbox
schloegl
parents:
diff changeset
17 %
7e9aed1ac687 add test routines for some functions of NaN-toolbox
schloegl
parents:
diff changeset
18 % You should have received a copy of the GNU General Public License
7e9aed1ac687 add test routines for some functions of NaN-toolbox
schloegl
parents:
diff changeset
19 % along with this program; if not, write to the Free Software
8165
41f92a4ada86 Updated FSF address
carandraug
parents: 8037
diff changeset
20 % Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
6530
7e9aed1ac687 add test routines for some functions of NaN-toolbox
schloegl
parents:
diff changeset
21
7e9aed1ac687 add test routines for some functions of NaN-toolbox
schloegl
parents:
diff changeset
22
6541
4bec4452a4b9 {-1,+1} encoding of classlabel supported; test of liblinear and libSVM with Octave3.2
schloegl
parents: 6530
diff changeset
23 if 1,
6530
7e9aed1ac687 add test routines for some functions of NaN-toolbox
schloegl
parents:
diff changeset
24 clear
6787
64a859a65534 update website, svn keywords, prepare for next release
schloegl
parents: 6543
diff changeset
25 N=100; % number of samples
64a859a65534 update website, svn keywords, prepare for next release
schloegl
parents: 6543
diff changeset
26 M=10; % number of features
64a859a65534 update website, svn keywords, prepare for next release
schloegl
parents: 6543
diff changeset
27 classifier= {'SVM:LIB','REG','MDA','MD2','QDA','QDA2','LD2','LD3','LD4','LD5','LD6','NBC','aNBC','WienerHopf','LDA/GSVD','MDA/GSVD', 'LDA/sparse','MDA/sparse', 'PLA', 'LMS','LDA/DELETION','MDA/DELETION','NBC/DELETION','RDA/DELETION','REG/DELETION','RDA','GDBC','SVM','RBF','PSVM','SVM11','SVM:LIN4','SVM:LIN0','SVM:LIN1','SVM:LIN2','SVM:LIN3','WINNOW'};
12583
21f4d96c4959 [nan] modify tests
schloegl
parents: 8165
diff changeset
28 %classifier= {'SVM:RBF'};
6530
7e9aed1ac687 add test routines for some functions of NaN-toolbox
schloegl
parents:
diff changeset
29
6787
64a859a65534 update website, svn keywords, prepare for next release
schloegl
parents: 6543
diff changeset
30 x = randn(N,M); % data
64a859a65534 update website, svn keywords, prepare for next release
schloegl
parents: 6543
diff changeset
31 c = ([1:N]'>(N/2))+1; % classlabel
6530
7e9aed1ac687 add test routines for some functions of NaN-toolbox
schloegl
parents:
diff changeset
32 %w = [ones(1,N/2)/5,ones(1,N/10),zeros(1,4*N/10)];
6787
64a859a65534 update website, svn keywords, prepare for next release
schloegl
parents: 6543
diff changeset
33 w = []; % no weightening
6530
7e9aed1ac687 add test routines for some functions of NaN-toolbox
schloegl
parents:
diff changeset
34
7e9aed1ac687 add test routines for some functions of NaN-toolbox
schloegl
parents:
diff changeset
35 x = randn(N,M);
7e9aed1ac687 add test routines for some functions of NaN-toolbox
schloegl
parents:
diff changeset
36 x = x+c*ones(1,M);
7e9aed1ac687 add test routines for some functions of NaN-toolbox
schloegl
parents:
diff changeset
37
6787
64a859a65534 update website, svn keywords, prepare for next release
schloegl
parents: 6543
diff changeset
38 if 1,
6541
4bec4452a4b9 {-1,+1} encoding of classlabel supported; test of liblinear and libSVM with Octave3.2
schloegl
parents: 6530
diff changeset
39 %x(2:2:N/2,2) = NaN;
4bec4452a4b9 {-1,+1} encoding of classlabel supported; test of liblinear and libSVM with Octave3.2
schloegl
parents: 6530
diff changeset
40 x(2:2:N,2) = NaN;
6530
7e9aed1ac687 add test routines for some functions of NaN-toolbox
schloegl
parents:
diff changeset
41 x(3,2:2:end) = NaN;
6541
4bec4452a4b9 {-1,+1} encoding of classlabel supported; test of liblinear and libSVM with Octave3.2
schloegl
parents: 6530
diff changeset
42 end;
6787
64a859a65534 update website, svn keywords, prepare for next release
schloegl
parents: 6543
diff changeset
43 end;
6530
7e9aed1ac687 add test routines for some functions of NaN-toolbox
schloegl
parents:
diff changeset
44
6543
ce8e73d81297 remove temporary changes
schloegl
parents: 6541
diff changeset
45 for k = 1:length(classifier);
ce8e73d81297 remove temporary changes
schloegl
parents: 6541
diff changeset
46 try,
6541
4bec4452a4b9 {-1,+1} encoding of classlabel supported; test of liblinear and libSVM with Octave3.2
schloegl
parents: 6530
diff changeset
47 [R{k},CC{k}] = xval(x, {c,w}, classifier{k});
6787
64a859a65534 update website, svn keywords, prepare for next release
schloegl
parents: 6543
diff changeset
48 fprintf(1,'%8s\t%i\t%5.2f\t%5.2f+-%5.2f\n',classifier{k},sum(R{k}.data(:)),R{k}.ACC*100,R{k}.kappa,R{k}.kappa_se);
64a859a65534 update website, svn keywords, prepare for next release
schloegl
parents: 6543
diff changeset
49 save -v6 debug.mat
6543
ce8e73d81297 remove temporary changes
schloegl
parents: 6541
diff changeset
50 catch,
ce8e73d81297 remove temporary changes
schloegl
parents: 6541
diff changeset
51 R{k} = [];
ce8e73d81297 remove temporary changes
schloegl
parents: 6541
diff changeset
52 end;
6530
7e9aed1ac687 add test routines for some functions of NaN-toolbox
schloegl
parents:
diff changeset
53 end;
7e9aed1ac687 add test routines for some functions of NaN-toolbox
schloegl
parents:
diff changeset
54
7e9aed1ac687 add test routines for some functions of NaN-toolbox
schloegl
parents:
diff changeset
55 for k = 1:length(R)
7e9aed1ac687 add test routines for some functions of NaN-toolbox
schloegl
parents:
diff changeset
56 if isempty(R{k})
7e9aed1ac687 add test routines for some functions of NaN-toolbox
schloegl
parents:
diff changeset
57 fprintf(1,'%8s \t failed\n',classifier{k});
7e9aed1ac687 add test routines for some functions of NaN-toolbox
schloegl
parents:
diff changeset
58 else
7e9aed1ac687 add test routines for some functions of NaN-toolbox
schloegl
parents:
diff changeset
59 fprintf(1,'%8s\t%i\t%5.2f\t%5.2f+-%5.2f\n',classifier{k},sum(R{k}.data(:)),R{k}.ACC*100,R{k}.kappa,R{k}.kappa_se);
7e9aed1ac687 add test routines for some functions of NaN-toolbox
schloegl
parents:
diff changeset
60 end;
7e9aed1ac687 add test routines for some functions of NaN-toolbox
schloegl
parents:
diff changeset
61 end
7e9aed1ac687 add test routines for some functions of NaN-toolbox
schloegl
parents:
diff changeset
62