-
Notifications
You must be signed in to change notification settings - Fork 7
/
Main.m
67 lines (50 loc) · 1.78 KB
/
Main.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
%-------------------------------------------------------------------%
% Binary Grey Wolf Optimization (BGWO) demo version %
%-------------------------------------------------------------------%
%---Input------------------------------------------------------------
% feat : feature vector (instances x features)
% label : label vector (instances x 1)
% N : Number of wolves
% max_Iter : Maximum number of iterations
%---Output-----------------------------------------------------------
% sFeat : Selected features (instances x features)
% Sf : Selected feature index
% Nf : Number of selected features
% curve : Convergence curve
%--------------------------------------------------------------------
%% Binary Grey Wolf Optimization (Version 1)
clc, clear, close
% Benchmark data set
load ionosphere.mat;
% Set 20% data as validation set
ho = 0.2;
% Hold-out method
HO = cvpartition(label,'HoldOut',ho,'Stratify',false);
% Parameter setting
N = 10;
max_Iter = 100;
% Binary Grey Wolf Optimization
[sFeat,Sf,Nf,curve] = jBGWO1(feat,label,N,max_Iter,HO);
% Plot convergence curve
plot(1:max_Iter,curve);
xlabel('Number of Iterations');
ylabel('Fitness Value');
title('BGWO1'); grid on;
%% Binary Grey Wolf Optimization (Version 2)
clc, clear, close;
% Benchmark data set
load ionosphere.mat;
% Set 20% data as validation set
ho = 0.2;
% Hold-out method
HO = cvpartition(label,'HoldOut',ho,'Stratify',false);
% Parameter setting
N = 10;
max_Iter = 100;
% Binary Grey Wolf Optimization
[sFeat,Sf,Nf,curve] = jBGWO2(feat,label,N,max_Iter,HO);
% Plot convergence curve
plot(1:max_Iter,curve);
xlabel('Number of Iterations');
ylabel('Fitness Value');
title('BGWO2'); grid on;