-
Notifications
You must be signed in to change notification settings - Fork 0
/
script_example_NSGAII_REGRESSION.m
136 lines (97 loc) · 3.99 KB
/
script_example_NSGAII_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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
% This script illustrates the NSGA-II implementation of the
% WQEISS input selection technique described in:
%
% Taormina, R., Galelli, S., Karakaya, G., Ahipasaoglu, S.D.
% An information theoretic approach to select alternate subsets
% of predictors for data-driven hydrological models.
% Water Resources Research (in review)
%
% WQEISS and other techniques for feature selection in classificatio
% problems are described in:
%
% Karakaya, G., Galelli, S., Ahipasaoglu, S.D., Taormina, R., 2015.
% Identifying (Quasi) Equally Informative Subsets in Feature Selection Problems
% for Classification: A Max-Relevance Min-Redundancy Approach.
% IEEE Trans. Cybern. doi:10.1109/TCYB.2015.2444435
%
%
% 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/>.
%
% Environmental Intelligence Lab version
% Matteo Sangiorgio, email: matteo.sangiorgio@polimi.it
%
clc; clear;
%% include paths
addpath('mi'); % Peng's mutual information
addpath('nsga2_MATLAB_alternative'); % LIN's NPGM (for NSGA-II)
addpath('pareto_front'); % Yi Cao's paretofront toolbox
%% Load and prepare dataset
% load dataset
filePath = 'Concrete_Data.csv';
[orig_data,varNames,varTypes] = readData(filePath);
% remove rainfall column from ForestFires dataset
% (sometimes it leads to singularity problems)
% orig_data(:,end-1) = [];
% transform data
transf_data = transformData(orig_data,varTypes);
% normalize data
norm_data = normalizeData(transf_data);
% compute relevance and redundacy
global suRED suREL
[suRED,suREL] = computeRelevanceRedundancy(norm_data);
%% Prepare for launching the algorithms
% specify GO algorithm to use (BORG or NSGA2)
GOalgorithm = 'NSGA2';
% get algorithm options
global objFunOptions
[options,objFunOptions] = ...
getAlgorithmOptions(GOalgorithm,norm_data,true);
% initialize overall archive and array containing the values of the
% objctive functions (fvals)
global archive fvals ix_solutions
archive = {}; % archive of all solutions explored
fvals = []; % values of the obj function explored
% RELEVANCE - REDUNDACY - SU - #INPUTS
ix_solutions = []; % this will track which solutions are found by each algorithm
%% launch WQEISS
fprintf ('Launching WQEISS\n')
% define number of obj functions and the matlab function coding them
options.numObj = 4;
options.objfun = @objFunWQEISS_regression;
% launch
nsga2(options);
% get solutions indexes for WQEISS
ixWQEISS = find(ix_solutions);
% compute final pareto front
ixesPF = find(paretofront(fvals(ixWQEISS,:)));
PF_WQEISS.archive = archive(ixWQEISS(ixesPF));
PF_WQEISS.fvals = fvals(ixWQEISS(ixesPF),:);
PF_WQEISS.fvals_ext = fvals(ixWQEISS(ixesPF),:);
%% delta elimination
delta = 100;
PFdelta_WQEISS = deltaElimination(PF_WQEISS,delta);
%% Plot Frequency matrices
figure('name','W-QEISS frequency matrices');
plotFrequencyMatrix(PFdelta_WQEISS,options.numVar,varNames)