|
1 | | -# Whale-Optimization-Algorithm-for-Feature-Selection |
| 1 | +# Whale Optimization Algorithm for Feature Selection |
| 2 | + |
| 3 | +[](https://github.com/JingweiToo/Whale-Optimization-Algorithm-for-Feature-Selection/blob/main/LICENSE) |
| 4 | +[](https://github.com/JingweiToo/Whale-Optimization-Algorithm-for-Feature-Selection) |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | +## Introduction |
| 10 | +* This toolbox offers a Whale Optimization Algorithm ( WOA ) method |
| 11 | +* The `Main` script illustrates the example of how WOA can solve the feature selection problem using benchmark dataset |
| 12 | + |
| 13 | + |
| 14 | +## Input |
| 15 | +* *`feat`* : feature vector ( Instances *x* Features ) |
| 16 | +* *`label`* : label vector ( Instances *x* 1 ) |
| 17 | +* *`N`* : number of whales |
| 18 | + |
| 19 | + |
| 20 | +## Output |
| 21 | +* *`sFeat`* : selected features |
| 22 | +* *`Sf`* : selected feature index |
| 23 | +* *`Nf`* : number of selected features |
| 24 | +* *`curve`* : convergence curve |
| 25 | + |
| 26 | + |
| 27 | +### Example |
| 28 | +```code |
| 29 | +% Benchmark data set |
| 30 | +load ionosphere.mat; |
| 31 | +
|
| 32 | +% Set 20% data as validation set |
| 33 | +ho=0.2; |
| 34 | +% Hold-out method |
| 35 | +HO=cvpartition(label,'HoldOut',ho); |
| 36 | +
|
| 37 | +% Parameter setting |
| 38 | +N = 10; |
| 39 | +max_Iter = 100; |
| 40 | +
|
| 41 | +% Whale Optimization Algorithm |
| 42 | +[sFeat,Sf,Nf,curve] = jWOA(feat,label,N,max_Iter,HO); |
| 43 | +
|
| 44 | +% Accuracy |
| 45 | +Acc = jKNN(sFeat,label,HO); |
| 46 | +fprintf('\n Accuracy: %g %%',Acc); fprintf('\n'); |
| 47 | +
|
| 48 | +% Plot convergence curve |
| 49 | +plot(1:max_Iter,curve); |
| 50 | +xlabel('Number of Iterations'); |
| 51 | +ylabel('Fitness Value'); |
| 52 | +title('WOA'); grid on; |
| 53 | +``` |
| 54 | + |
| 55 | +## Requirement |
| 56 | +* MATLAB 2014 or above |
| 57 | +* Statistics and Machine Learning Toolbox |
| 58 | + |
0 commit comments