Skip to content

Commit bd2f7dc

Browse files
committed
Load in files direct from zip.
0 parents  commit bd2f7dc

24 files changed

+3741
-0
lines changed

Contents.m

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
% Support Vector Machine toolbox
2+
% Version 2.51, January 2002
3+
%
4+
% SVM functions:
5+
% svm - create a support vector machine classifier
6+
% svmfwd - forward propagation through svm
7+
% svmkernel - compute svm kernel function
8+
% svmtrain - train a svm using decomposition algorithm
9+
% svmstat - svm statistics
10+
% svmcv - simple parameter selection via cross validation
11+
%
12+
% Extension to multi class case via error correcting output codes (ECOC)
13+
% ecoc - create a ECOC wrapper
14+
% ecocload - load code matrix from archive ecoc-codes.tar.gz
15+
% ecoctrain - train ECOC classifier
16+
% ecocfwd - forward propagation through ECOC classifier
17+
%
18+
% Data files:
19+
% ecoc-codes.tar.gz - Tom Dietterich's collection of code matrices
20+
%
21+
% Files for PRLOQO code:
22+
% loqo.c (C) by Steve Gunn
23+
% pr_loqo.c (C) by Alex Smola
24+
% pr_loqo.h (C) by Alex Smola
25+
%
26+
% Demo programs:
27+
% demsvm1 - demonstrate basic support vector machine classification
28+
% demsvm2 - demonstrate advanced support vector machine features
29+
% demsvm3 - sample code for parameter selection via cross validation
30+
% demecoc1 - solving a simple multi-class problem with SVMs
31+
%
32+
% Copyright (c) Anton Schwaighofer (2002)
33+
% mailto:anton.schwaighofer@gmx.net
34+
%
35+
% This program is released unter the GNU General Public License.
36+
%
37+
38+
%
39+
% $Revision: 1.10 $ $Date: 2002/01/09 12:12:23 $
40+
%
41+
% This program is free software; you can redistribute it and/or
42+
% modify it under the terms of the GNU General Public License
43+
% as published by the Free Software Foundation; either version 2
44+
% of the License, or (at your option) any later version.
45+
%
46+
% This program is distributed in the hope that it will be useful,
47+
% but WITHOUT ANY WARRANTY; without even the implied warranty of
48+
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
49+
% GNU General Public License for more details.
50+
%
51+
% You should have received a copy of the GNU General Public License
52+
% along with this program; if not, write to the Free Software
53+
% Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
54+
%
55+

License.txt

Lines changed: 340 additions & 0 deletions
Large diffs are not rendered by default.

Readme.txt

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
2+
Support Vector Machine toolbox for Matlab
3+
Version 2.51, January 2002
4+
5+
6+
Contents.m contains a brief description of all parts of this toolbox.
7+
8+
Main features are:
9+
10+
- Except for the QP solver, all parts are written in plain Matlab. This
11+
guarantees for easy modification. Special kinds of kernels that require
12+
much computation (such as the Fisher kernel, which is based on a model of
13+
the data) can easily be incorporated.
14+
15+
- Extension to multi-class problems via error correcting output codes is
16+
included.
17+
18+
- Unless many other SVM toolboxes, this one can handle SVMs with 1norm
19+
or 2norm of the slack variables.
20+
21+
- For both cases, a decomposition algorithm is implemented for the training
22+
routine, together with efficient working set selection strategies.
23+
The training algorithm uses many of the ideas proposed by Thorsten
24+
Joachims for his SVMlight. It thus should exhibit a scaling behaviour that
25+
is comparable to SVMlight.
26+
27+
28+
29+
This toolbox optionally makes use of a Matlab wrapper for an interior point
30+
code in LOQO style (Matlab wrapper by Steve Gunn, LOQO code by Alex Smola).
31+
To compile the wrapper, run
32+
mex loqo.c pr_loqo.c
33+
Make sure you have turned on the compiler optimizations in mexopts.sh
34+
The LOQO code can be retrieved from
35+
http://www.kernel-machines.org/code/prloqo.tar.gz
36+
The wrapper comes directly from Steve Gunn.
37+
38+
39+
Copyright (c) Anton Schwaighofer (2001)
40+
mailto:anton.schwaighofer@gmx.net
41+
42+
This program is released unter the GNU General Public License.
43+
See License.txt for details.
44+
45+
Changes in version 2.51:
46+
- fixed bug in SVMTRAIN that prevented correct initialisation with
47+
NET.recompute==Inf
48+
49+
Changes in version 2.5:
50+
- Handling of multi-class problems with ECOC
51+
- NET.recompute is set to Inf by default, thus all training is done
52+
incrementally by default.
53+
- Handling the case of all training examples being -1 or +1 correctly
54+
55+
Changes in version 2.4:
56+
- Better selection of the initial working set
57+
- Added workaround for a (rare) Matlab quadprog bug with badly conditioned
58+
matrices
59+
- There is now a new kernel function 'rbffull' where a full matrix
60+
("covariance matrix") C may be put into an RBF kernel:
61+
K(X1,X2) = exp(-(X1-X2)'*C*(X1-X2))
62+
63+
Changes in version 2.3:
64+
- slightly more compact debug output
65+
66+
Changes in version 2.2:
67+
- New default values for parameter qpsize that make the whole toolbox
68+
*much* faster
69+
- Workaround for a Matlab bug with sparse matrices
70+
- Changed the definition of the RBF-Kernel: from |x-y|^2/(2*nin*param^2)
71+
to |x-y|^2/(nin*param). This means that all parameter settings for old
72+
versions need to be updated!
73+
- A few minor things I can't remember
74+
75+
Changes in version 2.1:
76+
Fixed a nasty bug at the KKT check
77+
78+
Changes in version 2.0:
79+
All relevant routines have been updated to allow the use of a SVM with
80+
2norm of the slack variables (NET.use2norm==1).

code14-11

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
0 0 0 0 1 1 1 0 1 1 0 0 1 0
2+
1 1 1 0 0 0 1 0 0 1 1 0 1 0
3+
0 1 1 1 1 0 0 0 1 0 0 1 1 0
4+
1 0 0 1 0 1 0 0 0 0 1 1 1 0
5+
1 0 1 1 0 0 1 0 1 0 0 0 0 1
6+
0 1 0 1 1 1 1 0 0 0 1 0 0 1
7+
1 1 0 0 0 1 0 0 1 1 0 1 0 1
8+
0 0 1 0 1 0 0 0 0 1 1 1 0 1
9+
0 1 1 0 0 1 0 1 0 0 0 0 1 1
10+
1 0 0 0 1 0 0 1 1 0 1 0 1 1
11+
0 0 0 1 0 0 1 1 0 1 0 1 1 1

consist.m

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
function errstring = consist(model, type, inputs, outputs)
2+
%CONSIST Check that arguments are consistent.
3+
%
4+
% Description
5+
%
6+
% ERRSTRING = CONSIST(NET, TYPE, INPUTS) takes a network data structure
7+
% NET together with a string TYPE containing the correct network type,
8+
% a matrix INPUTS of input vectors and checks that the data structure
9+
% is consistent with the other arguments. An empty string is returned
10+
% if there is no error, otherwise the string contains the relevant
11+
% error message. If the TYPE string is empty, then any type of network
12+
% is allowed.
13+
%
14+
% ERRSTRING = CONSIST(NET, TYPE) takes a network data structure NET
15+
% together with a string TYPE containing the correct network type, and
16+
% checks that the two types match.
17+
%
18+
% ERRSTRING = CONSIST(NET, TYPE, INPUTS, OUTPUTS) also checks that the
19+
% network has the correct number of outputs, and that the number of
20+
% patterns in the INPUTS and OUTPUTS is the same. The fields in NET
21+
% that are used are
22+
% type
23+
% nin
24+
% nout
25+
%
26+
% See also
27+
% MLPFWD
28+
%
29+
30+
% Copyright (c) Ian T Nabney (1996-9)
31+
32+
% Assume that all is OK as default
33+
errstring = '';
34+
35+
% If type string is not empty
36+
if ~isempty(type)
37+
% First check that model has type field
38+
if ~isfield(model, 'type')
39+
errstring = 'Data structure does not contain type field';
40+
return
41+
end
42+
% Check that model has the correct type
43+
s = model.type;
44+
if ~strcmp(s, type)
45+
errstring = ['Model type ''', s, ''' does not match expected type ''',...
46+
type, ''''];
47+
return
48+
end
49+
end
50+
51+
% If inputs are present, check that they have correct dimension
52+
if nargin > 2
53+
if ~isfield(model, 'nin')
54+
errstring = 'Data structure does not contain nin field';
55+
return
56+
end
57+
58+
data_nin = size(inputs, 2);
59+
if model.nin ~= data_nin
60+
errstring = ['Dimension of inputs ', num2str(data_nin), ...
61+
' does not match number of model inputs ', num2str(model.nin)];
62+
return
63+
end
64+
end
65+
66+
% If outputs are present, check that they have correct dimension
67+
if nargin > 3
68+
if ~isfield(model, 'nout')
69+
errstring = 'Data structure does not conatin nout field';
70+
return
71+
end
72+
data_nout = size(outputs, 2);
73+
if model.nout ~= data_nout
74+
errstring = ['Dimension of outputs ', num2str(data_nout), ...
75+
' does not match number of model outputs ', num2str(model.nout)];
76+
return
77+
end
78+
79+
% Also check that number of data points in inputs and outputs is the same
80+
num_in = size(inputs, 1);
81+
num_out = size(outputs, 1);
82+
if num_in ~= num_out
83+
errstring = ['Number of input patterns ', num2str(num_in), ...
84+
' does not match number of output patterns ', num2str(num_out)];
85+
return
86+
end
87+
end

demecoc1.m

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
function demecoc1()
2+
% DEMECOC1 - Demo program for error correcting output codes
3+
%
4+
% DEMECOC1
5+
% Show a simple multi class problem (VOWEL-CONTEXT from UCI archive)
6+
% with ECOC and Support Vector Machine as the base learner.
7+
%
8+
% See also ECOC, ECOCLOAD, ECOCTRAIN, ECOCFWD
9+
%
10+
11+
%
12+
% Copyright (c) by Anton Schwaighofer (2001)
13+
% $Revision: 1.2 $ $Date: 2002/01/07 20:52:34 $
14+
% mailto:anton.schwaighofer@gmx.net
15+
%
16+
% This program is released unter the GNU General Public License.
17+
%
18+
19+
load('demecoc1.mat', 'Xtrain', 'Ytrain', 'Xtest', 'Ytest');
20+
21+
[N, d] = size(Xtrain);
22+
% 11 class problem, solve with 14 bit code
23+
net = ecoc(11,14);
24+
net.verbosity = 2;
25+
% Load code matrix from given file
26+
net = ecocload(net, 'code14-11');
27+
28+
% For a 12 class problem with 15 bit code, Dietterichs archive provides a
29+
% code. This code can be loaded by
30+
% net = ecoc(12, 15);
31+
% net.codepath = '/some/path/to/' where ecoc-codes.tar.gz resides
32+
% net = ecocload(net);
33+
34+
% Initialise an instance of the base learning algorithm
35+
learner = svm(d, 'rbf', 0.5, 1);
36+
learner.recompute = Inf;
37+
% Train the individual bit learners, all starting out from the parameter
38+
% setting in the SVM structure LEARNER
39+
warning off;
40+
fprintf('Starting the training.\n');
41+
fprintf('This may take a while, since we need to train one SVM per bit ...\n');
42+
net = ecoctrain(net, learner, Xtrain, Ytrain+1);
43+
pred = ecocfwd(net, Xtest);
44+
fprintf('Classification result on the test set: %i out of %i correct\n', ...
45+
length(find((Ytest+1)==pred)), length(Ytest));
46+

demecoc1.mat

86.4 KB
Binary file not shown.

0 commit comments

Comments
 (0)