-
Notifications
You must be signed in to change notification settings - Fork 14
/
objFunWQEISS_regression.m
108 lines (94 loc) · 3.74 KB
/
objFunWQEISS_regression.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
96
97
98
99
100
101
102
103
104
105
106
107
108
function [fval,dummy] = objFunWQEISS_regression(X,varargin)
global archive fvals objFunOptions suREL suRED ix_solutions
% objective function for developing WQEISS wrappers
%
%
%
% Copyright 2016 Riccardo Taormina ([email protected]),
% Gulsah Karakaya ([email protected];),
% Stefano Galelli ([email protected]),
% and Selin Damla Ahipasaoglu ([email protected];.
%
% 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/>.
%
% initialize fitness values
fval = zeros(1,4);
% unpack data and parameters
Y = objFunOptions.Y; % targets
PHI = objFunOptions.PHI; % inputs
nFolds = objFunOptions.nFolds; % nFolds for k-fold cross validation
nELM = objFunOptions.nELM; % number of repeats for computing the accuracy obj function
nUnits = objFunOptions.nUnits; % info on dataset
maxCardinality = objFunOptions.maxCardinality; % maximum cardinality
% retrieve populations size and number of attributes
nAttrs = size(X,2);
% transform decision variables from continuous to discrete
% 0 or 1 assigned depending on ratio of maxCardinality/nAttrs
% (This has no effect if the search algorithm is binary-coded already!)
varRatio = maxCardinality/nAttrs;
if varRatio > 0.5
X = X>0.5;
else
X = X>(1 - varRatio);
end
% get selected features from genotype
featIxes = find(X);
% get cardinality
cardinality = numel(featIxes);
% check if this combination of inputs is already in archive
% if so, assign existing fitness values to this genotype
temp = cellfun(@(x) isequal(x,featIxes),archive,'UniformOutput',false);
archiveIx = find([temp{:}]);
if ~isempty(archiveIx);
% get fval from lookup table
fval = fvals(archiveIx,:);
ix_solutions(archiveIx) = 1;
else
if cardinality > maxCardinality
% if cardinality > maxCardinality do not evaluate and assign very
% high values of the obj functions
fval = [Inf,Inf,Inf,numel(featIxes)];
elseif cardinality == 0
% no inputs selected, irregular solution
fval = [Inf,Inf,Inf,numel(featIxes)];
else
% found new combination, compute values of obj. functions
% relevance
REL = sum(suREL(featIxes));
% redundancy
if cardinality == 1
% 1 input selected, no redundancy
RED = 0;
else
temp = nchoosek(featIxes,2);
ixes = (temp(:,2)-1)*nAttrs+temp(:,1);
RED = sum(suRED(ixes));
end
% compute ELM classifier accuracy
SU = trainAndValidateELM_regression(PHI,Y,featIxes,nFolds,nELM,nUnits);
% fitness values (- for those obj. functions to maximize)
fval = [-REL,RED,-SU,cardinality];
% add solution to archive and fvals
archive = cat(1,archive,featIxes);
fvals = cat(1,fvals,[-REL,RED,-SU,cardinality]);
ix_solutions = cat(1,ix_solutions,1);
end
end
dummy = [];