-
Notifications
You must be signed in to change notification settings - Fork 1
/
demo1.m
42 lines (34 loc) · 1.12 KB
/
demo1.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
% % demo1
% % This demo shows the user how to perform feature selection with the GA
% % toolbox using all default parameters.
%== First, load the data
addpath([pwd '/data/']);
addpath([pwd '/fcns/']);
addpath([pwd '/stats/']);
load simulated_binary.mat
%=== Open parallel processing if using
parallelizeFlag = 0;
if (exist('matlabpool','file')==2) && parallelizeFlag
if matlabpool('size')<=0
matlabpool 4;
end
else
parallelizeFlag=0; % No MATLAB toolbox
end
%=== Next, instantiate the GA options
% A full list of options is available in the help file
opts=ga_opt_set('Parallelize',parallelizeFlag,'CostFcn',@cost_AUROC,'OptDir',1,...
'ErrorIterations',20,'ErrorGradient',0.005,...
'MinimizeFeatures',false,'OutputContent','debug',...
'PopulationSize', 4,'FitnessFcn','fit_GLM',...
'PlotFcn','plot_All','Display','plot',...
'Repetitions', 1,'MaxIterations',10);
% Run the GA
fprintf('Here we go! \n');
[ga_out, ga_options] = AlgoGen(X,y,opts);
%=== Save the output
save('GA_DemoOutput_1.mat','ga_out','ga_options');
%=== Close the parallel toolbox
if matlabpool('size')>0
matlabpool close;
end