-
Notifications
You must be signed in to change notification settings - Fork 0
/
getAlgorithmOptions.m
96 lines (85 loc) · 3.79 KB
/
getAlgorithmOptions.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
function [options,objFunOptions] = getAlgorithmOptions(algorithm,data,varargin)
% Options for the algorithms (NSGAII/BORG) and the objective function
%
%
%
% Copyright 2016 Riccardo Taormina (riccardo_taormina@sutd.edu.sg),
% Gulsah Karakaya (gulsahkilickarakaya@gmail.com;),
% Stefano Galelli (stefano_galelli@sutd.edu.sg),
% and Selin Damla Ahipasaoglu (ahipasaoglu@sutd.edu.sg;.
%
% Please refer to README.txt for further information.
%
%
% This file is part of Matlab-Multi-objective-Feature-Selection.
%
% Matlab-Multi-objective-Feature-Selection is free software: you can redistribute
% it and/or modify it under the terms of the GNU General Public License
% as published by the Free Software Foundation, either version 3 of the
% License, or (at your option) any later version.
%
% This code is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with MATLAB_IterativeInputSelection.
% If not, see <http://www.gnu.org/licenses/>.
%
% check nargin
if nargin == 2
problem_type = 'CLASSIFICATION';
elseif (nargin == 3) && varargin{1} == true
problem_type = 'REGRESSION';
else
error('Problem type not recognized!')
end
% extract attributes (PHI) and predictand (Y)
PHI = data(:,1:end-1);
[nPatterns,nAttrs] = size(PHI);
tempY = data(:,end);
if strcmp(problem_type, 'CLASSIFICATION')
% restructure predictand (array with same number of columns of number of classes)
classes = unique(tempY);
nClasses = numel(classes);
Y = zeros(nPatterns,nClasses);
for i = 1 : nClasses
thisClass = classes(i);
ixes = (tempY == thisClass);
Y(ixes,i) = 1;
end
else
Y = tempY;
end
% Objective Function options
objFunOptions.Y = Y; % predictand
objFunOptions.PHI = PHI; % attributes
objFunOptions.nFolds = 10; % folds for k-fold cross-validation
objFunOptions.nELM = 10; % size of ELM ensemble
objFunOptions.nUnits = 50; % number of units in ELM
objFunOptions.maxCardinality = 20; % maximum cardinality (important for large datasets)
% Algorithm options
if strcmp(algorithm,'NSGA2')
% NSGA2
options = nsgaopt(); % get default options
options.popsize = 100; % populations size
options.maxGen = 100; % max generation
options.numVar = nAttrs; % number of design variables
options.numCons = 0; % number of contraints
options.lb = zeros(1,nAttrs); % lower bound of design variables (0)
options.ub = ones(1,nAttrs); % upper bound of design variables (1)
options.vartype = ones(1,nAttrs); % specify all binary variables
options.outputInterval = 1; % interval between echo on screen
options.plotInterval = 1; % interval between plot updates
options.useParallel = 'no'; % use parallel ('yes'/'no')
options.poolsize = 1; % matlab poolisize (num. parallel threads)
elseif strcmp(algorithm,'BORG')
options.nvars = nAttrs; % number of design variables
options.nconstrs = 0; % number of contraints
options.NFE = 5000; % number of functions evaluations
options.lowerBounds = -ones(1,nAttrs); % lower bound of design variables (-1)
options.upperBounds = ones(1,nAttrs); % upper bound of design variables (1)
else
error('Algorithm not supported!')
end