-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig_set.m
56 lines (46 loc) · 1.7 KB
/
config_set.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
function [ config ] = config_set( varargin )
%CONFIG_SET Constructs the default configuration stucture to be used by
%nytro_train
% Set default configuration fields
config = struct();
% data
config.data.shuffle = 1;
% crossValidation
config.crossValidation.storeTrainingError = 0;
config.crossValidation.validationPart = 0.2;
config.crossValidation.recompute = 0;
config.crossValidation.errorFunction = @rmse;
config.crossValidation.codingFunction = [];
config.crossValidation.stoppingRule = @windowLinearFitting;
config.crossValidation.windowSize = 10;
config.crossValidation.threshold = 0;
% filter
config.filter.fixedIterations = [];
config.filter.maxIterations = 500;
config.filter.gamma = [];
% kernel
config.kernel.kernelFunction = @gaussianKernel;
config.kernel.kernelParameters = 1;
config.kernel.m = 100;
% Parse function inputs
if ~isempty(varargin)
% Assign parsed parameters to object properties
fields = varargin(1:2:end);
for idx = 1:numel(fields)
currField = fields{idx};
% Parse current field
k = strfind(currField , '.');
k = [0 ; k ; (numel(currField)+1)];
tokens = cell(1,(numel(k) - 1));
for i = 1 : (numel(k) - 1);
tokens{i} = currField( (k(i)+1) : (k(i+1)-1) );
end
cmdStr = 'config';
for i = 1 : (numel(tokens) - 1)
cmdStr = strcat(cmdStr , '.(''' , tokens{i} , ''')');
end
cmdStr = strcat(cmdStr , '.(''' , tokens{end} , ''') = varargin{2*(idx-1) + 2};');
eval(cmdStr);
end
end
end