-
Notifications
You must be signed in to change notification settings - Fork 18
/
ALtrain.m
28 lines (23 loc) · 1 KB
/
ALtrain.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function ALtrain(trnSet, modelParameters, num_of_classes, modelname, rundir)
% function ALtrain(trnSet, modelParameters, num_of_classes, modelname, rundir)
%
% trnSet: training set
% costFin: SVM C parameter
% stdzFin: SVM RBF Gaussian kernel sigma parameter
% num_of_classes: number of classes
% modelname: filename where the model will be saved to
% rundir: directory where 'multisvm' will run
%
% See also AL, ALtoolbox
enteteSTrnSet = [size(trnSet,1) size(trnSet,2)];
dlmwrite([rundir '/TrnSetShuffled.txt'], enteteSTrnSet, 'delimiter', ' ', 'precision', 8);
dlmwrite([rundir '/TrnSetShuffled.txt'], trnSet, 'delimiter', ' ', '-append');
% Entranement
cmdtrn = sprintf('multisvm %s/TrnSetShuffled.txt %s %d -c %f -std %f -dir %s', ...
rundir, modelname, num_of_classes, modelParameters.costFin, modelParameters.stdzFin * sqrt(2), rundir);
if ~ispc, cmdtrn = ['./' cmdtrn]; end
[status,result] = system(cmdtrn);
if status ~= 0
disp(result)
error('ALToolbox:AL:multisvm','Error running multisvm')
end