-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
1,636 additions
and
19 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
function [trYhat, valYhat,W1,W2,bias] =... | ||
ELMregression(trX, trY, valX, nUnits) | ||
|
||
% This function implements an ELM classifier with tanh activation function. | ||
% | ||
% Inputs: trX <- array of training inputs with size = num. features x num. training patterns | ||
% trY <- array of training targets with size = num. categories x num. training patterns | ||
% (for each i-th column of trY only the entry relative to the correct category is 1) | ||
% valX <- array of validation inputs with size = num. features x num. training patterns | ||
% nUnits <- num. hidden units of ELM | ||
% | ||
% Output: | ||
% trYhat <- array of training target predictions with size = 1 x num. training patterns | ||
% (each i-th is an integer = predicted category) | ||
% valYhat <- array of validaiton target predictions with size = 1 x num. validation patterns | ||
% (each i-th is an integer = predicted category) | ||
% W1,W2,bias <- the trained parameters of the ELM | ||
% | ||
% Reference: Huang, G.-B., Zhu, Q.-Y., Siew, C.-K., 2006. Extreme learning machine: Theory and applications. | ||
% Neurocomputing 70, 489–501. doi:10.1016/j.neucom.2005.12.126 | ||
% | ||
% | ||
% | ||
% | ||
% 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/>. | ||
% | ||
|
||
% get number of features and number of patterns for training and validation | ||
[nFeatures,nPatternsTr] = size(trX); | ||
nPatternsVal = size(valX,2); | ||
|
||
% generate random input->hidden weights W1 (between -1 and 1) | ||
W1 = rand(nUnits,nFeatures)*2-1; | ||
|
||
% generate random biases (between 0 and 1) | ||
bias = rand(nUnits,1); | ||
|
||
% compute hidden neuron output matrix H | ||
H = sigActFun(W1*trX + repmat(bias,[1,nPatternsTr])); | ||
|
||
% compute hidden->output weights W2 | ||
Hinv = pinv(H'); | ||
W2 = Hinv * trY'; | ||
|
||
% get ELM response on training | ||
temp = (H' * W2)'; | ||
[~,temp] = max(temp,[],1); | ||
trYhat = temp'; | ||
|
||
% ... and validation dataset | ||
Hval = sigActFun(W1*valX + repmat(bias,[1,nPatternsVal])); | ||
valYhat = (Hval' * W2)'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
function SU = computeSU(x,y) | ||
% Computes simmetric uncertainty between two variables | ||
% | ||
% | ||
% 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/>. | ||
|
||
% discretization options | ||
nBins = 20; | ||
quantType = 'equalwidth'; | ||
|
||
% quantize variables | ||
x = quantizeVariable(x,nBins,quantType); | ||
y = quantizeVariable(y,nBins,quantType); | ||
|
||
% compute entropies | ||
hX = entropy(x); | ||
hy = entropy(y); | ||
hXy = jointentropy(x, y); | ||
|
||
% compute mutual information | ||
MI = hX+hy-hXy; | ||
|
||
% compute symmetric uncertainty | ||
SU = 2*MI/(hX+hy); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 (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/>. | ||
% | ||
|
||
|
||
% 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 = []; |
Oops, something went wrong.