-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMain.m
50 lines (36 loc) · 1.35 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
%---------------------------------------------------------------------%
% Whale Optimization Algorithm (WOA) source codes demo version %
%---------------------------------------------------------------------%
%---Inputs-----------------------------------------------------------
% feat : feature vector ( Instances x Features )
% label : label vector ( Instances x 1 )
% N : Number of whales
% max_Iter : Maximum number of iterations
% b : Constant
%---Output-----------------------------------------------------------
% sFeat : Selected features (instances x features)
% Sf : Selected feature index
% Nf : Number of selected features
% curve : Convergence curve
%--------------------------------------------------------------------
%% Whale Optimization Algorithm
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);
% Parameter setting
N = 10;
max_Iter = 100;
% Whale Optimization Algorithm
[sFeat,Sf,Nf,curve] = jWOA(feat,label,N,max_Iter,HO);
% Accuracy
Acc = jKNN(sFeat,label,HO);
fprintf('\n Accuracy: %g %%',Acc);
% Plot convergence curve
plot(1:max_Iter,curve);
xlabel('Number of Iterations');
ylabel('Fitness Value');
title('WOA'); grid on;